add converter for aten.linalg_cross (torch.cross / torc… - #4485
Open
apbose wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/linalg.py 2026-08-13 20:17:38.528572+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/impl/linalg.py 2026-08-13 20:17:59.647057+00:00
@@ -29,18 +29,14 @@
a0, a1, a2 = (component(input, i, "a") for i in range(3))
b0, b1, b2 = (component(other, i, "b") for i in range(3))
def mul(lhs: TRTTensor, rhs: TRTTensor, label: str) -> TRTTensor:
- return impl.elementwise.mul(
- ctx, target, source_ir, f"{name}_{label}", lhs, rhs
- )
+ return impl.elementwise.mul(ctx, target, source_ir, f"{name}_{label}", lhs, rhs)
def sub(lhs: TRTTensor, rhs: TRTTensor, label: str) -> TRTTensor:
- return impl.elementwise.sub(
- ctx, target, source_ir, f"{name}_{label}", lhs, rhs
- )
+ return impl.elementwise.sub(ctx, target, source_ir, f"{name}_{label}", lhs, rhs)
r0 = sub(mul(a1, b2, "a1b2"), mul(a2, b1, "a2b1"), "r0")
r1 = sub(mul(a2, b0, "a2b0"), mul(a0, b2, "a0b2"), "r1")
r2 = sub(mul(a0, b1, "a0b1"), mul(a1, b0, "a1b0"), "r2")
…h.linalg.cross) torch.cross resolves its optional dim and delegates to aten.linalg_cross under decomposition, so a single converter for aten.linalg_cross.default covers both public APIs. Neither had a converter, so models using either op fell back to PyTorch or errored depending on partitioning settings. impl.linalg.cross splits each operand into its 3 components along dim via ISelect (gather), computes the cross product with elementwise mul/sub, and concatenates the 3 result components back along dim. A capability_validator rejects the case where dim's size isn't statically known to be 3, since the converter relies on that precondition. Fixes #3724
apbose
force-pushed
the
abose/linalg_cross_converter
branch
from
August 13, 2026 20:25
635f7f3 to
0b3770e
Compare
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.
Addresses #3724