Skip to content

Commit

Permalink
Merge pull request #488 from scala-steward/update/scalafmt-core-3.8.2
Browse files Browse the repository at this point in the history
Update scalafmt-core to 3.8.2
  • Loading branch information
EmergentOrder committed Jul 3, 2024
2 parents 9060575 + 1198d00 commit cc057df
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ aa0af90da52c49fd157e23ae5e3e148667a17fcd

# Scala Steward: Reformat with scalafmt 3.8.0
0e942e87563b915a9dc064eaf55f0b181b848a32

# Scala Steward: Reformat with scalafmt 3.8.2
394ff5b312131bd5afaa0cfdbefead351f66987c
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
align.preset = "more"
maxColumn = 100
version=3.8.1
version=3.8.2
runner.dialect = scala3
indent.main = 3
37 changes: 25 additions & 12 deletions backends/.js/src/main/scala/ORTOperatorBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ trait ORTOperatorBackend extends OpToONNXBytesConverter {
InferenceSession
] = IO.fromFuture(IO {
val infSess = new OrtSession()
infSess.loadModel(
bytesArrayBuffer, 0, bytesArrayBuffer.byteLength, {
val opts = InferenceSession.SessionOptions()
opts.executionProviders = scala.scalajs.js.Array("cpu")
opts
}
)
Future(infSess.asInstanceOf[org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession])
infSess.loadModel(
bytesArrayBuffer,
0,
bytesArrayBuffer.byteLength, {
val opts = InferenceSession.SessionOptions()
opts.executionProviders = scala.scalajs.js.Array("cpu")
opts
}
)
Future(
infSess.asInstanceOf[
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
]
)
})
session
}
Expand Down Expand Up @@ -340,10 +346,17 @@ trait ORTOperatorBackend extends OpToONNXBytesConverter {

val session: IO[
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
] = IO.fromFuture { IO {
val infSess = new OrtSession()
infSess.loadModel("squeezenet1.0-12.onnx", InferenceSession.SessionOptions())
Future(infSess.asInstanceOf[org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession])} }
] = IO.fromFuture {
IO {
val infSess = new OrtSession()
infSess.loadModel("squeezenet1.0-12.onnx", InferenceSession.SessionOptions())
Future(
infSess.asInstanceOf[
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
]
)
}
}
// val dataTypes = new FloatType {}

val dataType = "float32"
Expand Down
21 changes: 11 additions & 10 deletions backends/.js/src/test/scala/SqueezeNetTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@ import org.scalatest.freespec.AsyncFreeSpec
import org.scalatest.matchers.should._
import cats.effect.testing.scalatest.AsyncIOSpec


class ONNXScalaSpec extends AsyncFreeSpec with AsyncIOSpec with Matchers {

import org.emergentorder.onnx.onnxruntimeNode.mod.listSupportedBackends
listSupportedBackends()
import org.emergentorder.onnx.onnxruntimeNode.mod.listSupportedBackends
listSupportedBackends()

implicit override def executionContext =
scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
// TODO: push this inside ORTWebModelBackend, and use other create() which takes arraybufferlike
val session: IO[
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
] = IO.fromFuture(IO {
// val infSess = new org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession()

org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession.create(
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
.create(
"./squeezenet1_1_Opset18.onnx", {
val opts = org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession.SessionOptions()
val opts =
org.emergentorder.onnx.onnxruntimeCommon.inferenceSessionMod.InferenceSession
.SessionOptions()
opts.executionProviders = scala.scalajs.js.Array("cpu")
opts
}
).toFuture
)
.toFuture
})

"SqueezeNet ONNX-Scala model should predict dummy image class" in {
Expand Down Expand Up @@ -67,9 +70,7 @@ class ONNXScalaSpec extends AsyncFreeSpec with AsyncIOSpec with Matchers {
singleIO.asserting(x =>
((x._1(0), x._1(1), x._2.indices.maxBy(x._2))
shouldBe
(1,
1000,
753))
(1, 1000, 753))
)

}
Expand Down
4 changes: 1 addition & 3 deletions backends/.jvm/src/test/scala/SqueezeNetTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ class ONNXScalaSpec extends AsyncFreeSpec with AsyncIOSpec with Matchers {
singleIO.asserting(x =>
((x._1(0), x._1(1), x._2.indices.maxBy(x._2))
shouldBe
(1,
1000,
753))
(1, 1000, 753))
)

}
Expand Down
22 changes: 12 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ lazy val commonSettings = Seq(
resolvers += Resolver.mavenLocal,
resolvers += "Sonatype OSS Snapshots" at "https://s01.oss.sonatype.org/content/repositories/snapshots",
updateOptions := updateOptions.value.withLatestSnapshots(false),
libraryDependencies += "com.google.protobuf" % "protobuf-java" % "4.27.0",
libraryDependencies += "org.scala-lang" % "scala3-compiler_3" % scalaVersion.value exclude ("org.scala-sbt", "compiler-interface"),
libraryDependencies += "com.google.protobuf" % "protobuf-java" % "4.27.0",
libraryDependencies += "org.scala-lang" % "scala3-compiler_3" % scalaVersion.value exclude (
"org.scala-sbt",
"compiler-interface"
),
scalacOptions ++= Seq(
"-explain",
"-explain-types",
Expand Down Expand Up @@ -44,13 +47,13 @@ lazy val common = (crossProject(JSPlatform, JVMPlatform)
)
.jsSettings(
scalaJSStage := FullOptStage
)
)

lazy val proto = (crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure) in file("proto"))
.settings(
commonSettings,
name := "onnx-scala-proto",
name := "onnx-scala-proto",
mimaPreviousArtifacts := Set("org.emergent-order" %%% "onnx-scala-proto" % "0.17.0"),
crossScalaVersions := Seq(
dottyVersion
Expand All @@ -63,17 +66,17 @@ lazy val proto = (crossProject(JSPlatform, JVMPlatform)
)
.jsSettings(
scalaJSStage := FullOptStage
)
)

lazy val backends = (crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure) in file("backends"))
.dependsOn(core)
.settings(
commonSettings,
name := "onnx-scala-backends",
name := "onnx-scala-backends",
mimaPreviousArtifacts := Set("org.emergent-order" %%% "onnx-scala-backends" % "0.17.0"),
libraryDependencies ++= Seq(
"com.microsoft.onnxruntime" % "onnxruntime" % "1.18.0",
"com.microsoft.onnxruntime" % "onnxruntime" % "1.18.0",
"com.microsoft.onnxruntime" % "onnxruntime-extensions" % "0.11.0"
),
libraryDependencies += ("org.scalatest" %%% "scalatest" % scalaTestVersion) % Test,
Expand All @@ -89,7 +92,6 @@ lazy val backends = (crossProject(JSPlatform, JVMPlatform)
scalaJSUseMainModuleInitializer := true, // , //Testing
// stuck on web/node 1.15.1 due to this issue: https://github.com/microsoft/onnxruntime/issues/17979


// 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.18.0",
Expand All @@ -104,7 +106,7 @@ lazy val backends = (crossProject(JSPlatform, JVMPlatform)
_.withESVersion(org.scalajs.linker.interface.ESVersion.ES2021)
))
// scalaJSLinkerConfig ~= { _.withESFeatures(_.withESVersion(scala.scalajs.LinkingInfo.ESVersion.ES2021)) }
)
)
// For distribution as a library, using ScalablyTypedConverterGenSourcePlugin (vs ScalablyTypedConverterPlugin) is required
// which slows down the build (particularly the doc build, for publishing) considerably
// TODO: minimize to reduce build time and size of js output
Expand All @@ -116,7 +118,7 @@ lazy val core = (crossProject(JSPlatform, JVMPlatform)
.dependsOn(proto)
.settings(
commonSettings,
name := "onnx-scala",
name := "onnx-scala",
mimaPreviousArtifacts := Set("org.emergent-order" %%% "onnx-scala" % "0.17.0"),
crossScalaVersions := Seq(
dottyVersion
Expand Down

0 comments on commit cc057df

Please sign in to comment.