-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TorchToStablehlo lit test failure with scatter.mlir #1962
Comments
Hi @sjain-stanford #1869 allows the block arguments of reduce op to have different element types than that of the input arguments of reduce op and the output type of the reduce op has to equal to those block arguments. As a consequence the output type of reduce op can no longer be inferred from the operand types: The type inference needs to somehow have the information regarding the block-arguments's element type. The check that was added at #1918 is a guard against inferring reduce op type with empty blocks, which is what is happening at https://sourcegraph.com/github.com/llvm/torch-mlir/-/blob/lib/Conversion/TorchToStablehlo/GatherScatter.cpp?L336. We encountered a similar problem with creating mhlo reduce op with empty reduction block and the solution we proposed was to create a custom builder here and here. In StableHLO we do not have such builder as we do not see a use-case for that until now with the issue you posted. IMO the solution will be along the similar lines and I will be working on that. I will keep you posted on updates. |
Thanks @sdasgup3 for looking into this. PLMK if/when you have a patch-set you'd like me to test on the |
Please find the patch at #1965. On the torch-mlir side, we need the following patch to make sure that the newly supported builder is invoked.
Please let us know if this works at your end. |
@sdasgup3 Thanks for the quick fix. Confirming the test passes locally with your patches 👍🏻 (cherry-picked the stablehlo changes from your fork but will re-apply once it lands on |
@sjain-stanford Please let us know if the merged #1965 worked at your end. |
@sdasgup3 any idea how this piece of code needs to be refactored? DenseIntElementsAttr bcast_attr = DenseIntElementsAttr::get(
RankedTensorType::get({static_cast<long int>(bcastDims.size())},
rewriter.getI64Type()),
bcastDims);
auto bcast_op = rewriter.create<stablehlo::BroadcastInDimOp>(
op->getLoc(), outType, input, bcast_attr); After bumping to stablehlo@HEAD, I hit some new build errors like so:
|
@sjain-stanford
|
|
The CMake build now fails with setup_sanitizers. Probably related to #1959 (cc: @fzakaria , @mlevesquedion ). I see the default for
Error:
|
I'll take a look. |
This fixes it: #1972 |
Fixes #1962 (comment) Context: This breaks torch-mlir's CMake build when bumping stablehlo. The CMake build [fails](https://github.com/llvm/torch-mlir/actions/runs/7729517677/job/21072878412?pr=2821) with setup_sanitizers. Probably related to #1959 (cc: @fzakaria , @mlevesquedion ). I see the default for `STABLEHLO_ENABLE_SANITIZER` being `OFF`, but this code probably needs to be enclosed in an `if-endif`: ``` include(SetupSanitizers) setup_sanitizers() ``` Error: ``` -- Building StableHLO as an external LLVM project -- Building with -fPIC CMake Error at /_work/torch-mlir/torch-mlir/externals/stablehlo/CMakeLists.txt:147 (include): include could not find requested file: SetupSanitizers CMake Error at /_work/torch-mlir/torch-mlir/externals/stablehlo/CMakeLists.txt:148 (setup_sanitizers): Unknown CMake command "setup_sanitizers". -- Configuring incomplete, errors occurred! ```
What happened?
Hi stablehlo, we need some help on the
torch-mlir
side of things with a lit test error we hit when bumping stablehlo that hits anunexpected error: Expects non-empty reduction block for type inference
PR: llvm/torch-mlir#2821
Failing CI: https://github.com/llvm/torch-mlir/actions/runs/7687361450/job/20947291128?pr=2821
Here's the error:
Seems like this check was added in #1918 but I lack the historic context to know what needs fixing.
Steps to reproduce your issue
sambhav/bazel_fix
branchgit submodule update --init --progress
./utils/bazel/docker/run_docker.sh
bazel run @torch-mlir//test/Conversion:TorchToStablehlo/scatter.mlir.test
Version information
No response
The text was updated successfully, but these errors were encountered: