Adding bf16 and i4 support plumbing in a few places. (#7680)
They'll print/parse as binary via the HAL string utils. Still some dragons hiding in the compiler but this is the cross-cutting stuff that spiders outside of the compiler proper.
diff --git a/bindings/python/iree/runtime/hal.cc b/bindings/python/iree/runtime/hal.cc
index 52d2aa4..e3d1dfb 100644
--- a/bindings/python/iree/runtime/hal.cc
+++ b/bindings/python/iree/runtime/hal.cc
@@ -84,10 +84,17 @@
.value("OPAQUE_16", IREE_HAL_ELEMENT_TYPE_OPAQUE_16)
.value("OPAQUE_32", IREE_HAL_ELEMENT_TYPE_OPAQUE_32)
.value("OPAQUE_64", IREE_HAL_ELEMENT_TYPE_OPAQUE_64)
+ .value("INT_4", IREE_HAL_ELEMENT_TYPE_INT_4)
+ .value("INT_8", IREE_HAL_ELEMENT_TYPE_INT_8)
+ .value("INT_16", IREE_HAL_ELEMENT_TYPE_INT_16)
+ .value("INT_32", IREE_HAL_ELEMENT_TYPE_INT_32)
+ .value("INT_64", IREE_HAL_ELEMENT_TYPE_INT_64)
+ .value("SINT_4", IREE_HAL_ELEMENT_TYPE_SINT_4)
.value("SINT_8", IREE_HAL_ELEMENT_TYPE_SINT_8)
.value("SINT_16", IREE_HAL_ELEMENT_TYPE_SINT_16)
.value("SINT_32", IREE_HAL_ELEMENT_TYPE_SINT_32)
.value("SINT_64", IREE_HAL_ELEMENT_TYPE_SINT_64)
+ .value("UINT_4", IREE_HAL_ELEMENT_TYPE_UINT_4)
.value("UINT_8", IREE_HAL_ELEMENT_TYPE_UINT_8)
.value("UINT_16", IREE_HAL_ELEMENT_TYPE_UINT_16)
.value("UINT_32", IREE_HAL_ELEMENT_TYPE_UINT_32)
@@ -95,6 +102,7 @@
.value("FLOAT_16", IREE_HAL_ELEMENT_TYPE_FLOAT_16)
.value("FLOAT_32", IREE_HAL_ELEMENT_TYPE_FLOAT_32)
.value("FLOAT_64", IREE_HAL_ELEMENT_TYPE_FLOAT_64)
+ .value("BFLOAT_16", IREE_HAL_ELEMENT_TYPE_BFLOAT_16)
.value("BOOL_8",
static_cast<iree_hal_element_types_t>(IREE_HAL_ELEMENT_TYPE_VALUE(
IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 1)))
diff --git a/bindings/python/iree/runtime/hal.h b/bindings/python/iree/runtime/hal.h
index 25a1ff3..634c741 100644
--- a/bindings/python/iree/runtime/hal.h
+++ b/bindings/python/iree/runtime/hal.h
@@ -149,7 +149,7 @@
"Error getting buffer view shape");
iree_hal_element_type_t element_type =
iree_hal_buffer_view_element_type(bv_);
- int32_t element_size = iree_hal_element_byte_count(element_type);
+ int32_t element_size = iree_hal_element_dense_byte_count(element_type);
std::vector<py::ssize_t> dims(shape.size());
for (int i = 0; i < shape.size(); ++i) {
dims[i] = shape[i];
diff --git a/bindings/python/iree/runtime/vm.cc b/bindings/python/iree/runtime/vm.cc
index a846d5e..60e5f9a 100644
--- a/bindings/python/iree/runtime/vm.cc
+++ b/bindings/python/iree/runtime/vm.cc
@@ -441,24 +441,28 @@
// TODO: Handle dtypes that do not map to a code (i.e. fp16).
const char* dtype_code;
switch (element_type) {
+ case IREE_HAL_ELEMENT_TYPE_INT_8:
case IREE_HAL_ELEMENT_TYPE_SINT_8:
dtype_code = "b";
break;
case IREE_HAL_ELEMENT_TYPE_UINT_8:
dtype_code = "B";
break;
+ case IREE_HAL_ELEMENT_TYPE_INT_16:
case IREE_HAL_ELEMENT_TYPE_SINT_16:
dtype_code = "h";
break;
case IREE_HAL_ELEMENT_TYPE_UINT_16:
dtype_code = "H";
break;
+ case IREE_HAL_ELEMENT_TYPE_INT_32:
case IREE_HAL_ELEMENT_TYPE_SINT_32:
dtype_code = "i";
break;
case IREE_HAL_ELEMENT_TYPE_UINT_32:
dtype_code = "I";
break;
+ case IREE_HAL_ELEMENT_TYPE_INT_64:
case IREE_HAL_ELEMENT_TYPE_SINT_64:
dtype_code = "l";
break;
@@ -471,7 +475,7 @@
case IREE_HAL_ELEMENT_TYPE_FLOAT_64:
dtype_code = "d";
break;
- case IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 1):
+ case IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER, 1):
// Due to layering issues it is not uncommon to get i1 buffer views
// and we just silently promote them to i8 since that is what they are.
// Really i1 should not exist at this boundary.
diff --git a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/tensor_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/tensor_ops.mlir
index 9dc0e47..30f4181 100644
--- a/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/tensor_ops.mlir
+++ b/iree/compiler/Dialect/HAL/Conversion/FlowToHAL/test/tensor_ops.mlir
@@ -12,7 +12,7 @@
// CHECK: %[[OFF:.+]] = hal.allocator.compute_offset<%allocator : !hal.allocator>
// CHECK-SAME: indices([%[[C0]], %[[C1]]])
// CHECK-SAME: shape([%[[C2]], %[[C3]]])
- // CHECK-SAME: type(%c16777248_i32)
+ // CHECK-SAME: type(%c268435488_i32)
// CHECK-NEXT: = hal.buffer.load<%[[BUFFER]] : !hal.buffer>[%[[OFF]]] : i32
%0 = flow.tensor.load %tensor[%i0, %i1] : tensor<2x3xi32>
return
@@ -26,7 +26,7 @@
// CHECK: %[[OFF:.+]] = hal.allocator.compute_offset<%allocator : !hal.allocator>
// CHECK-SAME: indices([])
// CHECK-SAME: shape([])
- // CHECK-SAME: type(%c16777217_i32)
+ // CHECK-SAME: type(%c268435457_i32)
// CHECK-NEXT: = hal.buffer.load<%[[BUFFER]] : !hal.buffer>[%[[OFF]]] : i1
%0 = flow.tensor.load %tensor : tensor<i1>
return
@@ -48,7 +48,7 @@
// CHECK: %[[OFF:.+]] = hal.allocator.compute_offset<%allocator : !hal.allocator>
// CHECK-SAME: indices([%[[C0]], %[[C1]]])
// CHECK-SAME: shape([%[[C2]], %[[C3]]])
- // CHECK-SAME: type(%c16777248_i32)
+ // CHECK-SAME: type(%c268435488_i32)
// CHECK-NEXT: hal.buffer.store<%[[BUFFER]] : !hal.buffer>[%[[OFF]]] value(%[[C9]] : i32)
flow.tensor.store %c9, %tensor[%i0, %i1] : tensor<2x3xi32>
return
@@ -64,7 +64,7 @@
// CHECK: %[[OFF:.+]] = hal.allocator.compute_offset<%allocator : !hal.allocator>
// CHECK-SAME: indices([])
// CHECK-SAME: shape([])
- // CHECK-SAME: type(%c16777217_i32)
+ // CHECK-SAME: type(%c268435457_i32)
// CHECK-NEXT: hal.buffer.store<%[[BUFFER]] : !hal.buffer>[%[[OFF]]] value(%[[C1]] : i1)
flow.tensor.store %c1, %tensor : tensor<i1>
return
diff --git a/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertCommandBufferOps.cpp b/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertCommandBufferOps.cpp
index fb700b3..396334b 100644
--- a/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertCommandBufferOps.cpp
+++ b/iree/compiler/Dialect/HAL/Conversion/HALToVM/ConvertCommandBufferOps.cpp
@@ -50,7 +50,7 @@
auto patternLengthConst = rewriter.createOrFold<mlir::arith::ConstantIntOp>(
op.getLoc(), patternLengthBytes, 32);
Value pattern = op.pattern();
- if (originalPatternType.isF16() || originalPatternType.isF32()) {
+ if (originalPatternType.isa<FloatType>()) {
pattern = rewriter.createOrFold<arith::BitcastOp>(
op.getLoc(), rewriter.getIntegerType(patternBitWidth), pattern);
}
diff --git a/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/structural_ops.mlir b/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/structural_ops.mlir
index c8f919a..5d865a4 100644
--- a/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/structural_ops.mlir
+++ b/iree/compiler/Dialect/HAL/Conversion/StandardToHAL/test/structural_ops.mlir
@@ -37,7 +37,7 @@
// CHECK-DAG: %[[C1_1:.*]] = arith.constant 1 : index
// CHECK-DAG: %[[C4:.*]] = arith.constant 4 : index
// CHECK-DAG: %[[C1_2:.*]] = arith.constant 1 : index
- // CHECK-DAG: %[[ET:.*]] = arith.constant 50331680 : i32
+ // CHECK-DAG: %[[ET:.*]] = arith.constant 553648160 : i32
// CHECK: %[[VIEW:.*]] = hal.buffer_view.create
// CHECK-SAME: shape([%[[C3]], %[[C2]], %[[C1_1]], %[[C4]], %[[C1_2]]])
// CHECK-SAME: type(%[[ET]])
diff --git a/iree/compiler/Dialect/HAL/IR/HALTypes.cpp b/iree/compiler/Dialect/HAL/IR/HALTypes.cpp
index d45adba..43a3278 100644
--- a/iree/compiler/Dialect/HAL/IR/HALTypes.cpp
+++ b/iree/compiler/Dialect/HAL/IR/HALTypes.cpp
@@ -293,21 +293,34 @@
namespace {
enum class NumericalType : uint32_t {
kUnknown = 0x00,
- kIntegerSigned = 0x01,
- kIntegerUnsigned = 0x02,
- // TODO(benvanik): specialize with semantics from APFloat.
- kFloatIEEE = 0x03,
+ kInteger = 0x10,
+ kIntegerSigned = kInteger | 0x01,
+ kIntegerUnsigned = kInteger | 0x02,
+ kFloat = 0x20,
+ kFloatIEEE = kFloat | 0x01,
+ kFloatBrain = kFloat | 0x02,
};
constexpr inline int32_t makeElementTypeValue(NumericalType numericalType,
int32_t bitCount) {
return (static_cast<uint32_t>(numericalType) << 24) | bitCount;
}
} // namespace
+
llvm::Optional<int32_t> getElementTypeValue(Type type) {
if (auto intType = type.dyn_cast_or_null<IntegerType>()) {
- // TODO(benvanik): add signed/unsigned check when landed in MLIR.
- return makeElementTypeValue(NumericalType::kIntegerSigned,
- intType.getWidth());
+ NumericalType numericalType;
+ if (intType.isSigned()) {
+ numericalType = NumericalType::kIntegerSigned;
+ } else if (intType.isUnsigned()) {
+ numericalType = NumericalType::kIntegerUnsigned;
+ } else {
+ // There's no such thing as a signless integer in machine types but we
+ // need to be able to round-trip the format through the ABI. Exact
+ // numerical type equality comparisons may fail if the frontend assumes
+ // signed/unsigned but the compiler is propagating signless.
+ numericalType = NumericalType::kInteger;
+ }
+ return makeElementTypeValue(numericalType, intType.getWidth());
} else if (auto floatType = type.dyn_cast_or_null<FloatType>()) {
switch (APFloat::SemanticsToEnum(floatType.getFloatSemantics())) {
case APFloat::S_IEEEhalf:
@@ -316,6 +329,9 @@
case APFloat::S_IEEEquad:
return makeElementTypeValue(NumericalType::kFloatIEEE,
floatType.getWidth());
+ case APFloat::S_BFloat:
+ return makeElementTypeValue(NumericalType::kFloatBrain,
+ floatType.getWidth());
default:
return llvm::None;
}
diff --git a/iree/compiler/Dialect/HAL/IR/test/allocator_op_folding.mlir b/iree/compiler/Dialect/HAL/IR/test/allocator_op_folding.mlir
index e31e854..f72efad 100644
--- a/iree/compiler/Dialect/HAL/IR/test/allocator_op_folding.mlir
+++ b/iree/compiler/Dialect/HAL/IR/test/allocator_op_folding.mlir
@@ -30,7 +30,7 @@
// CHECK-NEXT: %[[VIEW:.+]] = hal.buffer_view.create
// CHECK-SAME: buffer(%[[BUFFER]] : !hal.buffer)
// CHECK-SAME: shape([%c4, %c4])
- // CHECK-SAME: type(%c16777248_i32)
+ // CHECK-SAME: type(%c268435488_i32)
// CHECK-SAME: encoding(%c1_i32) : !hal.buffer_view
%ref = hal.allocator.constant<%allocator : !hal.allocator>
type(DeviceLocal) usage(Transfer) : !hal.buffer_view =
diff --git a/iree/compiler/Dialect/HAL/Transforms/test/convert_to_hal2.mlir b/iree/compiler/Dialect/HAL/Transforms/test/convert_to_hal2.mlir
index 745cda7..d77d583 100644
--- a/iree/compiler/Dialect/HAL/Transforms/test/convert_to_hal2.mlir
+++ b/iree/compiler/Dialect/HAL/Transforms/test/convert_to_hal2.mlir
@@ -49,7 +49,7 @@
// CHECK: hal.buffer_view.assert<%[[ARG0]] : !hal.buffer_view>
// CHECK-SAME: message("tensor")
// CHECK-SAME: shape([%c4])
- // CHECK-SAME: type(%c50331680_i32)
+ // CHECK-SAME: type(%c553648160_i32)
// CHECK-SAME: encoding(%c1_i32)
// (annoyingly out of order)
@@ -68,7 +68,7 @@
// CHECK: hal.buffer_view.assert<%[[ARG1]] : !hal.buffer_view>
// CHECK-SAME: message("tensor")
// CHECK-SAME: shape([%c4])
- // CHECK-SAME: type(%c50331680_i32)
+ // CHECK-SAME: type(%c553648160_i32)
// CHECK-SAME: encoding(%c1_i32)
// CHECK: hal.buffer.assert<%[[ARG1_BUFFER]] : !hal.buffer>
// CHECK-SAME: message("tensor")
@@ -140,7 +140,7 @@
// CHECK: %[[RESULT_VIEW:.+]] = hal.buffer_view.create
// CHECK-SAME: buffer(%[[RESULT_BUFFER]] : !hal.buffer)
// CHECK-SAME: shape([%c4])
- // CHECK-SAME: type(%c50331680_i32)
+ // CHECK-SAME: type(%c553648160_i32)
// CHECK-SAME: encoding(%c1_i32)
%result_view = stream.tensor.export %result_ready : tensor<4xf32> in !stream.resource<external>{%c16} -> !hal.buffer_view
// CHECK: return
diff --git a/iree/hal/buffer_view.c b/iree/hal/buffer_view.c
index bdc55bc..fe0e3e6 100644
--- a/iree/hal/buffer_view.c
+++ b/iree/hal/buffer_view.c
@@ -58,7 +58,7 @@
buffer_view->element_type = element_type;
buffer_view->encoding_type = encoding_type;
buffer_view->byte_length =
- iree_hal_element_byte_count(buffer_view->element_type);
+ iree_hal_element_dense_byte_count(buffer_view->element_type);
buffer_view->shape_rank = shape_rank;
for (iree_host_size_t i = 0; i < shape_rank; ++i) {
buffer_view->shape[i] = shape[i];
@@ -322,7 +322,7 @@
IREE_API_EXPORT iree_host_size_t
iree_hal_buffer_view_element_size(const iree_hal_buffer_view_t* buffer_view) {
IREE_ASSERT_ARGUMENT(buffer_view);
- return iree_hal_element_byte_count(buffer_view->element_type);
+ return iree_hal_element_dense_byte_count(buffer_view->element_type);
}
IREE_API_EXPORT iree_hal_encoding_type_t
@@ -371,7 +371,7 @@
switch (encoding_type) {
case IREE_HAL_ENCODING_TYPE_DENSE_ROW_MAJOR:
- byte_length = iree_hal_element_byte_count(element_type);
+ byte_length = iree_hal_element_dense_byte_count(element_type);
for (iree_host_size_t i = 0; i < shape_rank; ++i) {
byte_length *= shape[i];
}
@@ -418,7 +418,7 @@
}
offset += axis_offset;
}
- offset *= iree_hal_element_byte_count(element_type);
+ offset *= iree_hal_element_dense_byte_count(element_type);
*out_offset = offset;
return iree_ok_status();
@@ -456,7 +456,8 @@
iree_hal_dim_t* end_indices =
iree_alloca(shape_rank * sizeof(iree_hal_dim_t));
- iree_device_size_t element_size = iree_hal_element_byte_count(element_type);
+ iree_device_size_t element_size =
+ iree_hal_element_dense_byte_count(element_type);
iree_device_size_t subspan_length = element_size;
for (iree_host_size_t i = 0; i < lengths_count; ++i) {
subspan_length *= lengths[i];
diff --git a/iree/hal/buffer_view.h b/iree/hal/buffer_view.h
index 310a487..b73587a 100644
--- a/iree/hal/buffer_view.h
+++ b/iree/hal/buffer_view.h
@@ -27,26 +27,70 @@
// iree/compiler/Dialect/HAL/IR/HALTypes.cpp
enum iree_hal_numerical_type_bits_t {
+ // Opaque or unknown - bytes cannot be interpreted.
IREE_HAL_NUMERICAL_TYPE_UNKNOWN = 0x00u,
- IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED = 0x01u,
- IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED = 0x02u,
- // TODO(benvanik): specialize with semantics from APFloat.
- IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE = 0x03u,
+
+ // Signless integer-like.
+ IREE_HAL_NUMERICAL_TYPE_INTEGER = 0x10u,
+ // Signed integer.
+ IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED =
+ IREE_HAL_NUMERICAL_TYPE_INTEGER | 0x01u,
+ // Unsigned integer.
+ IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED =
+ IREE_HAL_NUMERICAL_TYPE_INTEGER | 0x02u,
+
+ // Float-like.
+ IREE_HAL_NUMERICAL_TYPE_FLOAT = 0x20,
+ // IEEE754-compatible floating point semantics.
+ IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE = IREE_HAL_NUMERICAL_TYPE_FLOAT | 0x01u,
+ // 'Brain' floating point semantics (currently only bf16).
+ IREE_HAL_NUMERICAL_TYPE_FLOAT_BRAIN = IREE_HAL_NUMERICAL_TYPE_FLOAT | 0x02u,
};
typedef uint8_t iree_hal_numerical_type_t;
#define IREE_HAL_ELEMENT_TYPE_VALUE(numerical_type, bit_count) \
(((uint32_t)(numerical_type) << 24) | (uint32_t)(bit_count))
+// Composes an iree_hal_element_type_t value with the given attributes.
#define iree_hal_make_element_type(numerical_type, bit_count) \
(iree_hal_element_type_t)( \
IREE_HAL_ELEMENT_TYPE_VALUE(numerical_type, bit_count))
+
+// Returns the numerical type of the element, if known and not opaque.
#define iree_hal_element_numerical_type(element_type) \
(iree_hal_numerical_type_t)((uint32_t)(element_type) >> 24)
+
+// Returns true if |element_type| is opaque and cannot be interpreted.
+#define iree_hal_element_numerical_type_is_opaque(element_type) \
+ (iree_hal_element_numerical_type(element_type) == \
+ IREE_HAL_NUMERICAL_TYPE_UNKNOWN)
+
+// Returns true if |element_type| is an integer of some width and semantics.
+#define iree_hal_element_numerical_type_is_integer(element_type) \
+ iree_all_bits_set(iree_hal_element_numerical_type(element_type), \
+ IREE_HAL_NUMERICAL_TYPE_INTEGER)
+
+// Returns true if |element_type| is a float of some width and semantics.
+#define iree_hal_element_numerical_type_is_float(element_type) \
+ iree_all_bits_set(iree_hal_element_numerical_type(element_type), \
+ IREE_HAL_NUMERICAL_TYPE_FLOAT)
+
+// Returns the bit width of each element.
#define iree_hal_element_bit_count(element_type) (size_t)((element_type)&0xFF)
-#define iree_hal_element_byte_count(element_type) \
+
+// Returns the number of bytes each |element_type| consumes in memory.
+// This is only valid when the encoding type is dense as sub-byte bit widths
+// may be packed in various forms (for example, i4 may be stored as nibbles
+// where each byte in memory contains two elements).
+#define iree_hal_element_dense_byte_count(element_type) \
((iree_hal_element_bit_count(element_type) + 8 - 1) / 8)
+// Returns true if the given |element_type| represents an integer of exactly
+// |bit_width|. This ignores the signedness of the integer type.
+#define iree_hal_element_type_is_integer(element_type, bit_width) \
+ (iree_hal_element_numerical_type_is_integer(element_type) && \
+ iree_hal_element_bit_count(element_type) == (bit_width))
+
// Defines the element type of a buffer in a standard format.
//
// Composed as a 32-bit bitfield to allow for opaque data types. Use
@@ -62,17 +106,25 @@
IREE_HAL_ELEMENT_TYPE_OPAQUE_16 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_UNKNOWN, 16), // NOLINT
IREE_HAL_ELEMENT_TYPE_OPAQUE_32 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_UNKNOWN, 32), // NOLINT
IREE_HAL_ELEMENT_TYPE_OPAQUE_64 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_UNKNOWN, 64), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_INT_4 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER, 4), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_SINT_4 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 4), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_UINT_4 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED, 4), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_INT_8 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER, 8), // NOLINT
IREE_HAL_ELEMENT_TYPE_SINT_8 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 8), // NOLINT
IREE_HAL_ELEMENT_TYPE_UINT_8 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED, 8), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_INT_16 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER, 16), // NOLINT
IREE_HAL_ELEMENT_TYPE_SINT_16 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 16), // NOLINT
IREE_HAL_ELEMENT_TYPE_UINT_16 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED, 16), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_INT_32 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER, 32), // NOLINT
IREE_HAL_ELEMENT_TYPE_SINT_32 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 32), // NOLINT
IREE_HAL_ELEMENT_TYPE_UINT_32 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED, 32), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_INT_64 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER, 64), // NOLINT
IREE_HAL_ELEMENT_TYPE_SINT_64 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED, 64), // NOLINT
IREE_HAL_ELEMENT_TYPE_UINT_64 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED, 64), // NOLINT
IREE_HAL_ELEMENT_TYPE_FLOAT_16 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE, 16), // NOLINT
IREE_HAL_ELEMENT_TYPE_FLOAT_32 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE, 32), // NOLINT
IREE_HAL_ELEMENT_TYPE_FLOAT_64 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE, 64), // NOLINT
+ IREE_HAL_ELEMENT_TYPE_BFLOAT_16 = IREE_HAL_ELEMENT_TYPE_VALUE(IREE_HAL_NUMERICAL_TYPE_FLOAT_BRAIN, 16), // NOLINT
};
typedef uint32_t iree_hal_element_type_t;
// clang-format on
diff --git a/iree/hal/string_util.c b/iree/hal/string_util.c
index 0c761d8..0938301 100644
--- a/iree/hal/string_util.c
+++ b/iree/hal/string_util.c
@@ -104,11 +104,15 @@
iree_string_view_t str_value = value;
iree_hal_numerical_type_t numerical_type = IREE_HAL_NUMERICAL_TYPE_UNKNOWN;
if (iree_string_view_consume_prefix(&str_value, IREE_SV("i"))) {
+ numerical_type = IREE_HAL_NUMERICAL_TYPE_INTEGER;
+ } else if (iree_string_view_consume_prefix(&str_value, IREE_SV("si"))) {
numerical_type = IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED;
- } else if (iree_string_view_consume_prefix(&str_value, IREE_SV("u"))) {
+ } else if (iree_string_view_consume_prefix(&str_value, IREE_SV("ui"))) {
numerical_type = IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED;
} else if (iree_string_view_consume_prefix(&str_value, IREE_SV("f"))) {
numerical_type = IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE;
+ } else if (iree_string_view_consume_prefix(&str_value, IREE_SV("bf"))) {
+ numerical_type = IREE_HAL_NUMERICAL_TYPE_FLOAT_BRAIN;
} else if (iree_string_view_consume_prefix(&str_value, IREE_SV("x")) ||
iree_string_view_consume_prefix(&str_value, IREE_SV("*"))) {
numerical_type = IREE_HAL_NUMERICAL_TYPE_UNKNOWN;
@@ -138,15 +142,21 @@
}
const char* prefix;
switch (iree_hal_element_numerical_type(element_type)) {
- case IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED:
+ case IREE_HAL_NUMERICAL_TYPE_INTEGER:
prefix = "i";
break;
+ case IREE_HAL_NUMERICAL_TYPE_INTEGER_SIGNED:
+ prefix = "si";
+ break;
case IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED:
- prefix = "u";
+ prefix = "ui";
break;
case IREE_HAL_NUMERICAL_TYPE_FLOAT_IEEE:
prefix = "f";
break;
+ case IREE_HAL_NUMERICAL_TYPE_FLOAT_BRAIN:
+ prefix = "bf";
+ break;
default:
prefix = "*";
break;
@@ -198,6 +208,7 @@
iree_string_view_t data_str, iree_hal_element_type_t element_type,
uint8_t* out_data) {
switch (element_type) {
+ case IREE_HAL_ELEMENT_TYPE_INT_8:
case IREE_HAL_ELEMENT_TYPE_SINT_8: {
int32_t temp = 0;
if (!iree_string_view_atoi_int32(data_str, &temp) || temp > INT8_MAX) {
@@ -214,6 +225,7 @@
*(uint8_t*)out_data = (uint8_t)temp;
return iree_ok_status();
}
+ case IREE_HAL_ELEMENT_TYPE_INT_16:
case IREE_HAL_ELEMENT_TYPE_SINT_16: {
int32_t temp = 0;
if (!iree_string_view_atoi_int32(data_str, &temp) || temp > INT16_MAX) {
@@ -230,6 +242,7 @@
*(uint16_t*)out_data = (uint16_t)temp;
return iree_ok_status();
}
+ case IREE_HAL_ELEMENT_TYPE_INT_32:
case IREE_HAL_ELEMENT_TYPE_SINT_32:
return iree_string_view_atoi_int32(data_str, (int32_t*)out_data)
? iree_ok_status()
@@ -238,6 +251,7 @@
return iree_string_view_atoi_uint32(data_str, (uint32_t*)out_data)
? iree_ok_status()
: iree_status_from_code(IREE_STATUS_INVALID_ARGUMENT);
+ case IREE_HAL_ELEMENT_TYPE_INT_64:
case IREE_HAL_ELEMENT_TYPE_SINT_64:
return iree_string_view_atoi_int64(data_str, (int64_t*)out_data)
? iree_ok_status()
@@ -264,7 +278,8 @@
: iree_status_from_code(IREE_STATUS_INVALID_ARGUMENT);
default: {
// Treat any unknown format as binary.
- iree_host_size_t element_size = iree_hal_element_byte_count(element_type);
+ iree_host_size_t element_size =
+ iree_hal_element_dense_byte_count(element_type);
if (data_str.size != element_size * 2) {
return iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
"binary hex element count mismatch: buffer "
@@ -280,7 +295,8 @@
IREE_API_EXPORT iree_status_t iree_hal_parse_element(
iree_string_view_t data_str, iree_hal_element_type_t element_type,
iree_byte_span_t data_ptr) {
- iree_host_size_t element_size = iree_hal_element_byte_count(element_type);
+ iree_host_size_t element_size =
+ iree_hal_element_dense_byte_count(element_type);
if (data_ptr.data_length < element_size) {
return iree_make_status(
IREE_STATUS_INVALID_ARGUMENT,
@@ -321,7 +337,8 @@
iree_const_byte_span_t data, iree_hal_element_type_t element_type,
iree_host_size_t buffer_capacity, char* buffer,
iree_host_size_t* out_buffer_length) {
- iree_host_size_t element_size = iree_hal_element_byte_count(element_type);
+ iree_host_size_t element_size =
+ iree_hal_element_dense_byte_count(element_type);
if (data.data_length < element_size) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
@@ -330,6 +347,7 @@
}
int n = 0;
switch (element_type) {
+ case IREE_HAL_ELEMENT_TYPE_INT_8:
case IREE_HAL_ELEMENT_TYPE_SINT_8:
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIi8,
*(const int8_t*)data.data);
@@ -338,6 +356,7 @@
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIu8,
*(const uint8_t*)data.data);
break;
+ case IREE_HAL_ELEMENT_TYPE_INT_16:
case IREE_HAL_ELEMENT_TYPE_SINT_16:
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIi16,
*(const int16_t*)data.data);
@@ -346,6 +365,7 @@
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIu16,
*(const uint16_t*)data.data);
break;
+ case IREE_HAL_ELEMENT_TYPE_INT_32:
case IREE_HAL_ELEMENT_TYPE_SINT_32:
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIi32,
*(const int32_t*)data.data);
@@ -354,6 +374,7 @@
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIu32,
*(const uint32_t*)data.data);
break;
+ case IREE_HAL_ELEMENT_TYPE_INT_64:
case IREE_HAL_ELEMENT_TYPE_SINT_64:
n = snprintf(buffer, buffer ? buffer_capacity : 0, "%" PRIi64,
*(const int64_t*)data.data);
@@ -398,7 +419,8 @@
IREE_API_EXPORT iree_status_t iree_hal_parse_buffer_elements(
iree_string_view_t data_str, iree_hal_element_type_t element_type,
iree_byte_span_t data_ptr) {
- iree_host_size_t element_size = iree_hal_element_byte_count(element_type);
+ iree_host_size_t element_size =
+ iree_hal_element_dense_byte_count(element_type);
iree_host_size_t element_capacity = data_ptr.data_length / element_size;
if (iree_string_view_is_empty(data_str)) {
memset(data_ptr.data, 0, data_ptr.data_length);
@@ -491,7 +513,7 @@
dim_length *= shape[i];
}
iree_device_size_t dim_stride =
- dim_length * iree_hal_element_byte_count(element_type);
+ dim_length * iree_hal_element_dense_byte_count(element_type);
if (data.data_length < dim_stride * shape[0]) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
@@ -522,7 +544,7 @@
iree_host_size_t max_count =
iree_min(*max_element_count, (iree_host_size_t)shape[0]);
iree_device_size_t element_stride =
- iree_hal_element_byte_count(element_type);
+ iree_hal_element_dense_byte_count(element_type);
if (data.data_length < max_count * element_stride) {
return iree_make_status(
IREE_STATUS_OUT_OF_RANGE,
diff --git a/iree/hal/string_util_test.cc b/iree/hal/string_util_test.cc
index c661520..be1a991 100644
--- a/iree/hal/string_util_test.cc
+++ b/iree/hal/string_util_test.cc
@@ -548,13 +548,17 @@
TEST(ElementTypeStringUtilTest, ParseElementType) {
EXPECT_THAT(ParseElementType("i8"),
+ IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_INT_8)));
+ EXPECT_THAT(ParseElementType("si8"),
IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_SINT_8)));
- EXPECT_THAT(ParseElementType("u16"),
+ EXPECT_THAT(ParseElementType("ui16"),
IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_UINT_16)));
EXPECT_THAT(ParseElementType("f32"),
IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_FLOAT_32)));
EXPECT_THAT(ParseElementType("f16"),
IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_FLOAT_16)));
+ EXPECT_THAT(ParseElementType("bf16"),
+ IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_BFLOAT_16)));
EXPECT_THAT(ParseElementType("x64"),
IsOkAndHolds(Eq(IREE_HAL_ELEMENT_TYPE_OPAQUE_64)));
EXPECT_THAT(ParseElementType("*64"),
@@ -572,12 +576,16 @@
}
TEST(ElementTypeStringUtilTest, FormatElementType) {
- EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_SINT_8),
+ EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_INT_8),
IsOkAndHolds(Eq("i8")));
+ EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_SINT_8),
+ IsOkAndHolds(Eq("si8")));
EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_UINT_16),
- IsOkAndHolds(Eq("u16")));
+ IsOkAndHolds(Eq("ui16")));
EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_FLOAT_32),
IsOkAndHolds(Eq("f32")));
+ EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_BFLOAT_16),
+ IsOkAndHolds(Eq("bf16")));
EXPECT_THAT(FormatElementType(IREE_HAL_ELEMENT_TYPE_OPAQUE_64),
IsOkAndHolds(Eq("*64")));
EXPECT_THAT(FormatElementType(iree_hal_make_element_type(
@@ -1001,10 +1009,12 @@
};
expect_round_trip("i8=-8");
- expect_round_trip("u8=239");
+ expect_round_trip("si8=-8");
+ expect_round_trip("ui8=239");
expect_round_trip("4xi8=0 -1 2 3");
+ expect_round_trip("4xsi8=0 -1 2 3");
expect_round_trip("4xi16=0 -1 2 3");
- expect_round_trip("4xu16=0 1 2 3");
+ expect_round_trip("4xui16=0 1 2 3");
expect_round_trip("2x2xi32=[0 1][2 3]");
expect_round_trip("4xf16=0 0.5 2 3");
expect_round_trip("4xf32=0 1.1 2 3");
diff --git a/iree/iree.natvis b/iree/iree.natvis
index 78b1188..2fd977c 100644
--- a/iree/iree.natvis
+++ b/iree/iree.natvis
@@ -264,101 +264,165 @@
<!--=========================================================================-->
<Type Name="iree_hal_buffer_view_t">
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<i4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<si4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<ui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<i8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<si8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<ui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<i16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<si16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<ui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<i32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<si32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<ui32> size={byte_length}}}</DisplayString>
- <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<si64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<i64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<ui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<ui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<f16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<f32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<f64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==0 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<bf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}xi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}xi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}xi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==1 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}xbf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xbf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==2 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}xbf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==3 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}xbf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==4 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}xbf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==5 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}xbf16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_INT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xsi4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_4">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xui4> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_INT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xsi8> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_8">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xui8> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_INT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xsi16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xui16> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_INT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xsi32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xui32> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_INT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_SINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xsi64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_UINT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xui64> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xf16> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_32">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xf32> size={byte_length}}}</DisplayString>
<DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_FLOAT_64">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xf64> size={byte_length}}}</DisplayString>
+ <DisplayString Condition="shape_rank==6 && element_type==IREE_HAL_ELEMENT_TYPE_BFLOAT_16">{{!hal.buffer_view<{shape[0]}x{shape[1]}x{shape[2]}x{shape[3]}x{shape[4]}x{shape[5]}xbf16> size={byte_length}}}</DisplayString>
<Expand>
<Item Name="[references]" ExcludeView="simple">ref_count</Item>
diff --git a/iree/modules/check/check_test.cc b/iree/modules/check/check_test.cc
index 404f016..e4793af 100644
--- a/iree/modules/check/check_test.cc
+++ b/iree/modules/check/check_test.cc
@@ -90,7 +90,7 @@
IREE_ASSERT_OK(iree_hal_buffer_write_data(
buffer.get(), 0, contents.data(), contents.size() * sizeof(int32_t)));
IREE_ASSERT_OK(iree_hal_buffer_view_create(
- buffer.get(), shape.data(), shape.size(), IREE_HAL_ELEMENT_TYPE_SINT_32,
+ buffer.get(), shape.data(), shape.size(), IREE_HAL_ELEMENT_TYPE_INT_32,
IREE_HAL_ENCODING_TYPE_DENSE_ROW_MAJOR, &*out_buffer_view));
}
diff --git a/iree/modules/check/module.cc b/iree/modules/check/module.cc
index 7fe3673..061fa71 100644
--- a/iree/modules/check/module.cc
+++ b/iree/modules/check/module.cc
@@ -108,22 +108,9 @@
return AlmostEqByteSpan<double>(lhs_bytes, rhs_bytes);
case IREE_HAL_ELEMENT_TYPE_FLOAT_16:
return AlmostEqByteSpanF16(lhs_bytes, rhs_bytes);
- case IREE_HAL_ELEMENT_TYPE_SINT_8:
- case IREE_HAL_ELEMENT_TYPE_UINT_8:
- case IREE_HAL_ELEMENT_TYPE_SINT_16:
- case IREE_HAL_ELEMENT_TYPE_UINT_16:
- case IREE_HAL_ELEMENT_TYPE_SINT_32:
- case IREE_HAL_ELEMENT_TYPE_UINT_32:
- case IREE_HAL_ELEMENT_TYPE_SINT_64:
- case IREE_HAL_ELEMENT_TYPE_UINT_64:
+ default:
// TODO(gcmn): Consider supporting fuzzy matching for quantized integers.
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_8:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_16:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_32:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_64:
- case IREE_HAL_ELEMENT_TYPE_NONE: {
break;
- }
}
char element_type_str[16];
IREE_RETURN_IF_ERROR(iree_hal_format_element_type(
@@ -135,18 +122,22 @@
Status ExpectAllTrue(iree_byte_span_t bytes,
iree_hal_element_type_t element_type) {
switch (element_type) {
+ case IREE_HAL_ELEMENT_TYPE_INT_8:
case IREE_HAL_ELEMENT_TYPE_SINT_8:
return ExpectAllTrue<int8_t>(bytes);
case IREE_HAL_ELEMENT_TYPE_UINT_8:
return ExpectAllTrue<uint8_t>(bytes);
+ case IREE_HAL_ELEMENT_TYPE_INT_16:
case IREE_HAL_ELEMENT_TYPE_SINT_16:
return ExpectAllTrue<int16_t>(bytes);
case IREE_HAL_ELEMENT_TYPE_UINT_16:
return ExpectAllTrue<uint16_t>(bytes);
+ case IREE_HAL_ELEMENT_TYPE_INT_32:
case IREE_HAL_ELEMENT_TYPE_SINT_32:
return ExpectAllTrue<int32_t>(bytes);
case IREE_HAL_ELEMENT_TYPE_UINT_32:
return ExpectAllTrue<uint32_t>(bytes);
+ case IREE_HAL_ELEMENT_TYPE_INT_64:
case IREE_HAL_ELEMENT_TYPE_SINT_64:
return ExpectAllTrue<int64_t>(bytes);
case IREE_HAL_ELEMENT_TYPE_UINT_64:
@@ -155,14 +146,8 @@
return ExpectAllTrue<float>(bytes);
case IREE_HAL_ELEMENT_TYPE_FLOAT_64:
return ExpectAllTrue<double>(bytes);
- case IREE_HAL_ELEMENT_TYPE_NONE:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_8:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_16:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_32:
- case IREE_HAL_ELEMENT_TYPE_OPAQUE_64:
- case IREE_HAL_ELEMENT_TYPE_FLOAT_16: {
+ default:
break;
- }
}
char element_type_str[16];
IREE_RETURN_IF_ERROR(iree_hal_format_element_type(
diff --git a/iree/samples/custom_modules/dialect/test/conversion.mlir b/iree/samples/custom_modules/dialect/test/conversion.mlir
index a6c65ca..3223f39 100644
--- a/iree/samples/custom_modules/dialect/test/conversion.mlir
+++ b/iree/samples/custom_modules/dialect/test/conversion.mlir
@@ -12,7 +12,7 @@
// CHECK-LABEL: @tensorToMessage
func @tensorToMessage(%tensor : tensor<2x4xf32>) {
- // CHECK-DAG: [[TYPE:%.+]] = vm.const.i32 50331680 : i32
+ // CHECK-DAG: [[TYPE:%.+]] = vm.const.i32 553648160 : i32
// CHECK-DAG: [[ENCODING:%.+]] = vm.const.i32 1 : i32
// CHECK-DAG: [[DIM0:%.+]] = vm.const.i32 2 : i32
// CHECK-DAG: [[DIM1:%.+]] = vm.const.i32 4 : i32
@@ -32,7 +32,7 @@
// CHECK-LABEL: @dynamicTensorToMessage
func @dynamicTensorToMessage(%arg0 : tensor<?x?xf32>, %arg1 : index, %arg2 : index) {
- // CHECK-DAG: [[TYPE:%.+]] = vm.const.i32 50331680 : i32
+ // CHECK-DAG: [[TYPE:%.+]] = vm.const.i32 553648160 : i32
// CHECK-DAG: [[ENCODING:%.+]] = vm.const.i32 1 : i32
// CHECK-NEXT: [[VIEW:%.+]] = vm.call.variadic @hal.buffer_view.create(
// CHECK-SAME: %arg0, [[TYPE]], [[ENCODING]], [%arg1, %arg2])
@@ -50,7 +50,7 @@
// CHECK-LABEL: @dynamicTensorToMessage2
func @dynamicTensorToMessage2(%arg0 : tensor<?x?xf32>, %arg1: !shapex.ranked_shape<[?, ?]> {iree.reflection = {}}) {
- // CHECK-DAG: [[TYPE:%.+]] = vm.const.i32 50331680 : i32
+ // CHECK-DAG: [[TYPE:%.+]] = vm.const.i32 553648160 : i32
// CHECK-DAG: [[ENCODING:%.+]] = vm.const.i32 1 : i32
// CHECK-NEXT: [[VIEW:%.+]] = vm.call.variadic @hal.buffer_view.create(
// CHECK-SAME: %arg0, [[TYPE]], [[ENCODING]], [%arg1, %arg2])
diff --git a/iree/tools/iree-e2e-matmul-test.c b/iree/tools/iree-e2e-matmul-test.c
index a2d0eea..4d622a0 100644
--- a/iree/tools/iree-e2e-matmul-test.c
+++ b/iree/tools/iree-e2e-matmul-test.c
@@ -147,9 +147,9 @@
reference_matmul_element_f32(m_size, k_size, n_size, lhs_type, rhs_type,
(float*)lhs_data, (float*)rhs_data,
(float*)acc_data, (float*)result_data, m, n);
- } else if (lhs_type == IREE_HAL_ELEMENT_TYPE_SINT_8 &&
- rhs_type == IREE_HAL_ELEMENT_TYPE_SINT_8 &&
- acc_type == IREE_HAL_ELEMENT_TYPE_SINT_32) {
+ } else if (iree_hal_element_type_is_integer(lhs_type, 8) &&
+ iree_hal_element_type_is_integer(rhs_type, 8) &&
+ iree_hal_element_type_is_integer(acc_type, 32)) {
reference_matmul_element_i8_i8_i32(
m_size, k_size, n_size, lhs_type, rhs_type, (int8_t*)lhs_data,
(int8_t*)rhs_data, (int32_t*)acc_data, (int32_t*)result_data, m, n);
@@ -203,18 +203,18 @@
iree_hal_dim_t n) {
iree_host_size_t index = n + m * n_size;
(void)m_size;
- switch (result_type) {
- case IREE_HAL_ELEMENT_TYPE_FLOAT_32:
- return iree_vm_value_make_f32(((float*)data)[index]);
- case IREE_HAL_ELEMENT_TYPE_SINT_32:
- return iree_vm_value_make_i32(((int32_t*)data)[index]);
- case IREE_HAL_ELEMENT_TYPE_SINT_8:
- return iree_vm_value_make_i8(((int8_t*)data)[index]);
- default:
- iree_status_abort(iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
- "unhandled matmul result type"));
- return iree_vm_value_make_none();
+ if (iree_hal_element_type_is_integer(result_type, 8)) {
+ return iree_vm_value_make_i8(((int8_t*)data)[index]);
+ } else if (iree_hal_element_type_is_integer(result_type, 16)) {
+ return iree_vm_value_make_i16(((int16_t*)data)[index]);
+ } else if (iree_hal_element_type_is_integer(result_type, 32)) {
+ return iree_vm_value_make_i32(((int32_t*)data)[index]);
+ } else if (result_type == IREE_HAL_ELEMENT_TYPE_FLOAT_32) {
+ return iree_vm_value_make_f32(((float*)data)[index]);
}
+ iree_status_abort(iree_make_status(IREE_STATUS_INVALID_ARGUMENT,
+ "unhandled matmul result type"));
+ return iree_vm_value_make_none();
}
typedef enum precision_e {
diff --git a/iree/tools/utils/image_util.c b/iree/tools/utils/image_util.c
index 60f7708..6bc1a06 100644
--- a/iree/tools/utils/image_util.c
+++ b/iree/tools/utils/image_util.c
@@ -132,7 +132,8 @@
result = iree_tools_utils_load_pixel_data(
filename, shape, shape_rank, element_type, &pixel_data, &buffer_length);
if (iree_status_is_ok(result)) {
- iree_host_size_t element_byte = iree_hal_element_byte_count(element_type);
+ iree_host_size_t element_byte =
+ iree_hal_element_dense_byte_count(element_type);
// SINT_8 and UINT_8 perform direct buffer wrap.
result = iree_hal_buffer_view_wrap_or_clone_heap_buffer(
allocator, shape, shape_rank, element_type,
@@ -164,7 +165,8 @@
uint8_t* pixel_data = NULL;
iree_hal_buffer_t* buffer = NULL;
iree_host_size_t buffer_length;
- iree_host_size_t element_byte = iree_hal_element_byte_count(element_type);
+ iree_host_size_t element_byte =
+ iree_hal_element_dense_byte_count(element_type);
iree_hal_buffer_mapping_t mapped_memory;
result = iree_tools_utils_load_pixel_data(
filename, shape, shape_rank, element_type, &pixel_data, &buffer_length);
diff --git a/iree/tools/utils/trace_replay.c b/iree/tools/utils/trace_replay.c
index 4f01524..7099b38 100644
--- a/iree/tools/utils/trace_replay.c
+++ b/iree/tools/utils/trace_replay.c
@@ -385,7 +385,7 @@
// Parses an element type.
//
// ```yaml
-// element_type: 50331680
+// element_type: 553648160
// ```
// or
// ```yaml
@@ -422,7 +422,7 @@
// Parses an encoding type.
//
// ```yaml
-// encoding_type: 50331680
+// encoding_type: 553648160
// ```
static iree_status_t iree_trace_replay_parse_hal_encoding_type(
iree_trace_replay_t* replay, yaml_document_t* document,
@@ -509,6 +509,10 @@
break;
switch (element_type) {
+ IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(INT_8, int8_t)
+ IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(INT_16, int16_t)
+ IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(INT_32, int32_t)
+ IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(INT_64, int64_t)
IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(SINT_8, int8_t)
IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(SINT_16, int16_t)
IREE_TRACE_REPLAY_WRITE_ELEMENT_CASE(SINT_32, int32_t)
@@ -545,7 +549,7 @@
iree_hal_element_type_t element_type, iree_byte_span_t span,
iree_hal_dim_t inner_size) {
iree_host_size_t element_byte_count =
- iree_hal_element_byte_count(element_type);
+ iree_hal_element_dense_byte_count(element_type);
uint8_t* data_end = span.data + span.data_length;
iree_host_size_t inner_index = 0;
iree_host_size_t outer_index = 0;
@@ -581,7 +585,7 @@
const bool is_unsigned = iree_hal_element_numerical_type(element_type) ==
IREE_HAL_NUMERICAL_TYPE_INTEGER_UNSIGNED;
iree_host_size_t element_byte_count =
- iree_hal_element_byte_count(element_type);
+ iree_hal_element_dense_byte_count(element_type);
uint8_t* data_end = span.data + span.data_length;
uint32_t state = seed;
for (uint8_t* data = span.data; data < data_end; data += element_byte_count) {
@@ -653,7 +657,7 @@
// ```yaml
// shape:
// - 4
-// element_type: 50331680
+// element_type: 553648160
// contents: !!binary |
// AACAPwAAAEAAAEBAAACAQA==
// ```