File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,9 @@ trait ORTOperatorBackend extends OpToONNXBytesConverter {
178
178
opName,
179
179
attrs
180
180
)
181
+ // unsafeRunSync is not avaible in the JS context
182
+ // so behavior on the JS side remains lazy
183
+ // and thus inefficient in case user code refers to Tensors more than once
181
184
result // .flatMap(x => IO.println("opName = " + opName).as(x))
182
185
}
183
186
Original file line number Diff line number Diff line change @@ -206,8 +206,10 @@ trait ORTOperatorBackend extends OpToONNXBytesConverter with AutoCloseable {
206
206
opName,
207
207
attrs
208
208
)
209
- // TODO: now that this is otherwise working, try memoizing here
210
- result.flatMap(IO .println(" Real call opName => " + opName).as(_))
209
+ // Using unsafeRunSync here to restore eager evaluation
210
+ // and avoid redundant op invocations in case user code refers to Tensors more than once
211
+ result.memoize.unsafeRunSync()
212
+ // .flatMap(IO.println("Real call opName => " + opName).as(_))
211
213
}
212
214
213
215
def modelToPersist (mod : ModelProto , outName : String ) = {
You can’t perform that action at this time.
0 commit comments