[Mlir-commits] [mlir] [mlir][spirv][tosa] Add remaining TOSA 1.0 SPIR-V TOSA ops (PR #200383)
Igor Wodiany
llvmlistbot at llvm.org
Fri May 29 05:52:06 PDT 2026
================
@@ -39,6 +58,80 @@ DenseIntElementsAttr getI32TensorArmAttr(ArrayRef<int32_t> values,
values);
}
+DenseIntElementsAttr getI32TensorArmAttr(ArrayRef<int64_t> values,
+ ConversionPatternRewriter &rewriter) {
+ SmallVector<int32_t> i32Values;
+ i32Values.reserve(values.size());
+ for (int64_t value : values)
+ i32Values.push_back(value);
+ return getI32TensorArmAttr(i32Values, rewriter);
+}
+
+FailureOr<DenseElementsAttr>
+convertDenseElementsAttr(DenseElementsAttr values, ShapedType convertedType) {
+ Type convertedElementType = convertedType.getElementType();
+ if (values.getElementType() == convertedElementType)
+ return values.reshape(convertedType);
+
+ // Constant attributes still have the source TOSA element type. Rebuild them
+ // for the converted SPIR-V tensor type, including integer type-converter
+ // changes such as index to i32, i4 to i8, and i48 to i64.
+ auto integerType = dyn_cast<IntegerType>(convertedElementType);
+ if (!integerType)
+ return failure();
+
+ // The SPIR-V ARM tensor type does not represent scalar shape constants
+ // directly, so model tensor<0xindex> as a one-element i32 tensor.
+ if (values.empty() && values.getElementType().isIndex())
+ return DenseIntElementsAttr::get(convertedType, {1});
+
+ DenseElementsAttr convertedValues =
+ values.mapValues(integerType, [&](const APInt &value) {
+ return value.sextOrTrunc(integerType.getWidth());
+ });
+ return convertedValues.reshape(convertedType);
+}
+
+LogicalResult splitConcat(tosa::ConcatOp op, Type resultType, int32_t axis,
----------------
IgWod wrote:
I think some description of what the function does would be helpful
https://github.com/llvm/llvm-project/pull/200383
More information about the Mlir-commits
mailing list