Skip to content

Commit

Permalink
Use ORT node for JS
Browse files Browse the repository at this point in the history
  • Loading branch information
EmergentOrder committed Dec 6, 2023
1 parent 84b1a59 commit 4bf775a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 131 deletions.
136 changes: 13 additions & 123 deletions backends/.js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions backends/.js/src/main/scala/ORTOperatorBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import scala.concurrent.duration._
import org.emergentorder.onnx.onnxruntimeCommon.tensorMod
//import typings.onnxruntimeWeb.tensorMod.Tensor.DataType
//import typings.onnxjs.libTensorMod.Tensor.DataTypeMap.DataTypeMapOps
import org.emergentorder.onnx.onnxruntimeWeb.mod.{InferenceSession => OrtSession}
import org.emergentorder.onnx.onnxruntimeWeb.mod.Tensor.{^ => OnnxTensor}
import org.emergentorder.onnx.onnxruntimeNode.mod.{InferenceSession => OrtSession}
import org.emergentorder.onnx.onnxruntimeNode.mod.Tensor.{^ => OnnxTensor}
//import typings.onnxruntimeWeb.ort.InferenceSession.{^ => InferenceSess}
//import typings.onnxjs.onnxMod.Onnx
import scala.scalajs.js.typedarray
Expand Down
2 changes: 1 addition & 1 deletion backends/.js/src/main/scala/ORTTensorUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.emergentorder.onnx.backends

//import scala.scalajs.js.Array
import org.emergentorder.onnx.Tensors._
import org.emergentorder.onnx.onnxruntimeWeb.mod.Tensor.{^ => OnnxTensor}
import org.emergentorder.onnx.onnxruntimeNode.mod.Tensor.{^ => OnnxTensor}
import scalajs.js.JSConverters._
import scala.scalajs.js.typedarray

Expand Down
2 changes: 1 addition & 1 deletion backends/.js/src/main/scala/ORTWebModelBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cats.effect.IO
import cats.implicits._
//import typings.onnxruntimeNode.mod.{InferenceSession => OrtSession}
import org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
import org.emergentorder.onnx.onnxruntimeWeb.mod.Tensor.{^ => OnnxTensor}
import org.emergentorder.onnx.onnxruntimeNode.mod.Tensor.{^ => OnnxTensor}
import org.emergentorder.onnx._
import org.emergentorder.onnx.Tensors._
import org.emergentorder.onnx.Tensors.Tensor._
Expand Down
4 changes: 2 additions & 2 deletions backends/.js/src/test/scala/SqueezeNetTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.emergentorder.onnx.Tensors.Tensor._
import org.emergentorder.onnx.backends._
import org.emergentorder.compiletime._
import org.emergentorder.io.kjaer.compiletime._
import org.emergentorder.onnx.onnxruntimeWeb.mod.{InferenceSession => OrtSession}
import org.emergentorder.onnx.onnxruntimeNode.mod.{InferenceSession => OrtSession}
import cats.effect.IO

import org.scalatest._
Expand All @@ -28,7 +28,7 @@ class ONNXScalaSpec extends AsyncFreeSpec with AsyncIOSpec with Matchers {
] = IO.fromFuture(IO {
OrtSession
.create(
"https://media.githubusercontent.com/media/onnx/models/main/vision/classification/squeezenet/model/squeezenet1.0-12.onnx", {
"./squeezenet1.0-12.onnx", {
val opts = InferenceSession.SessionOptions()
opts.executionProviders = scala.scalajs.js.Array("cpu")
opts
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ lazy val backends = (crossProject(JSPlatform, JVMPlatform, NativePlatform)
webpackCliVersion := "5.1.4",
startWebpackDevServer / version := "4.15.1",
scalaJSUseMainModuleInitializer := true, // , //Testing
Compile / npmDependencies += "onnxruntime-web" -> "1.15.1",
// Compile / npmDependencies += "onnxruntime-web" -> "1.15.1",
// ORT web and node are interchangeable, given minor package name changes, and node offers a significant speed-up (at the cost of working on the web)
// Compile / npmDependencies += "onnxruntime-node" -> "1.16.3",
Compile / npmDependencies += "onnxruntime-node" -> "1.15.1",
Compile / npmDependencies += "onnxruntime-common" -> "1.15.1",
Compile / npmDependencies += "typescript" -> "5.0.4",
libraryDependencies += "org.typelevel" %%% "cats-effect-testing-scalatest" % "1.5.0" % Test,
Expand Down

0 comments on commit 4bf775a

Please sign in to comment.