From b072c308ec8c76930745c8f2741a809d36a8b03c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 16 Jun 2024 15:13:54 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.8.2 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 2da064e..143d6bd 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ align.preset = "more" maxColumn = 100 -version=3.8.1 +version=3.8.2 runner.dialect = scala3 indent.main = 3 From 394ff5b312131bd5afaa0cfdbefead351f66987c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 16 Jun 2024 15:14:08 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.8.2 Executed command: scalafmt --non-interactive --- .../src/main/scala/ORTOperatorBackend.scala | 37 +++++++++++++------ .../.js/src/test/scala/SqueezeNetTest.scala | 21 ++++++----- .../.jvm/src/test/scala/SqueezeNetTest.scala | 4 +- build.sbt | 22 ++++++----- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/backends/.js/src/main/scala/ORTOperatorBackend.scala b/backends/.js/src/main/scala/ORTOperatorBackend.scala index 370d517..4e644a7 100644 --- a/backends/.js/src/main/scala/ORTOperatorBackend.scala +++ b/backends/.js/src/main/scala/ORTOperatorBackend.scala @@ -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 } @@ -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" diff --git a/backends/.js/src/test/scala/SqueezeNetTest.scala b/backends/.js/src/test/scala/SqueezeNetTest.scala index b41373f..458cd00 100644 --- a/backends/.js/src/test/scala/SqueezeNetTest.scala +++ b/backends/.js/src/test/scala/SqueezeNetTest.scala @@ -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 { @@ -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)) ) } diff --git a/backends/.jvm/src/test/scala/SqueezeNetTest.scala b/backends/.jvm/src/test/scala/SqueezeNetTest.scala index 2dec2c2..e89d0bd 100644 --- a/backends/.jvm/src/test/scala/SqueezeNetTest.scala +++ b/backends/.jvm/src/test/scala/SqueezeNetTest.scala @@ -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)) ) } diff --git a/build.sbt b/build.sbt index d95939d..29f96ed 100755 --- a/build.sbt +++ b/build.sbt @@ -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", @@ -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 @@ -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, @@ -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", @@ -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 @@ -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 From 1198d00dffc2c00799485ee23c886ff999e3ba73 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 16 Jun 2024 15:14:08 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.8.2' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index ca9a141..4f82ec4 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -9,3 +9,6 @@ aa0af90da52c49fd157e23ae5e3e148667a17fcd # Scala Steward: Reformat with scalafmt 3.8.0 0e942e87563b915a9dc064eaf55f0b181b848a32 + +# Scala Steward: Reformat with scalafmt 3.8.2 +394ff5b312131bd5afaa0cfdbefead351f66987c