Skip to content

Commit 2a84b67

Browse files
committed
Bump ONNX version to 1.6.0; format; Add full backend trait
1 parent 46cdc20 commit 2a84b67

File tree

11 files changed

+1726
-248
lines changed

11 files changed

+1726
-248
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import org.emergentorder.onnx._
2+
3+
trait FullBackend
4+
extends Abs
5+
with Acos
6+
with Acosh
7+
with Add
8+
with And
9+
with ArgMax
10+
with ArgMin
11+
with ArrayFeatureExtractor
12+
with Asin
13+
with Asinh
14+
with Atan
15+
with AveragePool
16+
with BatchNormalization
17+
with Binarizer
18+
with BitShift
19+
with Cast
20+
with CastMap
21+
with CategoryMapper
22+
with Ceil
23+
with Clip
24+
with Compress
25+
with Concat
26+
with ConcatFromSequence
27+
with Constant
28+
with ConstantOfShape
29+
with Conv
30+
with ConvInteger
31+
with ConvTranspose
32+
with Cos
33+
with Cosh
34+
with CumSum
35+
with DepthToSpace
36+
with DequantizeLinear
37+
with Det
38+
with DictVectorizer
39+
with Div
40+
with Dropout
41+
with DynamicQuantizeLinear
42+
with Elu
43+
with Equal
44+
with Erf
45+
with Exp
46+
with Expand
47+
with EyeLike
48+
with Flatten
49+
with Floor
50+
with GRU
51+
with Gather
52+
with GatherElements
53+
with GatherND
54+
with Gemm
55+
with GlobalAveragePool
56+
with GlobalLpPool
57+
with GlobalMaxPool
58+
with Greater
59+
with HardSigmoid
60+
with Hardmax
61+
with Identity
62+
with If
63+
with Imputer
64+
with InstanceNormalization
65+
with IsInf
66+
with IsNaN
67+
with LRN
68+
with LSTM
69+
with LabelEncoder
70+
with LeakyRelu
71+
with Less
72+
with LinearClassifier
73+
with LinearRegressor
74+
with Log
75+
with LogSoftmax
76+
with Loop
77+
with LpNormalization
78+
with LpPool
79+
with MatMul
80+
with MatMulInteger
81+
with Max
82+
with MaxPool
83+
with MaxRoiPool
84+
with MaxUnpool
85+
with Mean
86+
with MeanVarianceNormalization
87+
with Min
88+
with Mod
89+
with Mul
90+
with Multinomial
91+
with Neg
92+
with NonMaxSuppression
93+
with NonZero
94+
with Normalizer
95+
with Not
96+
with OneHot
97+
with OneHotEncoder
98+
with Or
99+
with PRelu
100+
with Pad
101+
with Pow
102+
with QLinearConv
103+
with QLinearMatMul
104+
with QuantizeLinear
105+
with RNN
106+
with RandomNormal
107+
with RandomNormalLike
108+
with RandomUniform
109+
with RandomUniformLike
110+
with Range
111+
with Reciprocal
112+
with ReduceL1
113+
with ReduceL2
114+
with ReduceLogSum
115+
with ReduceLogSumExp
116+
with ReduceMax
117+
with ReduceMean
118+
with ReduceMin
119+
with ReduceProd
120+
with ReduceSum
121+
with ReduceSumSquare
122+
with Relu
123+
with Reshape
124+
with Resize
125+
with ReverseSequence
126+
with RoiAlign
127+
with Round
128+
with SVMClassifier
129+
with SVMRegressor
130+
with Scaler
131+
with Scan
132+
with Scatter
133+
with ScatterElements
134+
with ScatterND
135+
with Selu
136+
with SequenceAt
137+
with SequenceConstruct
138+
with SequenceEmpty
139+
with SequenceErase
140+
with SequenceInsert
141+
with SequenceLength
142+
with Shape
143+
with Shrink
144+
with Sigmoid
145+
with Sign
146+
with Sin
147+
with Sinh
148+
with Size
149+
with Slice
150+
with Softmax
151+
with Softplus
152+
with Softsign
153+
with SpaceToDepth
154+
with Split
155+
with SplitToSequence
156+
with Sqrt
157+
with Squeeze
158+
with StringNormalizer
159+
with Sub
160+
with Sum
161+
with Tan
162+
with Tanh
163+
with TfIdfVectorizer
164+
with ThresholdedRelu
165+
with Tile
166+
with TopK
167+
with Transpose
168+
with TreeEnsembleClassifier
169+
with TreeEnsembleRegressor
170+
with Unique
171+
with Unsqueeze
172+
with Upsample
173+
with Where
174+
with Xor
175+
with ZipMap

backends/src/main/scala/NGraphBackend.scala

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import org.bytedeco.onnx.global.onnx.check_model
3939
//TODO: ONNX Runtime backend for JVM (and Native?)
4040
class NGraphBackend(onnxBytes: Array[Byte])
4141
extends Add
42-
// with DataSource
42+
with DataSource
4343
with Constant
4444
with ArgMin
4545
with ArgMax
@@ -62,29 +62,27 @@ class NGraphBackend(onnxBytes: Array[Byte])
6262
with AveragePool
6363
with Reshape
6464
with AutoCloseable {
65-
//with DataSource
65+
6666
val scope = new PointerScope()
6767

6868
val ngraphBackend = Backend.create("CPU")
69-
/*
69+
70+
val onnxHelper = new ONNXHelper(onnxBytes)
71+
7072
def paramsMap[T: spire.math.Numeric: ClassTag] =
7173
onnxHelper.params
7274
.map(x => x._1 -> (x._2, x._3.asInstanceOf[Array[T]], x._4))
7375
.toMap
7476

75-
override def getParams[T: Numeric: ClassTag](name: String)(
76-
implicit ev: (UNil TypeOr Float16 TypeOr Float TypeOr Double TypeOr Byte TypeOr Short TypeOr Int TypeOr Long TypeOr UByte TypeOr UShort TypeOr UInt TypeOr ULong TypeOr Complex[
77-
Float
78-
] TypeOr Complex[Double])#check[T]
79-
): Tensor[T] = {
77+
override def getParams[T: Numeric: ClassTag](name: String): Tensor[T] = {
8078
val params = paramsMap.get(name)
8179
params match {
8280
case Some(x) => TensorFactory.getTensor(x._2, x._3.map(z => z: XInt))
8381
case None =>
8482
throw new Exception("No params found for param name: " + name)
8583
}
8684
}
87-
*/
85+
8886
def Abs1[@sp T: Numeric: ClassTag](
8987
name: String,
9088
consumed_inputs: Option[(Array[Int])] = None,
@@ -207,8 +205,8 @@ class NGraphBackend(onnxBytes: Array[Byte])
207205

208206
def Equal1[@sp T: Numeric: ClassTag, @sp T1: Numeric: ClassTag](
209207
name: String,
210-
axis: Option[(Int)] = None,
211-
broadcast: Option[(Int)] = None,
208+
axis: Option[(Int)],
209+
broadcast: Option[(Int)],
212210
A: Option[Tensor[T]],
213211
B: Option[Tensor[T]]
214212
)(

common/src/main/scala/UnionType.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515

1616
package org.emergentorder
1717

18-
package object union{
18+
package object union {
1919

20-
type ![A] = A => Nothing
21-
type !![A] = ![![A]]
20+
type ![A] = A => Nothing
21+
type !![A] = ![![A]]
2222

23-
trait Disjunction[T] {
24-
type or[S] = Disjunction[T with ![S]]
25-
type create = ![T]
26-
}
23+
trait Disjunction[T] {
24+
type or[S] = Disjunction[T with ![S]]
25+
type create = ![T]
26+
}
2727

28-
type Union[T] = {
29-
type or[S] = Disjunction[![T]]#or[S]
30-
}
28+
type Union[T] = {
29+
type or[S] = Disjunction[![T]]#or[S]
30+
}
3131

32-
type Contains[S, T] = !![S] <:< T
32+
type Contains[S, T] = !![S] <:< T
3333
}

0 commit comments

Comments
 (0)