@@ -35,8 +35,7 @@ trait ORTOperatorBackend
35
35
def runModel (
36
36
sess : Session ,
37
37
input_tensor_values : Array [Value ],
38
- inputNames : PointerPointer [BytePointer ],
39
- nodeDims : Array [LongPointer ],
38
+ inputNames : PointerPointer [BytePointer ],
40
39
outputNames : PointerPointer [BytePointer ]
41
40
) = {
42
41
@@ -142,6 +141,7 @@ trait ORTOperatorBackend
142
141
case f : Array [Float ] => getTensorFloat(tens)
143
142
case i : Array [Int ] => getTensorInt(tens)
144
143
case l : Array [Long ] => getTensorLong(tens)
144
+ case b : Array [Boolean ] => getTensorBoolean(tens)
145
145
}
146
146
value
147
147
}
@@ -159,6 +159,7 @@ trait ORTOperatorBackend
159
159
case f : Array [Float ] => getTensorFloat(tens)
160
160
case i : Array [Int ] => getTensorInt(tens)
161
161
case l : Array [Long ] => getTensorLong(tens)
162
+ case b : Array [Boolean ] => getTensorBoolean(tens)
162
163
}
163
164
value
164
165
}
@@ -178,7 +179,7 @@ trait ORTOperatorBackend
178
179
}
179
180
180
181
val size : Long = dims.capacity
181
- val inputTensorSize = ( 0 until size.toInt).map(j => dims.get(j)).reduce( _* _)
182
+ val inputTensorSize = tens._1.size
182
183
183
184
val inputTensor : Value = Value .CreateTensorByte (
184
185
memory_info.asOrtMemoryInfo,
@@ -200,7 +201,7 @@ trait ORTOperatorBackend
200
201
}
201
202
202
203
val size : Long = dims.capacity
203
- val inputTensorSize = ( 0 until size.toInt).map(j => dims.get(j)).reduce( _* _)
204
+ val inputTensorSize = tens._1.size
204
205
205
206
val inputTensor : Value = Value .CreateTensorShort (
206
207
memory_info.asOrtMemoryInfo,
@@ -222,7 +223,7 @@ trait ORTOperatorBackend
222
223
}
223
224
224
225
val size : Long = dims.capacity
225
- val inputTensorSize = ( 0 until size.toInt).map(j => dims.get(j)).reduce( _* _)
226
+ val inputTensorSize = tens._1.size
226
227
227
228
val inputTensor : Value = Value .CreateTensorDouble (
228
229
memory_info.asOrtMemoryInfo,
@@ -244,7 +245,7 @@ trait ORTOperatorBackend
244
245
}
245
246
246
247
val size : Long = dims.capacity
247
- val inputTensorSize = ( 0 until size.toInt).map(j => dims.get(j)).reduce( _* _)
248
+ val inputTensorSize = tens._1.size
248
249
249
250
val inputTensor : Value = Value .CreateTensorInt (
250
251
memory_info.asOrtMemoryInfo,
@@ -266,7 +267,7 @@ trait ORTOperatorBackend
266
267
}
267
268
268
269
val size : Long = dims.capacity
269
- val inputTensorSize = ( 0 until size.toInt).map(j => dims.get(j)).reduce( _* _)
270
+ val inputTensorSize = tens._1.size
270
271
271
272
val inputTensor : Value = Value .CreateTensorLong (
272
273
memory_info.asOrtMemoryInfo,
@@ -293,7 +294,7 @@ trait ORTOperatorBackend
293
294
294
295
295
296
val size : Long = dims.capacity
296
- val inputTensorSize = ( 0 until size.toInt).map(j => dims.get(j)).reduce( _* _)
297
+ val inputTensorSize = tens._1.size
297
298
298
299
val inputTensor : Value = Value .CreateTensorFloat (
299
300
memory_info.asOrtMemoryInfo,
@@ -305,6 +306,31 @@ trait ORTOperatorBackend
305
306
inputTensor
306
307
}
307
308
309
+ def getTensorBoolean (tens : Tensor [Boolean ]): Value = {
310
+
311
+ val inputArray = tens._1
312
+
313
+ val inputPointer = new BoolPointer (new BooleanPointer (inputArray : _* ))
314
+
315
+ // input_node_names.put(i,new BytePointer(i.toString))
316
+
317
+ val dims = new LongPointer (tens._2.size)
318
+ (0 until tens._2.size).map { i =>
319
+ dims.put(i, tens._2(i))
320
+ }
321
+
322
+ val size : Long = dims.capacity
323
+ val inputTensorSize = tens._1.size
324
+
325
+ val inputTensor : Value = Value .CreateTensorBool (
326
+ memory_info.asOrtMemoryInfo,
327
+ inputPointer,
328
+ inputTensorSize,
329
+ dims,
330
+ size
331
+ )
332
+ inputTensor
333
+ }
308
334
309
335
def callByteArrayOp [
310
336
T : ClassTag
@@ -324,22 +350,24 @@ trait ORTOperatorBackend
324
350
val output_node_names = new PointerPointer [BytePointer ](1 )
325
351
326
352
327
- val inputDimsAndValues : Array [Tuple2 [ LongPointer , Value ] ] = (0 until x.size).map{i =>
353
+ val inputDimsAndValues : Array [Value ] = (0 until x.size).map{i =>
328
354
355
+ val tens = x(i)
329
356
330
- input_node_names.put(i,new BytePointer (i.toString))
331
-
332
- (null , getTensor(x(i)))
333
- }.toArray
357
+ tens match {
358
+ case None => None
359
+ case _ =>
360
+ input_node_names.put(i,new BytePointer (i.toString))
361
+ Some (getTensor(tens))
362
+ }
363
+ }.toArray.flatten
334
364
335
365
output_node_names.put(0l ,new BytePointer (" outName" ))
336
366
337
- // println(tens._2(0))
338
367
val output = runModel(
339
368
sess,
340
- inputDimsAndValues.map(_._2) ,
369
+ inputDimsAndValues,
341
370
input_node_names,
342
- inputDimsAndValues.map(_._1),
343
371
output_node_names
344
372
)
345
373
0 commit comments