llvm / llvm/torch-mlir

TorchToTMTensor CumSum Lowering Only Supports Constant Axis

Open
#2,845 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.9k
Forks
736
Avg merge
5d 22h
Merged PRs (30d)
15

Description

Here,

https://github.com/llvm/torch-mlir/blob/34f6948533287e67801384cb00f7150edc1461a5/lib/Conversion/TorchToTMTensor/TorchToTMTensor.cpp#L1532

the TorchToTMTensor lowering checks to make sure that dim is a TorchConstantInt.

However, ONNX forces the axis to be variable because it allows axis to be a tensor.

This causes (at least part of) the lowering failure described in https://github.com/nod-ai/iree-amd-aie/issues/103

opt-125M.fp32.onnx.mlir:231:12: error: failed to legalize operation 'torch.aten.cumsum' that was explicitly marked illegal
    %228 = torch.operator "onnx.CumSum"(%226, %227) : (!torch.vtensor<[1,6],si64>, !torch.vtensor<[],si32>) -> !torch.vtensor<[1,6],si64>
           ^
opt-125M.fp32.onnx.mlir:231:12: note: see current operation: %287 = "torch.aten.cumsum"(%18, %286, %16) : (!torch.vtensor<[1,6],si64>, !torch.int, !torch.int) -> !torch.vtensor<[1,6],si64> loc("opt-125M.fp32.onnx.mlir":231:12)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/Conversion/TorchToTMTensor/TorchToTMTensor.cpp around line 1532 and inspect the TorchToTMTensor lowering for torch.aten.cumsum. Compare its constant-axis check with the ONNX-generated operation and the opt-125M.fp32.onnx.mlir diagnostic. Done means the lowering accepts the variable axis form described here and no longer fails to legalize that cumsum operation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, pytorch
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.