Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,22 @@ public class StableHloConverter(
* `name -> encoding` map of every tensor that carries a non-null
* [TensorEncoding]. Duplicates (the same name appearing in multiple
* nodes) collapse to a single entry — first-writer-wins.
*
* Implementation note: uses an explicit `!in` check rather than
* `MutableMap.putIfAbsent` because the latter is a JVM-only
* extension and does not exist in Kotlin common-stdlib for WasmJS
* / JS / Native targets.
*/
private fun collectTensorEncodings(nodes: List<GraphNode>): Map<String, TensorEncoding> {
val result = linkedMapOf<String, TensorEncoding>()
for (node in nodes) {
for (spec in node.outputs) {
val encoding = spec.tensorEncoding ?: continue
result.putIfAbsent(spec.name, encoding)
if (spec.name !in result) result[spec.name] = encoding
}
for (spec in node.inputs) {
val encoding = spec.tensorEncoding ?: continue
result.putIfAbsent(spec.name, encoding)
if (spec.name !in result) result[spec.name] = encoding
}
}
return result
Expand Down
Loading