Repository navigation
feat(io-onnx): import LeakyRelu, Silu, Clip, BatchNormalization and Pad as real ops - #1466
Merged
Merged
Conversation
…ad as real ops (#1400) The ONNX importer mapped these node types to OnnxPlaceholderOperation, which made the graph import but throw on execution. - LeakyRelu -> leakyRelu (alpha attribute -> negativeSlope, default 0.01) - Silu -> silu - Clip -> clamp; min/max from attributes (opset < 11) or folded from initializer inputs (opset >= 11). Dynamic min/max tensors keep the placeholder so execution fails loudly instead of silently not clipping. - BatchNormalization -> batchNorm with its epsilon attribute; the executor decomposes inference-mode BN into primitive ops with per-channel (1, C, 1, ...) broadcast reshapes. - Pad -> pad2d for the mappable form (constant mode, zero fill, 4D input, spatial-only pads), pads from the attribute (opset < 11) or an INT64 initializer input (opset >= 11), with proper H/W output-shape inference. Other modes/layouts keep the placeholder. Supporting changes: - Ops whose trailing initializer inputs fold into parameters at import (Clip min/max, Pad pads) wire only the data input as a graph edge. - ComputeGraphExecutor: dispatch leakyRelu, clamp, pad2d and batchNorm; treat onnx_initializer nodes as input-like so their values bind by node id or tensor name and unused initializers no longer break execution. - skainet-io-onnx jvmTest gains a backend-cpu dependency so the new tests import AND execute each one-node graph against the real CPU ops. ConvTranspose (#1406) is intentionally not mapped here: it needs the convTranspose2d op that lands with #1464. Closes #1401, closes #1402, closes #1403, closes #1404, closes #1405. Part of #1400.
aharakal
approved these changes
Oct 31, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the op-mapping lanes of #1400. These ONNX node types imported as
OnnxPlaceholderOperation, so the graph built but threw on execution. They now map to operations theComputeGraphExecutordispatches, and each one-node graph imports and executes with PyTorch/ONNX-spec semantics:LeakyRelu(#1401)leakyRelualpha→negativeSlope, default 0.01Silu(#1402)siluClip(#1403)clampBatchNormalization(#1404)batchNorm(1, C, 1, …)broadcasts;epsilonhonouredPad(#1405)pad2dDesign notes:
BaseOperationsubclasses whose name matches the executor's dispatch (same asOnnxConcatOperation), so no public lang-core API changes.ComputeGraphExecutorgains dispatch forleakyRelu,clamp,pad2d,batchNorm, and treatsonnx_initializernodes as input-like: values bind by node id or tensor name, and unused initializers no longer break execution.ConvTranspose([Lane 2 · kotlin-core] ONNX importer — import ONNX ConvTranspose as a real op #1406) is deliberately not mapped here — it needs theconvTranspose2dop that lands with feat(ops): implement convTranspose2d — CPU kernel, backward and StableHLO lowering #1464; it stays a loud placeholder until that merges.Tests
OnnxRealOpsExecuteTest(jvmTest, with a new backend-cpu test dependency): builds one-node ONNX models with pbandk protos, imports them and runs them on the real CPU ops — value assertions for every op (BN against the closed-form reference), both Clip forms (attribute + folded initializers, with an edge-count assertion), both Pad forms (attribute + INT64 initializer, incl. output-shape inference), and the fail-loud paths (dynamic Clip bound, reflect-mode Pad).Closes #1401, closes #1402, closes #1403, closes #1404, closes #1405. Part of #1400.