Skip to content
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

Bump llvm to llvm/llvm-project@c06d0ff806b7 #19903

Merged
merged 11 commits into from
Feb 6, 2025

Conversation

hanhanW
Copy link
Contributor

@hanhanW hanhanW commented Feb 4, 2025

Add local fixes to torch-mlir because of llvm/llvm-project@956c070

Local revert commits:

Additional changes:

  • Switch DumpExecutableBenchmarks to use eliminateCommonSubExpressions.
  • Remove cleanups (dynamic pass manager) from IREEBufferizeOp::apply

Because the dynamic pass pipeline triggers the below error. The dialects either need to be loaded or we need to initialize the objects before running the pass. The transform op is not a pass, which makes it much tricker. We follow what upstream does, which separate the cleanups, i.e., users need to clean the IR themselves. Upstream example: https://github.com/llvm/llvm-project/blob/cf9806eb4da23b42702aa88784969520702dae00/mlir/test/Integration/Dialect/Linalg/CPU/unpack-dynamic-inner-tile.mlir#L96-L104

Assertion failed: (impl->multiThreadedExecutionContext == 0 && "appending to the MLIRContext dialect registry while in a " "multi-threaded execution context"), function ap
pendDialectRegistry, file MLIRContext.cpp, line 403.
Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: build/tools/iree-opt --iree-transform-dialect-interpreter --transform-dialect-drop-schedule compiler/src/iree/compiler/Codegen/LLVMCPU/test/tran
sform_dialect_bufferize.mlir --mlir-disable-threading

Signed-off-by: hanhanW <hanhan0912@gmail.com>
Signed-off-by: hanhanW <hanhan0912@gmail.com>
Signed-off-by: hanhanW <hanhan0912@gmail.com>
@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

Here is the dump from the new CUDA smoketest: https://gist.github.com/hanhanW/b5399262d73b05d119fa2a5550bba00e

It looks like .entry add_dispatch becomes .visible .func add_dispatch. The .maxntid 32, 1, 1 disappears. @MaheshRavishankar @benvanik @kuhar What is the best fix for the test? It is the only failure.

// PTX: .entry add_dispatch
// PTX: .maxntid 32, 1, 1
// PTX: add.rn.f32
// PTX: .entry mul_dispatch
// PTX: .maxntid 32, 1, 1
// PTX: mul.rn.f32

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

This is the PTX from the current main branch: https://gist.github.com/hanhanW/baa52eb162b7370a1dcf9bb943b71739

Confirmed that entry becomes function, and only maxntid disappears. The mlir dumps are the same, and the generated data from SerializeTargetExecutablesPass is different.

Signed-off-by: hanhanW <hanhan0912@gmail.com>
@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

Okay, I think llvm/llvm-project@de7438e is the root cause. Let's revert it local for now, and we can revisit later.

This reverts commit e9349b1.

Signed-off-by: hanhanW <hanhan0912@gmail.com>
Signed-off-by: hanhanW <hanhan0912@gmail.com>
@MaheshRavishankar
Copy link
Contributor

Good catch! Report it to the original author?

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

Hitting the below failure, I'm still figuring why

Assertion failed: (impl->multiThreadedExecutionContext == 0 && "appending to the MLIRContext dialect registry while in a " "multi-threaded execution context"), function ap
pendDialectRegistry, file MLIRContext.cpp, line 403.
Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.
Stack dump:
0.      Program arguments: build/tools/iree-opt --iree-transform-dialect-interpreter --transform-dialect-drop-schedule compiler/src/iree/compiler/Codegen/LLVMCPU/test/tran
sform_dialect_bufferize.mlir --mlir-disable-threading

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

It seems to be dynamic pipeline issue, I need to learn more about it.

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

I'm not looking at this now, will get back to it later

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

yeah, I think the issue happens in dynamic pipeline.. I dont see the issue for a failure if I disable the canonicalization and cse in the pass. I'm looking at how to do it properly now. (I can't find suspicious commit in upstream.)

// Run CSE and the canonicalizer to pretty up the output.
PassManager passManager(moduleOp->getContext());
passManager.addPass(mlir::createCanonicalizerPass());
passManager.addPass(mlir::createCSEPass());
if (failed(passManager.run(*moduleOp))) {
moduleOp->emitError("failed to run canonicalizer; malformed output");
return {};
}

@benvanik
Copy link
Collaborator

benvanik commented Feb 5, 2025

oo yeah, that looks wrong (running the pass manager inline like that) - given that it's canonicalization + CSE we could avoid using passes (applyPatternsAndFoldGreedily + eliminateCommonSubExpressions)

back when I wrote that eliminateCommonSubExpressions didn't exist - nice that it does now!

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

oo yeah, that looks wrong (running the pass manager inline like that) - given that it's canonicalization + CSE we could avoid using passes (applyPatternsAndFoldGreedily + eliminateCommonSubExpressions)

back when I wrote that eliminateCommonSubExpressions didn't exist - nice that it does now!

The transform interpreter one is also tricky, I'll take a look after this.

@benvanik
Copy link
Collaborator

benvanik commented Feb 5, 2025

oh yeah, no clue about transform dialect >_>

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

eliminateCommonSubExpressions works! I think we do not need applyPatternsAndFoldGreedily because it is not a pattern-based pass. Looking at other failures now!

Signed-off-by: hanhanW <hanhan0912@gmail.com>
@hanhanW hanhanW requested a review from benvanik as a code owner February 5, 2025 16:23
@benvanik
Copy link
Collaborator

benvanik commented Feb 5, 2025

the apply patterns would be the replacement for canonicalization:

 RewritePatternSet patterns(context);

    for (auto *dialect : context->getLoadedDialects()) {
      dialect->getCanonicalizationPatterns(patterns);
    }
    for (auto op : context->getRegisteredOperations()) {
      op.getCanonicalizationPatterns(patterns, context);
    }
    IREE::Util::populateCommonPatterns(context, patterns);

    FrozenRewritePatternSet frozenPatterns(std::move(patterns));
    if (failed(applyPatternsGreedily(getOperation(), frozenPatterns))) {
      getOperation()->emitError()
          << "failed to apply patterns, likely due to a bad pattern that "
             "causes an infinite fixed point iteration";
      return signalPassFailure();
    }

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

It only fails in IREEBufferizeOp op, looking >__>

DiagnosedSilenceableFailure transform_dialect::IREEBufferizeOp::apply(
transform::TransformRewriter &rewriter,
transform::TransformResults &results, transform::TransformState &state) {
auto payload = state.getPayloadOps(getTarget());
// Bufferize the dispatch.
using mlir::bufferization::BufferizationOptions;
BufferizationOptions::AllocationFn allocationFn =
cpuComprehensiveBufferizeAllocationFn;
BufferizationOptions::MemCpyFn memCpyFn = cpuComprehensiveBufferizeCopyFn;
if (getTargetGpu()) {
allocationFn = gpuComprehensiveBufferizeAllocationFn;
memCpyFn = gpuComprehensiveBufferizeCopyFn;
}
Operation *target = *payload.begin();
ErrorCheckingTrackingListener listener(state, *this);
// 1. Rewrite tensor.empty to tensor.alloc, without the pass baggage.
{
RewritePatternSet patterns(getContext());
patterns.add<EmptyTensorLoweringPattern>(patterns.getContext());
GreedyRewriteConfig config;
config.listener = &listener;
// Manually gather list of ops because the other GreedyPatternRewriteDriver
// overloads only accepts ops that are isolated from above.
LogicalResult result =
applyOpPatternsGreedily(target, std::move(patterns), config);
if (failed(result)) {
return mlir::emitDefiniteFailure(target,
"greedy pattern application failed");
}
if (listener.failed())
return listener.checkAndResetError();
}
// 2. Run one-shot-bufferize, without the pass baggage.
IREEOneShotBufferizationOptions options = getBufferizationOptions();
options.allocationFn = allocationFn;
options.memCpyFn = memCpyFn;
options.testAnalysisOnly = getTestAnalysisOnly();
options.printConflicts = getPrintConflicts();
if (getTargetGpu()) {
options.defaultMemorySpaceFn =
[&](TensorType t) -> std::optional<Attribute> {
Attribute addressSpaceAttr = gpu::AddressSpaceAttr::get(
t.getContext(), gpu::GPUDialect::getWorkgroupAddressSpace());
return addressSpaceAttr;
};
}
if (failed(runIREEOneShotBufferize(target, options))) {
return mlir::emitDefiniteFailure(target, "bufferization failed");
}
// Early exit if test_analysis_only is set.
if (getTestAnalysisOnly()) {
results.set(getOperation()->getOpResult(0), {*payload.begin()});
return listener.checkAndResetError();
}
// 3. Post-bufferization passes are fine.
PassManager pm(getContext());
addIREEPostBufferizationPasses(pm);
if (failed(pm.run(target))) {
return mlir::emitDefiniteFailure(target)
<< "post-bufferization passes failed";
}
results.set(getOperation()->getOpResult(0), {target});
return listener.checkAndResetError();
}

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

I think it is dynamic pipeline issue again.. It does not crash if I comment out it, looking.

   //   3. Post-bufferization passes are fine. 
   PassManager pm(getContext()); 
   addIREEPostBufferizationPasses(pm); 
   if (failed(pm.run(target))) { 
     return mlir::emitDefiniteFailure(target) 
            << "post-bufferization passes failed"; 
   } 

@benvanik
Copy link
Collaborator

benvanik commented Feb 5, 2025

oh yeah that's tricky - the benchmarks pass was running nested because it was producing a module to output to a file (the newly produced module never exists in the main module IR so there's no way to setup dynamic passes for it) - addIREEPostBufferizationPasses is added in several places in normal pipelines, though, so maybe it's not needed there

Signed-off-by: hanhanW <hanhan0912@gmail.com>
@hanhanW hanhanW requested a review from pashu123 as a code owner February 5, 2025 16:43
@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

That part is just adding some cleanup passes. I think we should follow what upstream does, drop the dynamic passes, and users should run canonicalization themselves. The transform dialect tests are not default, so I'd just drop the cleanup support from the op. Just tested, it works.

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

oh no, there are numerical issues in Sharktank.. I thought that my fix is very reasonable... It follows what the upstream does: llvm/llvm-project@956c070 :/

iree-org/torch-mlir@eefc553...f8eaf8d

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

Let's try if llvm/torch-mlir#4001 helps or not

Signed-off-by: hanhanW <hanhan0912@gmail.com>
@ScottTodd
Copy link
Member

oh no, there are numerical issues in Sharktank.. I thought that my fix is very reasonable... It follows what the upstream does: llvm/llvm-project@956c070 :/

iree-org/torch-mlir@eefc553...f8eaf8d

I'm pretty sure TOSA changes shouldn't affect sharktank. The sharktank models go through a PyTorch -> Torch MLIR -> Linalg path. We only use TOSA for TFLite/LiteRT -> TOSA -> Linalg.

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

oh no, there are numerical issues in Sharktank.. I thought that my fix is very reasonable... It follows what the upstream does: llvm/llvm-project@956c070 :/
iree-org/torch-mlir@eefc553...f8eaf8d

I'm pretty sure TOSA changes shouldn't affect sharktank. The sharktank models go through a PyTorch -> Torch MLIR -> Linalg path. We only use TOSA for TFLite/LiteRT -> TOSA -> Linalg.

Then it looks like an upstream issue... The changes that I made in IREE do not impact any lowering, unless they use transform dialect. Even though, it should not impact numerics.. I'll take a look later

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

@ScottTodd is there a quick way to get the MLIR file and input data? Otherwise, I think I need to follow https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models/llama3.1 to reproduce the issue.

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

Inlining the error, it produces NAN:

  comparison failed
  Obtained: nan
  Expected: 0.589 ± 5.9e-03

@ScottTodd
Copy link
Member

@ScottTodd is there a quick way to get the MLIR file and input data? Otherwise, I think I need to follow https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models/llama3.1 to reproduce the issue.

MLIR file yes, download from https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models/llama3.1/assets.

Input data and run commands... not as easy as you might like. Instructions are at https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models. You'd need to build the IREE Python bindings and run pytest.

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 5, 2025

@ScottTodd is there a quick way to get the MLIR file and input data? Otherwise, I think I need to follow https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models/llama3.1 to reproduce the issue.

MLIR file yes, download from https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models/llama3.1/assets.

Input data and run commands... not as easy as you might like. Instructions are at https://github.com/iree-org/iree-test-suites/tree/main/sharktank_models. You'd need to build the IREE Python bindings and run pytest.

Thanks for the pointers, I'll give it a shot!

@hanhanW
Copy link
Contributor Author

hanhanW commented Feb 6, 2025

Confirm that the root cause of numerics is llvm/llvm-project@3a33775. I haven't got a small repro yet.

cc @ita9naiwa

Signed-off-by: hanhanW <hanhan0912@gmail.com>
Signed-off-by: hanhanW <hanhan0912@gmail.com>
@ita9naiwa ita9naiwa requested review from ita9naiwa and removed request for ita9naiwa February 6, 2025 07:21
Copy link
Contributor

@pashu123 pashu123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hanhanW hanhanW merged commit 86b845b into iree-org:main Feb 6, 2025
43 checks passed
@hanhanW hanhanW deleted the integrate-llvm-20250205 branch February 6, 2025 09:43
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something in here broke the MSVC/Windows build: https://github.com/iree-org/iree/actions/runs/13196900742/job/36840094404#step:9:7647

FAILED: compiler/plugins/input/Torch/torch-mlir/CMakeFiles/iree_compiler_plugins_input_Torch_torch-mlir_ConversionPasses.objects.dir/__/__/__/__/__/third_party/torch-mlir/lib/Conversion/TorchToTosa/TosaLegalizeCommon.cpp.obj 
C:\ProgramData\chocolatey\bin\ccache "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.42.34433\bin\Hostx64\x64\cl.exe"  /nologo /TP  -IC:\home\runner\_work\iree\iree -IC:\mnt\azure\b\092805 -IC:\home\runner\_work\iree\iree\third_party\torch-mlir\include -IC:\home\runner\_work\iree\iree\compiler\plugins\input\Torch -IC:\mnt\azure\b\092805\compiler\plugins\input\Torch -IC:\home\runner\_work\iree\iree\third_party\llvm-project\llvm\include -IC:\mnt\azure\b\092805\llvm-project\include -IC:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include -IC:\mnt\azure\b\092805\llvm-project\tools\mlir\include -IC:\home\runner\_work\iree\iree\third_party\llvm-project\lld\include -IC:\mnt\azure\b\092805\llvm-project\tools\lld\include /DWIN32 /D_WINDOWS /EHsc /Z7 /O2 /Ob1  -std:c++17 -MD /wd4996 /Zc:preprocessor /DWIN32_LEAN_AND_MEAN /DNOMINMAX /D_USE_MATH_DEFINES /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES /D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING /GR- /bigobj /W3 /wd4200 /wd4018 /wd4146 /wd4244 /wd4267 /wd4005 /wd4065 /wd4141 /wd4624 /wd4576 /wd5105 /showIncludes /Focompiler\plugins\input\Torch\torch-mlir\CMakeFiles\iree_compiler_plugins_input_Torch_torch-mlir_ConversionPasses.objects.dir\__\__\__\__\__\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp.obj /Fdcompiler\plugins\input\Torch\torch-mlir\CMakeFiles\iree_compiler_plugins_input_Torch_torch-mlir_ConversionPasses.objects.dir\ /FS -c C:\home\runner\_work\iree\iree\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): error C2872: 'OpTrait': ambiguous symbol
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/IR/TosaOps.h(49): note: could be 'mlir::OpTrait'
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Dialect/Torch/IR/TorchTraits.h(23): note: or       'mlir::torch::Torch::OpTrait'
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): note: the template instantiation context (the oldest one first) is
C:\home\runner\_work\iree\iree\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp(126): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<mlir::tosa::MulOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::PatternRewriter &,mlir::Location,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(83): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(76): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInferShape<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]

I saw some recent changes to https://github.com/llvm/torch-mlir/blame/main/lib/Conversion/TorchToTosa/TosaLegalizeCommon.cpp and https://github.com/llvm/llvm-project/tree/main/mlir/include/mlir/Dialect/Tosa/Utils but I'm not sure what specifically

I'm also not sure why we build TorchToTosa at all in IREE, since we don't use it...?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch fixes for me locally... still not sure what triggered that failure though

D:\dev\projects\iree\third_party\llvm-project (HEAD detached at a1984ec)
λ git diff
diff --git a/mlir/include/mlir/Dialect/Tosa/Utils/ConversionUtils.h b/mlir/include/mlir/Dialect/Tosa/Utils/ConversionUtils.h
index 78a882885543..baee63308ee2 100644
--- a/mlir/include/mlir/Dialect/Tosa/Utils/ConversionUtils.h
+++ b/mlir/include/mlir/Dialect/Tosa/Utils/ConversionUtils.h
@@ -145,7 +145,7 @@ TosaOp createOpAndInferShape(ImplicitLocOpBuilder &builder, Type resultTy,
 template <typename TosaOp, typename... Args>
 TosaOp CreateOpAndInferShape(ImplicitLocOpBuilder &builder, Type resultTy,
                              Args &&...args) {
-  if (TosaOp::template hasTrait<OpTrait::SameOperandsAndResultRank>()) {
+  if (TosaOp::template hasTrait<::mlir::OpTrait::SameOperandsAndResultRank>()) {
     // op requires same ranks for tensor operands
     if constexpr (sizeof...(Args) == 2) {
       auto argX = std::get<0>(std::tie(args...));

The namespace code in torch-mlir is sketchy: https://github.com/llvm/torch-mlir/blob/52299e6a659e68879b2c656ffd82ae2a9d28afd8/include/torch-mlir/Dialect/Torch/IR/TorchTraits.h#L20-L23

namespace mlir {
namespace torch {
namespace Torch {
namespace OpTrait {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not sure why we build TorchToTosa at all in IREE, since we don't use it...?

Ah, TOSA is a non-optional dep of torch-mlir. We could carve it out with a TORCH_MLIR_ENABLE_TOSA like there already is for TORCH_MLIR_ENABLE_STABLEHLO 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent my fix/workaround upstream: llvm/llvm-project#126286

ScottTodd added a commit to llvm/llvm-project that referenced this pull request Feb 7, 2025
I'm seeing build errors in a downstream project using torch-mlir that
are fixed by this change. See
iree-org/iree#19903 (comment) for
more context. The build error on MSVC is:
```
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): error C2872: 'OpTrait': ambiguous symbol
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/IR/TosaOps.h(49): note: could be 'mlir::OpTrait'
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Dialect/Torch/IR/TorchTraits.h(23): note: or       'mlir::torch::Torch::OpTrait'
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): note: the template instantiation context (the oldest one first) is
C:\home\runner\_work\iree\iree\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp(126): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<mlir::tosa::MulOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::PatternRewriter &,mlir::Location,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(83): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(76): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInferShape<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
```

I think the torch-mlir code here is causing the issue, but I'm not sure
why builds only started failing now:
https://github.com/llvm/torch-mlir/blob/main/include/torch-mlir/Dialect/Torch/IR/TorchTraits.h.
Given that `mlir::OpTrait` already exists, torch-mlir should not be
creating an ambiguous symbol `mlir::torch::Torch::OpTrait`. So while a
better fix would be to the downstream project, being explicit here
doesn't seem that unreasonable to me.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 7, 2025
I'm seeing build errors in a downstream project using torch-mlir that
are fixed by this change. See
iree-org/iree#19903 (comment) for
more context. The build error on MSVC is:
```
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): error C2872: 'OpTrait': ambiguous symbol
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/IR/TosaOps.h(49): note: could be 'mlir::OpTrait'
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Dialect/Torch/IR/TorchTraits.h(23): note: or       'mlir::torch::Torch::OpTrait'
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): note: the template instantiation context (the oldest one first) is
C:\home\runner\_work\iree\iree\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp(126): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<mlir::tosa::MulOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::PatternRewriter &,mlir::Location,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(83): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(76): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInferShape<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
```

I think the torch-mlir code here is causing the issue, but I'm not sure
why builds only started failing now:
https://github.com/llvm/torch-mlir/blob/main/include/torch-mlir/Dialect/Torch/IR/TorchTraits.h.
Given that `mlir::OpTrait` already exists, torch-mlir should not be
creating an ambiguous symbol `mlir::torch::Torch::OpTrait`. So while a
better fix would be to the downstream project, being explicit here
doesn't seem that unreasonable to me.
bjacob pushed a commit to iree-org/llvm-project that referenced this pull request Feb 8, 2025
I'm seeing build errors in a downstream project using torch-mlir that
are fixed by this change. See
iree-org/iree#19903 (comment) for
more context. The build error on MSVC is:
```
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): error C2872: 'OpTrait': ambiguous symbol
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/IR/TosaOps.h(49): note: could be 'mlir::OpTrait'
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Dialect/Torch/IR/TorchTraits.h(23): note: or       'mlir::torch::Torch::OpTrait'
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): note: the template instantiation context (the oldest one first) is
C:\home\runner\_work\iree\iree\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp(126): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<mlir::tosa::MulOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::PatternRewriter &,mlir::Location,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(83): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(76): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInferShape<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
```

I think the torch-mlir code here is causing the issue, but I'm not sure
why builds only started failing now:
https://github.com/llvm/torch-mlir/blob/main/include/torch-mlir/Dialect/Torch/IR/TorchTraits.h.
Given that `mlir::OpTrait` already exists, torch-mlir should not be
creating an ambiguous symbol `mlir::torch::Torch::OpTrait`. So while a
better fix would be to the downstream project, being explicit here
doesn't seem that unreasonable to me.
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
I'm seeing build errors in a downstream project using torch-mlir that
are fixed by this change. See
iree-org/iree#19903 (comment) for
more context. The build error on MSVC is:
```
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): error C2872: 'OpTrait': ambiguous symbol
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/IR/TosaOps.h(49): note: could be 'mlir::OpTrait'
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Dialect/Torch/IR/TorchTraits.h(23): note: or       'mlir::torch::Torch::OpTrait'
C:\home\runner\_work\iree\iree\third_party\llvm-project\mlir\include\mlir/Dialect/Tosa/Utils/ConversionUtils.h(148): note: the template instantiation context (the oldest one first) is
C:\home\runner\_work\iree\iree\third_party\torch-mlir\lib\Conversion\TorchToTosa\TosaLegalizeCommon.cpp(126): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<mlir::tosa::MulOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::PatternRewriter &,mlir::Location,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(83): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInfer<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
C:\home\runner\_work\iree\iree\third_party\torch-mlir\include\torch-mlir/Conversion/TorchToTosa/TosaLegalizeUtils.h(76): note: see reference to function template instantiation 'TosaOp mlir::tosa::CreateOpAndInferShape<TosaOp,mlir::Value&,mlir::Value&,mlir::Value&>(mlir::ImplicitLocOpBuilder &,mlir::Type,mlir::Value &,mlir::Value &,mlir::Value &)' being compiled
        with
        [
            TosaOp=mlir::tosa::MulOp
        ]
```

I think the torch-mlir code here is causing the issue, but I'm not sure
why builds only started failing now:
https://github.com/llvm/torch-mlir/blob/main/include/torch-mlir/Dialect/Torch/IR/TorchTraits.h.
Given that `mlir::OpTrait` already exists, torch-mlir should not be
creating an ambiguous symbol `mlir::torch::Torch::OpTrait`. So while a
better fix would be to the downstream project, being explicit here
doesn't seem that unreasonable to me.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants