Skip to content

Commit

Permalink
Minor refactoring for better comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriyb committed Aug 22, 2024
1 parent 7d46963 commit 60bbde0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class KIModel(val id: String, val name: String, val opSet: OperatorSetRegistry,
val arrayContext = coroutineContext[ArrayContext.Key]
val results = if (arrayContext == null) {
withContext(ArrayContext()) {
graph.execute(input, contexts).also { it.forEach { it.markOutput() } }
graph.execute(input, contexts).onEach { it.markOutput() }
}
} else {
graph.execute(input, contexts).also { it.forEach { it.markOutput() } }
graph.execute(input, contexts).onEach { it.markOutput() }
}
// val results = withContext(ArrayContext()) {
// graph.execute(input, contexts).also { it.forEach { it.markOutput() } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PerformanceRunner<T : ONNXData<*, *>>(private val engine: TestEngine<T>) {
val results = ArrayList<PerformanceResults>()

withContext(ArrayContext()) {
val arrayContext = coroutineContext[ArrayContext.Key]
// val arrayContext = coroutineContext[ArrayContext.Key]
for (dataset in datasets) {
val inputs = dataset.data.map { engine.loadData(it.first, it.second) }

Expand Down Expand Up @@ -90,7 +90,8 @@ class PerformanceRunner<T : ONNXData<*, *>>(private val engine: TestEngine<T>) {
}.millis
times[i] = time

outputs.values.forEach { arrayContext?.returnNDArray(it.data as NDArrayCore) }
outputs.values.forEach { it.close() }
// outputs.values.forEach { arrayContext?.returnNDArray(it.data as NDArrayCore) }
}
}

Expand Down

0 comments on commit 60bbde0

Please sign in to comment.