[Mlir-commits] [mlir] [mlir] Add helper to check elementwise-mappable ops with tensors and scalars (PR #154872)
Adam Siemieniuk
llvmlistbot at llvm.org
Mon Aug 25 03:12:20 PDT 2025
================
@@ -20,13 +20,37 @@ namespace mlir {
using namespace mlir;
+// Treats primitive scalars and 0-D tensors as "scalar-like" for broadcasting.
+static inline bool isScalarLike(Type t) {
+ if (llvm::isa<IntegerType, FloatType, IndexType, ComplexType>(t))
+ return true;
+ if (auto rt = dyn_cast<RankedTensorType>(t))
+ return rt.getRank() == 0; // 0-D tensors are scalar-like
----------------
adam-smnk wrote:
AFAIK, the trait doesn't support that so, not sure if this case is really needed.
https://github.com/llvm/llvm-project/pull/154872
More information about the Mlir-commits
mailing list