Skip to content

Commit bf25167

Browse files
CRZbulabulaJackieTien97
authored andcommitted
[AINode] Fix call inference error (#17308)
1 parent 97f7333 commit bf25167

2 files changed

Lines changed: 2 additions & 90 deletions

File tree

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/model/ModelInformation.java

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public class ModelInformation {
3535
private static final int[] DEFAULT_MODEL_INPUT_SHAPE = new int[] {2880, 1};
3636
private static final int[] DEFAULT_MODEL_OUTPUT_SHAPE = new int[] {720, 1};
3737

38-
ModelType modelType;
39-
4038
private final String modelId;
4139

4240
private final int[] inputShape;
@@ -60,15 +58,13 @@ public ModelInformation(String modelId) {
6058
}
6159

6260
public ModelInformation(
63-
ModelType modelType,
6461
String modelId,
6562
int[] inputShape,
6663
int[] outputShape,
6764
TSDataType[] inputDataType,
6865
TSDataType[] outputDataType,
6966
String attribute,
7067
ModelStatus status) {
71-
this.modelType = modelType;
7268
this.modelId = modelId;
7369
this.inputShape = inputShape;
7470
this.outputShape = outputShape;
@@ -85,7 +81,6 @@ public ModelInformation(
8581
TSDataType[] inputDataType,
8682
TSDataType[] outputDataType,
8783
String attribute) {
88-
this.modelType = ModelType.USER_DEFINED;
8984
this.modelId = modelId;
9085
this.inputShape = inputShape;
9186
this.outputShape = outputShape;
@@ -95,7 +90,6 @@ public ModelInformation(
9590
}
9691

9792
public ModelInformation(String modelId, ModelStatus status) {
98-
this.modelType = ModelType.BUILT_IN_FORECAST;
9993
this.modelId = modelId;
10094
this.inputShape = new int[0];
10195
this.outputShape = new int[0];
@@ -104,21 +98,6 @@ public ModelInformation(String modelId, ModelStatus status) {
10498
this.status = status;
10599
}
106100

107-
// init built-in modelInformation
108-
public ModelInformation(ModelType modelType, String modelId) {
109-
this.modelType = modelType;
110-
this.modelId = modelId;
111-
this.inputShape = new int[2];
112-
this.outputShape = new int[2];
113-
this.inputDataType = new TSDataType[0];
114-
this.outputDataType = new TSDataType[0];
115-
this.status = ModelStatus.ACTIVE;
116-
}
117-
118-
public boolean isBuiltIn() {
119-
return modelType != ModelType.USER_DEFINED;
120-
}
121-
122101
public boolean available() {
123102
return status == ModelStatus.ACTIVE;
124103
}
@@ -139,26 +118,6 @@ public void setOutputLength(int length) {
139118
outputShape[0] = length;
140119
}
141120

142-
// calculation modelType and outputColumn metadata for different built-in models
143-
public void setInputColumnSize(int size) {
144-
inputShape[1] = size;
145-
if (modelType == ModelType.BUILT_IN_FORECAST) {
146-
outputShape[1] = size;
147-
} else if (modelType == ModelType.BUILT_IN_ANOMALY_DETECTION) {
148-
outputShape[1] = 1;
149-
} else {
150-
outputShape[1] = size;
151-
}
152-
if (modelType == ModelType.BUILT_IN_FORECAST) {
153-
buildOutputDataTypeForBuiltInModel(TSDataType.DOUBLE, outputShape[1]);
154-
} else if (modelType == ModelType.BUILT_IN_ANOMALY_DETECTION) {
155-
buildOutputDataTypeForBuiltInModel(TSDataType.INT32, outputShape[1]);
156-
} else {
157-
buildOutputDataTypeForBuiltInModel(TSDataType.FLOAT, outputShape[1]);
158-
buildInputDataTypeForBuiltInModel(TSDataType.FLOAT, inputShape[1]);
159-
}
160-
}
161-
162121
public void setInputDataType(TSDataType[] inputDataType) {
163122
this.inputDataType = inputDataType;
164123
}
@@ -206,7 +165,6 @@ public void setAttribute(String attribute) {
206165
}
207166

208167
public void serialize(DataOutputStream stream) throws IOException {
209-
ReadWriteIOUtils.write(modelType.ordinal(), stream);
210168
ReadWriteIOUtils.write(status.ordinal(), stream);
211169
ReadWriteIOUtils.write(modelId, stream);
212170
if (status == ModelStatus.UNAVAILABLE) {
@@ -231,7 +189,6 @@ public void serialize(DataOutputStream stream) throws IOException {
231189
}
232190

233191
public void serialize(FileOutputStream stream) throws IOException {
234-
ReadWriteIOUtils.write(modelType.ordinal(), stream);
235192
ReadWriteIOUtils.write(status.ordinal(), stream);
236193
ReadWriteIOUtils.write(modelId, stream);
237194
if (status == ModelStatus.UNAVAILABLE) {
@@ -256,7 +213,6 @@ public void serialize(FileOutputStream stream) throws IOException {
256213
}
257214

258215
public void serialize(ByteBuffer byteBuffer) {
259-
ReadWriteIOUtils.write(modelType.ordinal(), byteBuffer);
260216
ReadWriteIOUtils.write(status.ordinal(), byteBuffer);
261217
ReadWriteIOUtils.write(modelId, byteBuffer);
262218
if (status == ModelStatus.UNAVAILABLE) {
@@ -281,7 +237,6 @@ public void serialize(ByteBuffer byteBuffer) {
281237
}
282238

283239
public static ModelInformation deserialize(ByteBuffer buffer) {
284-
ModelType modelType = ModelType.values()[ReadWriteIOUtils.readInt(buffer)];
285240
ModelStatus status = ModelStatus.values()[ReadWriteIOUtils.readInt(buffer)];
286241
String modelName = ReadWriteIOUtils.readString(buffer);
287242
if (status == ModelStatus.UNAVAILABLE) {
@@ -311,18 +266,10 @@ public static ModelInformation deserialize(ByteBuffer buffer) {
311266
String attribute = ReadWriteIOUtils.readString(buffer);
312267

313268
return new ModelInformation(
314-
modelType,
315-
modelName,
316-
inputShape,
317-
outputShape,
318-
inputDataType,
319-
outputDataType,
320-
attribute,
321-
status);
269+
modelName, inputShape, outputShape, inputDataType, outputDataType, attribute, status);
322270
}
323271

324272
public static ModelInformation deserialize(InputStream stream) throws IOException {
325-
ModelType modelType = ModelType.values()[ReadWriteIOUtils.readInt(stream)];
326273
ModelStatus status = ModelStatus.values()[ReadWriteIOUtils.readInt(stream)];
327274
String modelName = ReadWriteIOUtils.readString(stream);
328275
if (status == ModelStatus.UNAVAILABLE) {
@@ -351,21 +298,13 @@ public static ModelInformation deserialize(InputStream stream) throws IOExceptio
351298

352299
String attribute = ReadWriteIOUtils.readString(stream);
353300
return new ModelInformation(
354-
modelType,
355-
modelName,
356-
inputShape,
357-
outputShape,
358-
inputDataType,
359-
outputDataType,
360-
attribute,
361-
status);
301+
modelName, inputShape, outputShape, inputDataType, outputDataType, attribute, status);
362302
}
363303

364304
public ByteBuffer serializeShowModelResult() throws IOException {
365305
PublicBAOS buffer = new PublicBAOS();
366306
DataOutputStream stream = new DataOutputStream(buffer);
367307
ReadWriteIOUtils.write(modelId, stream);
368-
ReadWriteIOUtils.write(modelType.toString(), stream);
369308
ReadWriteIOUtils.write(status.toString(), stream);
370309
ReadWriteIOUtils.write(Arrays.toString(inputShape), stream);
371310
ReadWriteIOUtils.write(Arrays.toString(outputShape), stream);
@@ -382,7 +321,6 @@ public boolean equals(Object obj) {
382321
if (obj instanceof ModelInformation) {
383322
ModelInformation other = (ModelInformation) obj;
384323
return modelId.equals(other.modelId)
385-
&& modelType.equals(other.modelType)
386324
&& Arrays.equals(inputShape, other.inputShape)
387325
&& Arrays.equals(outputShape, other.outputShape)
388326
&& Arrays.equals(inputDataType, other.inputDataType)

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/model/ModelType.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)