Skip to content

Commit 02ad8ac

Browse files
committedMay 28, 2020
[BUGFIX] Fixing shape as string in manifest
1 parent 0837caf commit 02ad8ac

File tree

10 files changed

+62
-62
lines changed

10 files changed

+62
-62
lines changed
 

‎commons/src/main/java/com/ovh/mls/serving/runtime/core/tensor/TensorField.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public TensorShape getTensorShape() {
5757
return new TensorShape(shape);
5858
}
5959

60-
public void setShape(String shape) {
61-
this.shape = new TensorShape(shape).getArrayShape();
60+
public void setShape(int[] shape) {
61+
this.shape = shape;
6262
}
6363

6464
public List<TensorIndex> getFields() {

‎commons/src/main/java/com/ovh/mls/serving/runtime/core/tensor/TensorShape.java

+28-28
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,41 @@ public TensorShape(int[] shape) {
1212
this.shape = shape;
1313
}
1414

15-
public TensorShape(String shape) {
16-
this.shape = getShapeFromString(shape);
17-
}
15+
// public TensorShape(String shape) {
16+
// this.shape = getShapeFromString(shape);
17+
// }
1818

1919
public TensorShape(long[] shape) {
2020
this.shape = Arrays.stream(shape)
2121
.mapToInt(x -> (int) x)
2222
.toArray();
2323
}
2424

25-
/**
26-
* Extract a shape from a string like (?, 2, 2)
27-
*/
28-
private static int[] getShapeFromString(String stringShape) {
29-
String removeParenthesis = stringShape.substring(1, stringShape.length() - 1);
30-
String[] split = removeParenthesis.split(",");
31-
32-
if (removeParenthesis.isEmpty()) {
33-
return new int[0];
34-
}
35-
36-
Integer[] result = Arrays
37-
.stream(split)
38-
.map(String::trim)
39-
.map(x -> {
40-
if ("?".equals(x)) {
41-
return -1;
42-
} else {
43-
return Integer.parseInt(x);
44-
}
45-
})
46-
.toArray(Integer[]::new);
47-
48-
return ArrayUtils.toPrimitive(result);
49-
}
25+
// /**
26+
// * Extract a shape from a string like (?, 2, 2)
27+
// */
28+
// private static int[] getShapeFromString(String stringShape) {
29+
// String removeParenthesis = stringShape.substring(1, stringShape.length() - 1);
30+
// String[] split = removeParenthesis.split(",");
31+
//
32+
// if (removeParenthesis.isEmpty()) {
33+
// return new int[0];
34+
// }
35+
//
36+
// Integer[] result = Arrays
37+
// .stream(split)
38+
// .map(String::trim)
39+
// .map(x -> {
40+
// if ("?".equals(x)) {
41+
// return -1;
42+
// } else {
43+
// return Integer.parseInt(x);
44+
// }
45+
// })
46+
// .toArray(Integer[]::new);
47+
//
48+
// return ArrayUtils.toPrimitive(result);
49+
// }
5050

5151
public boolean handleBatch() {
5252
return shape.length != 0 && shape[0] == -1;

‎evaluator-onnx/src/test/resources/onnx/iris/manifest-same-output.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputs": [
55
{
66
"name": "float_input",
7-
"shape": "(?, 4)",
7+
"shape": [-1, 4],
88
"type": "float",
99
"fields": [
1010
{
@@ -29,7 +29,7 @@
2929
"outputs": [
3030
{
3131
"name": "output_label",
32-
"shape": "(?)",
32+
"shape": [-1],
3333
"type": "long",
3434
"fields": [
3535
{
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"name": "output_probability",
43-
"shape": "(?, 3)",
43+
"shape": [-1, 3],
4444
"type": "float",
4545
"fields": [
4646
{

‎evaluator-onnx/src/test/resources/onnx/iris/manifest.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputs": [
55
{
66
"name": "float_input",
7-
"shape": "(?, 4)",
7+
"shape": [-1, 4],
88
"type": "float",
99
"fields": [
1010
{
@@ -29,7 +29,7 @@
2929
"outputs": [
3030
{
3131
"name": "output_label",
32-
"shape": "(?)",
32+
"shape": [-1],
3333
"type": "long",
3434
"fields": [
3535
{
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"name": "output_probability",
43-
"shape": "(?, 3)",
43+
"shape": [-1, 3],
4444
"type": "float",
4545
"fields": [
4646
{

‎evaluator-onnx/src/test/resources/onnx/titanic/manifest.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputs": [
55
{
66
"name": "pclass",
7-
"shape": "(?, 1)",
7+
"shape": [-1, 1],
88
"type": "string",
99
"fields": [
1010
{
@@ -15,7 +15,7 @@
1515
},
1616
{
1717
"name": "sex",
18-
"shape": "(?, 1)",
18+
"shape": [-1, 1],
1919
"type": "string",
2020
"fields": [
2121
{
@@ -26,7 +26,7 @@
2626
},
2727
{
2828
"name": "age",
29-
"shape": "(?, 1)",
29+
"shape": [-1, 1],
3030
"type": "float",
3131
"fields": [
3232
{
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"name": "fare",
40-
"shape": "(?, 1)",
40+
"shape": [-1, 1],
4141
"type": "float",
4242
"fields": [
4343
{
@@ -48,7 +48,7 @@
4848
},
4949
{
5050
"name": "embarked",
51-
"shape": "(?, 1)",
51+
"shape": [-1, 1],
5252
"type": "string",
5353
"fields": [
5454
{
@@ -61,7 +61,7 @@
6161
"outputs": [
6262
{
6363
"name": "output_label",
64-
"shape": "(?)",
64+
"shape": [-1],
6565
"type": "long",
6666
"fields": [
6767
{
@@ -71,7 +71,7 @@
7171
},
7272
{
7373
"name": "output_probability",
74-
"shape": "(?, 2)",
74+
"shape": [-1, 2],
7575
"type": "float",
7676
"fields": [
7777
{

‎evaluator-tensorflow/src/test/resources/tensorflow/2d_savedmodel/2d-tensorflow-model-manifest-same-output.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputs": [
55
{
66
"name": "input",
7-
"shape": "(?, 8)",
7+
"shape": [-1, 8],
88
"type": "float",
99
"fields": [
1010
{
@@ -29,7 +29,7 @@
2929
"outputs": [
3030
{
3131
"name": "output",
32-
"shape": "(?, 1)",
32+
"shape": [-1, 1],
3333
"type": "float",
3434
"fields": [
3535
{

‎evaluator-tensorflow/src/test/resources/tensorflow/2d_savedmodel/2d-tensorflow-model-manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputs": [
55
{
66
"name": "input",
7-
"shape": "(?, 8)",
7+
"shape": [-1, 8],
88
"type": "float",
99
"fields": [
1010
{
@@ -29,7 +29,7 @@
2929
"outputs": [
3030
{
3131
"name": "output",
32-
"shape": "(?, 1)",
32+
"shape": [-1, 1],
3333
"type": "float",
3434
"fields": [
3535
{

‎evaluator-tensorflow/src/test/resources/tensorflow/3d_savedmodel/3d-tensorflow-model-manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"inputs": [
55
{
66
"name": "input",
7-
"shape": "(?, 2, 4)",
7+
"shape": [-1, 2, 4],
88
"type": "float",
99
"fields": [
1010
{
@@ -29,7 +29,7 @@
2929
"outputs": [
3030
{
3131
"name": "output",
32-
"shape": "(?, 1)",
32+
"shape": [-1, 1],
3333
"type": "float",
3434
"fields": [
3535
{

‎evaluator-timeseries/src/test/resources/timeseries/datetime-string-manifest.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,69 +3,69 @@
33
{
44
"name": "date",
55
"type": "string",
6-
"shape": "(-1, -1)",
6+
"shape": [-1, -1],
77
"format": "yyyy-MM-dd HH:mm:ss"
88
}
99
],
1010
"outputs": [
1111
{
1212
"name": "year",
1313
"type": "integer",
14-
"shape": "(-1, -1)",
14+
"shape": [-1, -1],
1515
"format": "YEAR"
1616
},
1717
{
1818
"name": "month",
1919
"type": "integer",
20-
"shape": "(-1, -1)",
20+
"shape": [-1, -1],
2121
"format": "MONTH"
2222
},
2323
{
2424
"name": "dayofmonth",
2525
"type": "integer",
26-
"shape": "(-1, -1)",
26+
"shape": [-1, -1],
2727
"format": "DAYOFMONTH"
2828
},
2929
{
3030
"name": "hourofday",
3131
"type": "integer",
32-
"shape": "(-1, -1)",
32+
"shape": [-1, -1],
3333
"format": "HOUROFDAY"
3434
},
3535
{
3636
"name": "minuteofhour",
3737
"type": "integer",
38-
"shape": "(-1, -1)",
38+
"shape": [-1, -1],
3939
"format": "MINUTEOFHOUR"
4040
},
4141
{
4242
"name": "dayofweek",
4343
"type": "integer",
44-
"shape": "(-1, -1)",
44+
"shape": [-1, -1],
4545
"format": "DAYOFWEEK"
4646
},
4747
{
4848
"name": "year-string",
4949
"type": "string",
50-
"shape": "(-1, -1)",
50+
"shape": [-1, -1],
5151
"format": "yyyy"
5252
},
5353
{
5454
"name": "year-float",
5555
"type": "float",
56-
"shape": "(-1, -1)",
56+
"shape": [-1, -1],
5757
"format": "YEAR"
5858
},
5959
{
6060
"name": "timestamp-seconds",
6161
"type": "long",
62-
"shape": "(-1, -1)",
62+
"shape": [-1, -1],
6363
"format": "TS_S"
6464
},
6565
{
6666
"name": "timestamp-years",
6767
"type": "long",
68-
"shape": "(-1, -1)",
68+
"shape": [-1, -1],
6969
"format": "TS_Y"
7070
}
7171
]

‎evaluator-timeseries/src/test/resources/timeseries/datetime-timestamp-manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
{
44
"name": "timestamp-seconds",
55
"type": "long",
6-
"shape": "(-1, -1)",
6+
"shape": [-1, -1],
77
"format": "TS_S"
88
}
99
],
1010
"outputs": [
1111
{
1212
"name": "date",
1313
"type": "string",
14-
"shape": "(-1, -1)",
14+
"shape": [-1, -1],
1515
"format": "yyyy-MM-dd HH:mm:ss"
1616
}
1717
]

0 commit comments

Comments
 (0)
Please sign in to comment.