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 {
178178 opName,
179179 attrs
180180 )
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
181184 result // .flatMap(x => IO.println("opName = " + opName).as(x))
182185 }
183186
Original file line number Diff line number Diff line change @@ -206,8 +206,10 @@ trait ORTOperatorBackend extends OpToONNXBytesConverter with AutoCloseable {
206206 opName,
207207 attrs
208208 )
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(_))
211213 }
212214
213215 def modelToPersist (mod : ModelProto , outName : String ) = {
You can’t perform that action at this time.
0 commit comments