Skip to content

Commit b45355f

Browse files
committed
JS backend compiling again
1 parent 02487f1 commit b45355f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

backends/.js/src/main/scala/ORTWebModelBackend.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ class ORTWebModelBackend(session: IO[InferenceSession]) extends Model() with ORT
6868
.map(_.toArray)
6969

7070
val output = inputTensors.flatMap { tns =>
71-
runModel[T, Tt, Td, S](
71+
IO{runModel[T, Tt, Td, S](
7272
session,
7373
tns,
7474
inputNames,
7575
outputNames
76-
)
76+
)}
7777
}
78-
output
78+
output.flatten
7979
}
8080

8181
}

backends/.js/src/main/scala/ORTWebOperatorBackend.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.emergentorder.onnx.Tensors.Tensor._
2929
import org.emergentorder.compiletime._
3030
import io.kjaer.compiletime._
3131

32+
//TODO: fix redundant computation due to cats-effect on the JS side
3233
trait ORTWebOperatorBackend extends OpToONNXBytesConverter {
3334

3435
def getSession(bytes: Array[Byte]) = {
@@ -143,7 +144,7 @@ trait ORTWebOperatorBackend extends OpToONNXBytesConverter {
143144
val result: IO[Tensor[T, Tuple3[Tt, Td, S]]] =
144145
for {
145146
mp <- modelProto.flatMap(IO.println("OpName => " + opName).as(_))
146-
res: Tuple2[Array[T], Tuple3[Tt, Td, S]] <- {
147+
} yield {
147148
// println(mp)
148149
callByteArrayOp(
149150
mp.toByteArray,
@@ -153,7 +154,7 @@ trait ORTWebOperatorBackend extends OpToONNXBytesConverter {
153154
}
154155
)
155156
}
156-
} yield IO.eval(cats.Eval.later { res })
157+
157158
result.flatten
158159
}
159160

core/src/main/scala/Tensors.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ object Tensors {
3131
// Need this alias to not conflict with other Tensors
3232
// TODO: consider using TF-Java ndarray as backing instead of Scala Array here
3333
// S is overloaded
34-
opaque type Tensor[T <: Supported, +Ax <: Axes] = IO[Tuple2[Array[T], Ax]]
34+
type Tensor[T <: Supported, +Ax <: Axes] = IO[InnerTensor[T, Ax]]
35+
opaque type InnerTensor[T <: Supported, +Ax <: Axes] = Tuple2[Array[T], Ax]
3536

3637
type SparseTensor[T <: Supported, A <: Axes] = Tensor[T, A]
3738

0 commit comments

Comments
 (0)