1
1
package org .emergentorder .onnx .backends
2
2
3
3
import scala .concurrent .duration ._
4
- import typings .onnxjs .onnxImplMod .Tensor .{^ => Tensor }
4
+ import typings .onnxruntimeWeb .tensorMod .Tensor
5
+ import typings .onnxruntimeWeb .tensorMod .Tensor .FloatType
6
+ import typings .onnxruntimeWeb .tensorMod .Tensor .DataType
5
7
// import typings.onnxjs.libTensorMod.Tensor.DataTypeMap.DataTypeMapOps
6
- import typings .onnxjs .onnxImplMod .InferenceSession .{^ => InferenceSession }
8
+ import typings .onnxruntimeWeb .mod .InferenceSession
9
+ // import typings.onnxruntimeWeb.ort.InferenceSession.{^ => InferenceSession}
7
10
// import typings.onnxjs.onnxMod.Onnx
8
11
9
- import typings .onnxjs .onnxImplMod ._
12
+ // import typings.onnxruntimeWeb .onnxImplMod._
10
13
11
14
import scala .scalajs .js .|
12
15
@@ -16,34 +19,23 @@ trait ONNXJSOperatorBackend {
16
19
implicit val ec : scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext .global
17
20
def test () = {
18
21
19
- val session = new InferenceSession ()
20
- val url = " relu.onnx"
21
- val modelFuture = session.loadModel(url).toFuture
22
+ val session = InferenceSession .create(" relu.onnx" )
23
+ val dataTypes = new FloatType {}
22
24
23
- val dataTypes = new typings.onnxjs.libTensorMod.Tensor .FloatType {}
24
-
25
- val outputFuture = modelFuture.map { x =>
26
- val inputs = Array (
25
+ /*
26
+ val inputs = Array(
27
27
new Tensor(
28
- scala.scalajs.js.Array [Boolean | Double ](
29
- (1 until 61 ).map(_.toDouble: Boolean | Double ).toArray: _*
28
+ "float32",
29
+ scala.scalajs.js.Array[Double](
30
+ (1 until 61).map(_.toDouble: Double).toArray: _*
30
31
),
31
- typings.onnxjs.onnxjsStrings.float32,
32
32
scala.scalajs.js.Array(3.0, 4.0, 5.0)
33
- ): typings.onnxjs.tensorMod.Tensor
34
- );
35
- println(" before run" )
36
- val res = session.run(scala.scalajs.js.Array (inputs : _* )).toFuture
37
- println(" after run" )
38
- res
39
- }.flatten
40
-
41
- import scala .util .{Success , Failure }
42
-
43
- outputFuture onComplete {
44
- case Success (t) => println(t.get(" y" ).get.dims)
45
- case Failure (fail) => println(fail)
46
- }
47
-
33
+ )
34
+ )
35
+ */
36
+ // println("before run")
37
+ // val res = session.run(scala.scalajs.js.Array(inputs: _*))
38
+ // println("after run")
39
+ // res
48
40
}
49
41
}
0 commit comments