Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions src/main/java/com/redislabs/redisai/DataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,6 @@ protected Object toObject(List<byte[]> data) {
raw = SafeEncoder.encode(this.name());
}

static DataType getDataTypefromString(String dtypeRaw) {
DataType dt = null;
if (dtypeRaw.equals(DataType.INT32.name())) {
dt = DataType.INT32;
}
if (dtypeRaw.equals(DataType.INT64.name())) {
dt = DataType.INT64;
}
if (dtypeRaw.equals(DataType.FLOAT.name())) {
dt = DataType.FLOAT;
}
if (dtypeRaw.equals(DataType.DOUBLE.name())) {
dt = DataType.DOUBLE;
}
return dt;
}

/** The class for the data type to which Java object o corresponds. */
public static DataType baseObjType(Object o) {
Class<?> c = o.getClass();
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/redislabs/redisai/Tensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ protected static Tensor createTensorFromRespReply(List<?> reply) {
switch (arrayKey) {
case "dtype":
String dtypeString = SafeEncoder.encode((byte[]) reply.get(i + 1));
dtype = DataType.getDataTypefromString(dtypeString);
if (dtype == null) {
throw new JRedisAIRunTimeException("Unrecognized datatype: " + dtypeString);
}
dtype = DataType.valueOf(dtypeString);
break;
case "shape":
List<Long> shapeResp = (List<Long>) reply.get(i + 1);
Expand Down
26 changes: 0 additions & 26 deletions src/test/java/com/redislabs/redisai/DataTypeTest.java

This file was deleted.

21 changes: 13 additions & 8 deletions src/test/java/com/redislabs/redisai/RedisAITest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.redislabs.redisai;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;
Expand Down Expand Up @@ -175,9 +176,9 @@ public void testSetModelNegative() {
@Test
public void testSetModelFromModelOnnx() {
try {
ClassLoader classLoader = getClass().getClassLoader();
String modelPath = classLoader.getResource("test_data/mnist.onnx").getFile();
byte[] blob = Files.readAllBytes(Paths.get(modelPath));
byte[] blob =
Files.readAllBytes(
Paths.get(getClass().getClassLoader().getResource("test_data/mnist.onnx").toURI()));
Model m1 = new Model(Backend.ONNX, Device.CPU, new String[] {}, new String[] {}, blob);
Assert.assertTrue(client.setModel("mnist.onnx", m1));
Model m2 = client.getModel("mnist.onnx");
Expand All @@ -187,17 +188,21 @@ public void testSetModelFromModelOnnx() {
Model m3 = client.getModel("mnist.onnx.m2");
Assert.assertEquals(m2.getDevice(), m3.getDevice());
Assert.assertEquals(m2.getBackend(), m3.getBackend());
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}

@Test
public void testSetModelFromModelTFLite() {
try {
ClassLoader classLoader = getClass().getClassLoader();
String modelPath = classLoader.getResource("test_data/mnist_model_quant.tflite").getFile();
byte[] blob = Files.readAllBytes(Paths.get(modelPath));
byte[] blob =
Files.readAllBytes(
Paths.get(
getClass()
.getClassLoader()
.getResource("test_data/mnist_model_quant.tflite")
.toURI()));
Model m1 = new Model(Backend.TFLITE, Device.CPU, new String[] {}, new String[] {}, blob);
Assert.assertTrue(client.setModel("mnist.tflite", m1));
Model m2 = client.getModel("mnist.tflite");
Expand All @@ -207,7 +212,7 @@ public void testSetModelFromModelTFLite() {
Model m3 = client.getModel("mnist.tflite.m2");
Assert.assertEquals(m2.getDevice(), m3.getDevice());
Assert.assertEquals(m2.getBackend(), m3.getBackend());
} catch (IOException e) {
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
Expand Down