Skip to content

Commit 3d05630

Browse files
committed
Update README; Revert to using Scala 2.12 as default; put generated programs in gen dir; Bump scalafmt version
1 parent ced0d33 commit 3d05630

File tree

11 files changed

+203
-32
lines changed

11 files changed

+203
-32
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ to build against all of Scala 2.11, 2.12, 2.13 and Dotty/3.0, where possible.
117117
Then you can add this to your project's build.sbt
118118

119119
```scala
120-
libraryDependencies += "org.emergentorder.onnx" %% "onnx-scala" % "1.5.0-0.1.0-SNAPSHOT"
120+
libraryDependencies += "org.emergentorder.onnx" %% "onnx-scala" % "1.6.0-0.1.0-SNAPSHOT"
121121
```
122122

123123
or
124124

125125
```scala
126-
libraryDependencies += "org.emergentorder.onnx" %% "onnx-scala-zio" % "1.5.0-0.1.0-SNAPSHOT"
126+
libraryDependencies += "org.emergentorder.onnx" %% "onnx-scala-zio" % "1.6.0-0.1.0-SNAPSHOT"
127127
```
128128

129129
and build away with the traits provided. Backend implementation (and other) PRs welcome!
@@ -140,15 +140,15 @@ export SBT_OPTS="-XX:+CMSClassUnloadingEnabled -Xmx28G -Xss8M -XX:MaxMetaspaceSi
140140

141141
either each time in the terminal, or in your `~/.bashrc` file or equivalent, or you will encounter errors.
142142

143-
Now, get `squeezenet.onnx` [here](https://s3.amazonaws.com/download.onnx/models/opset_8/squeezenet.tar.gz) (rename `model.onnx` from inside the tar.gz). This model and more can be found in the [ONNX Model Zoo](https://github.com/onnx/models).
143+
Now, get `squeezenet.onnx` [here](https://s3.amazonaws.com/download.onnx/models/opset_8/squeezenet.tar.gz) (rename `model.onnx` from inside the tar.gz and move it to: `programGenerator/.jvm/src/main/resources/`). This model and more can be found in the [ONNX Model Zoo](https://github.com/onnx/models).
144144

145145
Then:
146146

147147
```
148148
sbt "project programGeneratorJVM" "run squeezenet.onnx"
149149
```
150150

151-
The resulting generated program appears as `programGenerator/src/main/scala/generatedprograms/Squeezenet.scala` and you can run `sbt compile` to confirm that the generated code compiles.
151+
The resulting generated program appears as `programGenerator/src/gen/scala/Squeezenet.scala` and you can run `sbt compile` to confirm that the generated code compiles.
152152

153153
## Program Execution
154154

@@ -178,7 +178,7 @@ This mode is a work-in-progress.
178178
### Example execution
179179
The most extensive working example at the moment is `zio/src/main/scala/NCFZIO.scala`, an implementation of Neural Collaborative Filtering, although you currently need to provide your own model file to load params from at `zio/.jvm/src/main/resources/NCF.onnx`.
180180

181-
This example provides full model execution via the `fullNCF` method and fine-grained execution via the `fineNCF` method.
181+
This example provides full model execution via the `fullNCF` method, while an example of fine-grained execution can be found at `zio/src/main/scala/NCFZIOFine.scala` in the `fineNCF` method.
182182

183183
To run it, use:
184184
```
@@ -197,14 +197,14 @@ To take advantage of union types to express type constraints, a Dotty (Scala 3)
197197

198198
The ZIO variant is not yet available for Dotty.
199199

200-
Currently at ONNX 1.5.0.
200+
Currently at ONNX 1.6.0.
201201

202202

203203
### Built With
204204

205205
#### Core
206206

207-
* [ONNX via JavaCPP Preset for ONNX 1.5.0](https://github.com/bytedeco/javacpp-presets/tree/master/onnx) - Open Neural Network Exchange / The missing bridge between Java and native C++ libraries (For access to Protobuf definitions and operator schemas)
207+
* [ONNX via JavaCPP Preset for ONNX 1.6.0](https://github.com/bytedeco/javacpp-presets/tree/master/onnx) - Open Neural Network Exchange / The missing bridge between Java and native C++ libraries (For access to Protobuf definitions and operator schemas)
208208

209209
* [Spire](https://github.com/non/spire) - Typelevel project enabling generic numeric programming (For support for unsigned ints, complex numbers, the Numeric type class and type specialization to avoid boxing overhead)
210210

backends/src/main/scala/NGraphBackend.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import spire.math.ULong
1717
import spire.math.Complex
1818

1919
import org.emergentorder.onnx._
20+
import org.emergentorder.union._
2021
import org.bytedeco.javacpp._;
2122
import org.bytedeco.onnx.ModelProto;
2223
import org.bytedeco.onnx.global.onnx.ParseProtoFromBytes;

build.sbt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ val scala213Version = "2.13.1"
66
val spireVersion = "0.17.0-M1"
77
val zioVersion = "1.0.0-RC13"
88
val scalametaVersion = "4.2.3"
9-
val onnxJavaCPPPresetVersion = "1.5.0-1.5.1"
9+
val onnxJavaCPPPresetVersion = "1.6.0-1.5.2-SNAPSHOT"
1010
scalaVersion := scala212Version
1111

1212
lazy val commonSettings = Seq(
1313
scalaJSUseMainModuleInitializer := true, //Test only
1414
organization := "org.emergentorder.onnx",
15-
version := "1.5.0-0.1.0-SNAPSHOT",
15+
version := "1.6.0-0.1.0-SNAPSHOT",
1616
resolvers += Resolver.mavenLocal,
1717
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
1818
updateOptions := updateOptions.value.withLatestSnapshots(false),
@@ -31,7 +31,7 @@ lazy val common = (crossProject(JSPlatform, JVMPlatform, NativePlatform)
3131
)
3232
)
3333
.jvmSettings(
34-
scalaVersion := scala213Version,
34+
// scalaVersion := scala213Version,
3535
crossScalaVersions := Seq(
3636
dottyVersion,
3737
scala212Version,
@@ -41,7 +41,7 @@ lazy val common = (crossProject(JSPlatform, JVMPlatform, NativePlatform)
4141
publishArtifact in (Compile, packageDoc) := false
4242
)
4343
.jsSettings(
44-
scalaVersion := scala213Version,
44+
// scalaVersion := scala213Version,
4545
crossScalaVersions := Seq(scala212Version, scala211Version, scala213Version)
4646
)
4747
.nativeSettings(
@@ -58,7 +58,7 @@ lazy val programGenerator = (crossProject(JSPlatform, JVMPlatform)
5858
.settings(
5959
commonSettings,
6060
name := "onnx-scala-program-generator",
61-
scalaVersion := scala213Version,
61+
// scalaVersion := scala213Version,
6262
mainClass in (Compile, run) := Some(
6363
"org.emergentorder.onnx.ONNXProgramGenerator"
6464
),
@@ -88,9 +88,9 @@ lazy val backends = (crossProject(JVMPlatform, JSPlatform)
8888
.settings(
8989
commonSettings,
9090
name := "onnx-scala-backends",
91-
scalaVersion := scala213Version,
91+
// scalaVersion := scala213Version,
9292
libraryDependencies ++= Seq(
93-
"org.bytedeco" % "ngraph-platform" % "0.22.0-1.5.1"
93+
"org.bytedeco" % "ngraph-platform" % "0.25.0-1.5.2-SNAPSHOT"
9494
),
9595
publishArtifact in (Compile, packageDoc) := false
9696
)
@@ -110,7 +110,7 @@ lazy val core = (crossProject(JSPlatform, JVMPlatform)
110110
.settings(
111111
commonSettings,
112112
name := "onnx-scala",
113-
scalaVersion := scala213Version,
113+
// scalaVersion := scala213Version,
114114
excludeFilter in unmanagedSources := (CrossVersion
115115
.partialVersion(scalaVersion.value) match {
116116
case Some((0, n)) => ("ONNXHelper.scala")
@@ -181,7 +181,7 @@ lazy val zio = (crossProject(JVMPlatform, JSPlatform)
181181
.settings(
182182
commonSettings,
183183
name := "onnx-scala-zio",
184-
scalaVersion := scala213Version,
184+
// scalaVersion := scala213Version,
185185
publishArtifact in (Compile, packageDoc) := false,
186186
libraryDependencies ++= (CrossVersion
187187
.partialVersion(scalaVersion.value) match {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Copyright 2017-19, Emmanouil Antonios Platanios, Alexander Merritt. All Rights Reserved.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
4+
* use this file except in compliance with the License. You may obtain a copy of
5+
* the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
* License for the specific language governing permissions and limitations under
13+
* the License.
14+
*/
15+
16+
package org.emergentorder
17+
18+
package object union{
19+
20+
type ![A] = A => Nothing
21+
type !![A] = ![![A]]
22+
23+
trait Disjunction[T] {
24+
type or[S] = Disjunction[T with ![S]]
25+
type create = ![T]
26+
}
27+
28+
type Union[T] = {
29+
type or[S] = Disjunction[![T]]#or[S]
30+
}
31+
32+
type Contains[S, T] = !![S] <:< T
33+
}

core/src/main/scala/ONNX.scala

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,9 @@ import spire.math.Numeric
1111
import spire.implicits._
1212
import spire.algebra.Field
1313
import scala.reflect.ClassTag
14-
package object onnx {
15-
16-
type ![A] = A => Nothing
17-
type !![A] = ![![A]]
18-
19-
trait Disjunction[T] {
20-
type or[S] = Disjunction[T with ![S]]
21-
type create = ![T]
22-
}
14+
import org.emergentorder.union._
2315

24-
type Union[T] = {
25-
type or[S] = Disjunction[![T]]#or[S]
26-
}
27-
28-
type Contains[S, T] = !![S] <:< T
16+
package object onnx {
2917

3018
type UNil
3119

0 commit comments

Comments
 (0)