-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][tosa] Use explicit namespace for OpTrait. #126286
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
Conversation
@llvm/pr-subscribers-mlir-tosa @llvm/pr-subscribers-mlir Author: Scott Todd (ScottTodd) ChangesI'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:
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 Full diff: https://github.com/llvm/llvm-project/pull/126286.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Tosa/Utils/ConversionUtils.h b/mlir/include/mlir/Dialect/Tosa/Utils/ConversionUtils.h
index 88c21629286525d..4e2f1b9cb19a91b 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...));
|
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.
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.
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:
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 symbolmlir::torch::Torch::OpTrait
. So while a better fix would be to the downstream project, being explicit here doesn't seem that unreasonable to me.