[Torch] Add aten.xlogy.Tensor decomposition - #4659
Merged
Merged
Conversation
Contributor
Author
josephbak
force-pushed
the
josephbak/decompose-xlogy
branch
from
July 21, 2026 02:44
0fc20a2 to
84503cc
Compare
Contributor
Author
|
Friendly ping — this has been green for several days (checks passing, no conflicts). @zjgarvey @sahas3 — would either of you have a moment to review, or point me to whoever's handling torch decompositions these days? This builds on #4204 and unblocks its KlDivLoss torchdynamo tests. Happy to address changes. Thanks! |
sahas3
reviewed
Jul 29, 2026
aten.xlogy.Tensor had no lowering in torch-mlir. Rather than add a C++ decomposition, register aten.xlogy in DEFAULT_DECOMPOSITIONS so the fx importer applies PyTorch's existing decomposition, which lowers to log/mul/eq/isnan/where. This avoids reimplementing and maintaining the same logic in torch-mlir. Adds e2e tests (basic, int-to-float promotion, zero/NaN conventions, and a broadcast case), passing on fx_importer, fx_importer_stablehlo, and fx_importer_tosa. The broadcast and zero/NaN tests are xfailed on onnx, where the lowering produces incorrect results for inputs whose result contains NaN. Assisted-by: Claude (Anthropic)
josephbak
force-pushed
the
josephbak/decompose-xlogy
branch
from
August 6, 2026 15:47
84503cc to
bf20deb
Compare
Contributor
Author
|
@sahas3 the nightly run failed at "Setup workspace and python" with a transient "Service Unavailable" fetching an action, before any build or test ran (stable was auto-cancelled). Looks like CI infra, not the change. Could you re-run when you get a chance? Thanks! |
Contributor
Author
|
Thanks for the review and guidance on the approach, @sahas3! |
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.
aten.xlogy.Tensorhad no lowering on any backend. It also blocked the torchdynamo config of the KlDivLoss e2e tests, since PyTorch'skl_divdecomposition emitsxlogy(see #4204, which addedkl_divand recorded the gap).This decomposes
xlogyintolog,mul,eq.Scalar,isnanandwhere, so all backend configs are handled at once. Shape and dtype functions are added as well; integer inputs promote tofloat32sincelogforces a float.This builds on the abandoned #2486 with its review feedback applied. I also fixed the type derivation, which was wrong under broadcasting:
eq.Scalar,logandisnanare shape-preserving, so their result types have to come from their operands, not the broadcast result. This is the same issue that #4509 fixed forlogaddexp. A[3,1] x [1,5]e2e test covers it.The broadcast test uses static shapes because TorchToLinalg's elementwise lowering only emits broadcast maps when size-1 dims are statically known; with dynamic sizes it emits equality assertions instead. This is pre-existing and general (
add.Tensor/mul.Tensorbehave the same way).Testing
linalg,fx_importer,fx_importer_stablehlo, andfx_importer_tosa(built StableHLO locally to verify that config).onnxconfig: PyTorch's ONNX exporter doesn't supportaten::xlogy(UnsupportedOperatorError).TORCHDYNAMO_CRASHING_SET; they were skipped entirely before and now run and pass under--config=torchdynamo.