Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion mlir/include/mlir/Dialect/Tosa/IR/TosaComplianceData.h.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2927,7 +2927,31 @@ extensionComplianceMap = {
{{{fp8e4m3T, fp8e4m3T}, SpecificationVersion::V_1_0}}},
{{Extension::fp8e5m2},
{{{fp8e5m2T, fp8e5m2T}, SpecificationVersion::V_1_0}}},
{{Extension::bf16}, {{{bf16T, bf16T}, SpecificationVersion::V_1_0}}}}},
{{Extension::bf16}, {{{bf16T, bf16T}, SpecificationVersion::V_1_0}}},
{{Extension::mx_common, Extension::mx_fp8e4m3},
{{{bs32_fp8ue8m0_fp8e4m3T, bs32_fp8ue8m0_fp8e4m3T},
SpecificationVersion::V_1_1_DRAFT}},
allOf},
{{Extension::mx_common, Extension::mx_fp8e5m2},
{{{bs32_fp8ue8m0_fp8e5m2T, bs32_fp8ue8m0_fp8e5m2T},
SpecificationVersion::V_1_1_DRAFT}},
allOf},
{{Extension::mx_common, Extension::mx_fp6e3m2},
{{{bs32_fp8ue8m0_fp6e3m2T, bs32_fp8ue8m0_fp6e3m2T},
SpecificationVersion::V_1_1_DRAFT}},
allOf},
{{Extension::mx_common, Extension::mx_fp6e2m3},
{{{bs32_fp8ue8m0_fp6e2m3T, bs32_fp8ue8m0_fp6e2m3T},
SpecificationVersion::V_1_1_DRAFT}},
allOf},
{{Extension::mx_common, Extension::mx_fp4e2m1},
{{{bs32_fp8ue8m0_fp4e2m1T, bs32_fp8ue8m0_fp4e2m1T},
SpecificationVersion::V_1_1_DRAFT}},
allOf},
{{Extension::mx_common, Extension::mx_int8},
{{{bs32_fp8ue8m0_mxint8T, bs32_fp8ue8m0_mxint8T},
SpecificationVersion::V_1_1_DRAFT}},
allOf}}},
{"tosa.gather",
{{{Extension::fp8e4m3},
{{{fp8e4m3T, i32T, fp8e4m3T}, SpecificationVersion::V_1_0}}},
Expand Down
6 changes: 6 additions & 0 deletions mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3583,6 +3583,12 @@ LogicalResult tosa::TransposeOp::verify() {
constantPerms, [](int32_t v) -> int64_t { return v; })))
return emitOpError() << "expected valid permutation indices";

if (isa<BlockScaledType>(getInput1().getType().getElementType()) &&
constantPerms.back() != static_cast<int32_t>(constantPerms.size()) - 1) {
return emitOpError() << "expected no-op permutation on innermost dimension "
"for block scaled input";
}

// ERROR_IF(tensor_size(shape1) != tensor_size(shape))
if (inputShape.hasStaticShape() && outputShape.hasStaticShape() &&
inputShape.getNumElements() != outputShape.getNumElements())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,11 @@ func.func @test_resize_mxfp(%arg0: tensor<1x32x32x32x!tosa.block_scaled<BLOCK_SH
%0 = tosa.resize %arg0, %scale, %offset, %border { mode = NEAREST_NEIGHBOR } : (tensor<1x32x32x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f4E2M1FN>>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x64x64x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f4E2M1FN>>
return %0 : tensor<1x64x64x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f4E2M1FN>>
}

// -----

func.func @test_transpose_block_scaled_f6E3M2FN(%input: tensor<29x12x13x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>) -> tensor<13x29x12x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>> {
// expected-error@+1 {{'tosa.transpose' op illegal: requires specification version compatible with 1.1.draft (got 1.0) and requires all of [mx_common, mx_fp6e3m2] profiles/extensions to be specified in the target environment}}
%transpose = tosa.transpose %input { perms = array<i32: 2, 0, 1, 3> } : (tensor<29x12x13x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>) -> tensor<13x29x12x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>
return %transpose : tensor<13x29x12x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>
}
8 changes: 8 additions & 0 deletions mlir/test/Dialect/Tosa/tosa-validation-version-1p0-valid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ func.func @test_scatter_i8_i32(%input: tensor<13x27x3xi8>, %indices: tensor<13x2
%scatter = tosa.scatter %input, %indices, %updates : (tensor<13x27x3xi8>, tensor<13x26xi32>, tensor<13x26x3xi8>) -> tensor<13x27x3xi8>
return %scatter : tensor<13x27x3xi8>
}

// -----

// CHECK-LABEL: test_transpose_i16
func.func @test_transpose_i16(%input: tensor<29x12x13x7xi16>) -> tensor<13x29x7x12xi16> {
%transpose = tosa.transpose %input { perms = array<i32: 2, 0, 3, 1> } : (tensor<29x12x13x7xi16>) -> tensor<13x29x7x12xi16>
return %transpose : tensor<13x29x7x12xi16>
}
8 changes: 8 additions & 0 deletions mlir/test/Dialect/Tosa/tosa-validation-version-1p1-valid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,11 @@ func.func @test_resize_mxfp_types(
%5 = tosa.resize %mxint8, %scale, %offset, %border { mode = NEAREST_NEIGHBOR } : (tensor<1x32x32x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:!tosa.mxint8>>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x64x64x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:!tosa.mxint8>>
return
}

// -----

// CHECK-LABEL: test_transpose_block_scaled_f6E3M2FN
func.func @test_transpose_block_scaled_f6E3M2FN(%input: tensor<29x12x13x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>) -> tensor<13x29x12x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>> {
%transpose = tosa.transpose %input { perms = array<i32: 2, 0, 1, 3> } : (tensor<29x12x13x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>) -> tensor<13x29x12x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>
return %transpose : tensor<13x29x12x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>
}
8 changes: 8 additions & 0 deletions mlir/test/Dialect/Tosa/verifier.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2393,3 +2393,11 @@ func.func @test_block_scaled_const_cast_scale_values_propagate() -> tensor<2x32x
%0 = "tosa.const"() <{values = dense<tensor<2x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E4M3FN, {2.0, 4.0}>> : 0.0 : f8E4M3FN>}> : () -> tensor<2x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E4M3FN, {2.0, 4.0}>>
return %0 : tensor<2x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f8E4M3FN, {2.0, 4.0}>>
}

// -----

func.func @test_transpose_block_scaled_illegal_perms(%input: tensor<29x12x32x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>) -> tensor<96x29x12x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>> {
// expected-error@+1 {{expected no-op permutation on innermost dimension for block scaled input}}
%transpose = tosa.transpose %input { perms = array<i32: 3, 0, 1, 2> } : (tensor<29x12x32x96x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>) -> tensor<96x29x12x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>
return %transpose : tensor<96x29x12x32x!tosa.block_scaled<BLOCK_SHAPE_32:f8E8M0FNU:f6E3M2FN>>
}