@@ -78,40 +78,6 @@ DLDataType RAI_GetDLDataTypeFromORT(ONNXTensorElementDataType dtype) {
78
78
return (DLDataType ){ .bits = 0 };
79
79
}
80
80
81
- // OrtValue* RAI_OrtValueFromTensor(RAI_Tensor* t, RAI_Error *error) {
82
- // const OrtApi* ort = OrtGetApiBase()->GetApi(1);
83
- // OrtMemoryInfo* memory_info;
84
- // OrtStatus* status;
85
- // status = ort->CreateCpuMemoryInfo(OrtArenaAllocator, OrtMemTypeDefault, &memory_info);
86
- // if (status != NULL) {
87
- // goto error;
88
- // }
89
- //
90
- // OrtValue* out;
91
- // status = OrtCreateTensorWithDataAsOrtValue(
92
- // allocator_info,
93
- // t->tensor.dl_tensor.data,
94
- // RAI_TensorByteSize(t),
95
- // t->tensor.dl_tensor.shape,
96
- // t->tensor.dl_tensor.ndim,
97
- // RAI_GetOrtDataTypeFromDL(t->tensor.dl_tensor.dtype),
98
- // &out);
99
- //
100
- // if (status != NULL) {
101
- // OrtReleaseAllocatorInfo(allocator_info);
102
- // goto error;
103
- // }
104
- //
105
- // OrtReleaseAllocatorInfo(allocator_info);
106
- //
107
- // return out;
108
- //
109
- // error:
110
- // RAI_SetError(error, RAI_EMODELCREATE, OrtGetErrorMessage(status));
111
- // OrtReleaseStatus(status);
112
- // return NULL;
113
- // }
114
-
115
81
OrtValue * RAI_OrtValueFromTensors (RAI_Tensor * * ts , size_t count , RAI_Error * error ) {
116
82
OrtStatus * status = NULL ;
117
83
const OrtApi * ort = OrtGetApiBase ()-> GetApi (1 );
@@ -140,7 +106,7 @@ OrtValue* RAI_OrtValueFromTensors(RAI_Tensor** ts, size_t count, RAI_Error *erro
140
106
141
107
RAI_Tensor * t0 = ts [0 ];
142
108
143
- int ndim = t0 -> tensor .dl_tensor .ndim ;
109
+ const int ndim = t0 -> tensor .dl_tensor .ndim ;
144
110
int64_t batched_shape [ndim ];
145
111
146
112
for (size_t i = 0 ; i < ndim ; i ++ ) {
@@ -267,11 +233,11 @@ RAI_Tensor* RAI_TensorCreateFromOrtValue(OrtValue* v, size_t batch_offset, size_
267
233
goto error ;
268
234
}
269
235
270
- size_t len = dtype .bits * elem_count ;
236
+ const size_t len = dtype .bits * elem_count ;
271
237
272
- size_t total_bytesize = len * sizeof (char );
273
- size_t sample_bytesize = total_bytesize / total_batch_size ;
274
- size_t batch_bytesize = sample_bytesize * batch_size ;
238
+ const size_t total_bytesize = len * sizeof (char );
239
+ const size_t sample_bytesize = total_bytesize / total_batch_size ;
240
+ const size_t batch_bytesize = sample_bytesize * batch_size ;
275
241
276
242
char * data = RedisModule_Calloc (batch_bytesize , sizeof (* data ));
277
243
memcpy (data , ort_data + batch_offset , batch_bytesize );
@@ -489,8 +455,8 @@ int RAI_ModelRunORT(RAI_ModelRunCtx *mctx, RAI_Error *error)
489
455
OrtValue * inputs [n_input_nodes ];
490
456
OrtValue * outputs [n_output_nodes ];
491
457
492
- size_t ninputs = array_len (mctx -> batches [0 ].inputs );
493
- size_t noutputs = array_len (mctx -> batches [0 ].outputs );
458
+ const size_t ninputs = array_len (mctx -> batches [0 ].inputs );
459
+ const size_t noutputs = array_len (mctx -> batches [0 ].outputs );
494
460
495
461
if (ninputs != n_input_nodes ) {
496
462
char msg [70 ];
0 commit comments