From 22a0d12b8f508e44fa5b76262357eb62e7c9467d Mon Sep 17 00:00:00 2001 From: Frank Liu Date: Tue, 30 Aug 2022 20:56:43 -0700 Subject: [PATCH] [api] Remove unnecessary DeviceType interface Change-Id: Ife754d8b82371c1cd86d8201d003fe8f7995ed92 --- api/src/main/java/ai/djl/DeviceType.java | 37 ------------------- .../ai/djl/mxnet/engine/MxDeviceType.java | 5 +-- .../ai/djl/pytorch/engine/PtDeviceType.java | 3 +- 3 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 api/src/main/java/ai/djl/DeviceType.java diff --git a/api/src/main/java/ai/djl/DeviceType.java b/api/src/main/java/ai/djl/DeviceType.java deleted file mode 100644 index 45cc4fad4dd..00000000000 --- a/api/src/main/java/ai/djl/DeviceType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance - * with the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES - * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ -package ai.djl; - -/** {@code DeviceType} is a class used to map the Device name to their corresponding type number. */ -public interface DeviceType { - - /** - * Map device to its type number. - * - * @param device {@link Device} to map from - * @return the number specified by engine - */ - static int toDeviceType(Device device) { - return 0; - } - - /** - * Map device to its type number. - * - * @param deviceType the number specified by engine - * @return {@link Device} to map to - */ - static String fromDeviceType(int deviceType) { - return null; - } -} diff --git a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxDeviceType.java b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxDeviceType.java index 7d4e754a88f..6b38c2f404a 100644 --- a/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxDeviceType.java +++ b/engines/mxnet/mxnet-engine/src/main/java/ai/djl/mxnet/engine/MxDeviceType.java @@ -13,10 +13,9 @@ package ai.djl.mxnet.engine; import ai.djl.Device; -import ai.djl.DeviceType; /** DeviceType is the MXNet equivalent of the types in {@link Device}. */ -public final class MxDeviceType implements DeviceType { +public final class MxDeviceType { private static final String CPU_PINNED = "cpu_pinned"; @@ -38,7 +37,7 @@ public static int toDeviceType(Device device) { } else if (CPU_PINNED.equals(deviceType)) { return 3; } else { - throw new IllegalArgumentException("Unsupported device: " + device.toString()); + throw new IllegalArgumentException("Unsupported device: " + device); } } diff --git a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtDeviceType.java b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtDeviceType.java index c898ddfd8b3..78b62034590 100644 --- a/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtDeviceType.java +++ b/engines/pytorch/pytorch-engine/src/main/java/ai/djl/pytorch/engine/PtDeviceType.java @@ -13,10 +13,9 @@ package ai.djl.pytorch.engine; import ai.djl.Device; -import ai.djl.DeviceType; /** DeviceType is the PyTorch equivalent of the types in {@link Device}. */ -public final class PtDeviceType implements DeviceType { +public final class PtDeviceType { private PtDeviceType() {}