[Mlir-commits] [mlir] [mlir][tosa] Add constant block scaled support (PR #205506)

Sayan Saha llvmlistbot at llvm.org
Tue Jul 7 18:08:36 PDT 2026


================
@@ -771,6 +825,43 @@ LogicalResult OpTrait::tosa::verifyBlockScaledTensorType(Operation &op,
   return success();
 }
 
+LogicalResult OpTrait::tosa::verifyBlockScaledTensorType(Operation &op,
+                                                         mlir::Type type) {
+  return ::verifyBlockScaledTensorType(op, type, /*allowScaleValues=*/false);
+}
+
+size_t mlir::tosa::BlockScaledType::getDenseElementBitSize() const {
+  const Type valueType = getValueType();
+  if (isa<tosa::mxint8Type>(valueType))
+    return 8;
+  return valueType.getIntOrFloatBitWidth();
+}
+
+Attribute
+mlir::tosa::BlockScaledType::convertToAttribute(ArrayRef<char> rawData) const {
+  assert(rawData.size() == 1 && "expected 1 byte for block_scaled element");
----------------
sahas3 wrote:

is this because 8 bit data is 1 byte? a comment will help readability

https://github.com/llvm/llvm-project/pull/205506


More information about the Mlir-commits mailing list