-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for uints in constant op (#1788)
Added support for unsigned ints in translation of constant op in stablehlo -> ttir and ttir -> ttnn passes. I noticed it was missing after conducting some jax tests.
- Loading branch information
1 parent
a485cf4
commit e4f3ce0
Showing
10 changed files
with
343 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,66 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | FileCheck %s | ||
module @jit_constant attributes {} { | ||
func.func public @test_splat() -> tensor<64xf32> { | ||
%0 = arith.constant dense<0.3> : tensor<64xf32> | ||
// CHECK: %[[C:.*]] = "ttir.constant"[[C:.*]] | ||
func.func public @test_scalar_float() -> tensor<f32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<3.000000e+00> : tensor<1xf32>}> : () -> tensor<1xf32> | ||
%0 = arith.constant dense<3.0> : tensor<f32> | ||
// CHECK: return %{{[0-9]+}} : tensor<1xf32> | ||
return %0 : tensor<f32> | ||
} | ||
|
||
func.func public @test_splat_float() -> tensor<64xf32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<3.000000e+00> : tensor<64xf32>}> : () -> tensor<64xf32> | ||
%0 = arith.constant dense<3.0> : tensor<64xf32> | ||
// CHECK: return %{{[0-9]+}} : tensor<64xf32> | ||
return %0 : tensor<64xf32> | ||
} | ||
|
||
func.func public @test_multiple() -> tensor<2x2xf32> { | ||
func.func public @test_multiple_float() -> tensor<2x2xf32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<{{([[])}}[0.000000e+00, 1.000000e+00], [2.000000e+00, 3.000000e+00]]> : tensor<2x2xf32>}> : () -> tensor<2x2xf32> | ||
%0 = arith.constant dense<[[0.0, 1.0], [2.0, 3.0]]> : tensor<2x2xf32> | ||
// CHECK: %[[C:.*]] = "ttir.constant"[[C:.*]] | ||
// CHECK: return %{{[0-9]+}} : tensor<2x2xf32> | ||
return %0 : tensor<2x2xf32> | ||
} | ||
|
||
func.func public @test_scalar_int() -> tensor<i32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<3> : tensor<1xi32>}> : () -> tensor<1xi32> | ||
%0 = arith.constant dense<3> : tensor<i32> | ||
// CHECK: return %{{[0-9]+}} : tensor<1xi32> | ||
return %0 : tensor<i32> | ||
} | ||
|
||
func.func public @test_splat_int() -> tensor<64xi32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<3> : tensor<64xi32>}> : () -> tensor<64xi32> | ||
%0 = arith.constant dense<3> : tensor<64xi32> | ||
// CHECK: return %{{[0-9]+}} : tensor<64xi32> | ||
return %0 : tensor<64xi32> | ||
} | ||
|
||
func.func public @test_multiple_int() -> tensor<2x2xi32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<{{([[])}}[0, 1], [2, 3]]> : tensor<2x2xi32>}> : () -> tensor<2x2xi32> | ||
%0 = arith.constant dense<[[0, 1], [2, 3]]> : tensor<2x2xi32> | ||
// CHECK: return %{{[0-9]+}} : tensor<2x2xi32> | ||
return %0 : tensor<2x2xi32> | ||
} | ||
|
||
func.func public @test_scalar_uint() -> tensor<ui32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<3> : tensor<1xui32>}> : () -> tensor<1xui32> | ||
%0 = arith.constant dense<3> : tensor<ui32> | ||
// CHECK: return %{{[0-9]+}} : tensor<1xui32> | ||
return %0 : tensor<ui32> | ||
} | ||
|
||
func.func public @test_splat_uint() -> tensor<64xui32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<3> : tensor<64xui32>}> : () -> tensor<64xui32> | ||
%0 = arith.constant dense<3> : tensor<64xui32> | ||
// CHECK: return %{{[0-9]+}} : tensor<64xui32> | ||
return %0 : tensor<64xui32> | ||
} | ||
|
||
func.func public @test_multiple_uint() -> tensor<2x2xui32> { | ||
// CHECK: %{{[0-9]+}} = "ttir.constant"() <{value = dense<{{([[])}}[0, 1], [2, 3]]> : tensor<2x2xui32>}> : () -> tensor<2x2xui32> | ||
%0 = arith.constant dense<[[0, 1], [2, 3]]> : tensor<2x2xui32> | ||
// CHECK: return %{{[0-9]+}} : tensor<2x2xui32> | ||
return %0 : tensor<2x2xui32> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: rm -rf %t.ttnn | ||
// RUN: rm -rf %t.mlir | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | \ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="system-desc-path=%system_desc_path%" > %t.mlir | ||
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn | ||
// RUN: FileCheck --input-file=%t.mlir %s | ||
|
||
module @jit_constant attributes {} { | ||
func.func public @test_uint16_scalar() -> tensor<ui16> { | ||
// CHECK-LABEL: func.func public @test_uint16_scalar | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: fillValue = 3.000000e+00 : f32 | ||
// CHECK-SAME: -> tensor<1xui16 | ||
%0 = stablehlo.constant dense<3> : tensor<ui16> | ||
return %0 : tensor<ui16> | ||
} | ||
|
||
func.func public @test_uint16_scalar_empty() -> tensor<ui16> { | ||
// CHECK-LABEL: func.func public @test_uint16_scalar_empty | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: -> tensor<1xui16 | ||
%0 = stablehlo.constant dense<0> : tensor<ui16> | ||
return %0 : tensor<ui16> | ||
} | ||
|
||
func.func public @test_uint16_empty() -> tensor<64x128xui16> { | ||
// CHECK-LABEL: func.func public @test_uint16_empty | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: -> tensor<64x128xui16 | ||
%0 = stablehlo.constant dense<0> : tensor<64x128xui16> | ||
return %0 : tensor<64x128xui16> | ||
} | ||
|
||
func.func public @test_uint16_splat() -> tensor<64x128xui16> { | ||
// CHECK-LABEL: func.func public @test_uint16_splat | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: fillValue = 3.000000e+00 : f32 | ||
// CHECK-SAME: -> tensor<64x128xui16 | ||
%0 = stablehlo.constant dense<3> : tensor<64x128xui16> | ||
return %0 : tensor<64x128xui16> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// REQUIRES: stablehlo | ||
// RUN: rm -rf %t.ttnn | ||
// RUN: rm -rf %t.mlir | ||
// RUN: ttmlir-opt --stablehlo-to-ttir-pipeline %s | \ | ||
// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="system-desc-path=%system_desc_path%" > %t.mlir | ||
// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn | ||
// RUN: FileCheck --input-file=%t.mlir %s | ||
|
||
module @jit_constant attributes {} { | ||
func.func public @test_uint32_scalar() -> tensor<ui32> { | ||
// CHECK-LABEL: func.func public @test_uint32_scalar | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: fillValue = 3.000000e+00 : f32 | ||
// CHECK-SAME: -> tensor<1xui32 | ||
%0 = stablehlo.constant dense<3> : tensor<ui32> | ||
return %0 : tensor<ui32> | ||
} | ||
|
||
func.func public @test_uint32_scalar_empty() -> tensor<ui32> { | ||
// CHECK-LABEL: func.func public @test_uint32_scalar_empty | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: -> tensor<1xui32 | ||
%0 = stablehlo.constant dense<0> : tensor<ui32> | ||
return %0 : tensor<ui32> | ||
} | ||
|
||
func.func public @test_uint32_empty() -> tensor<64x128xui32> { | ||
// CHECK-LABEL: func.func public @test_uint32_empty | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: -> tensor<64x128xui32 | ||
%0 = stablehlo.constant dense<0> : tensor<64x128xui32> | ||
return %0 : tensor<64x128xui32> | ||
} | ||
|
||
func.func public @test_uint32_splat() -> tensor<64x128xui32> { | ||
// CHECK-LABEL: func.func public @test_uint32_splat | ||
// CHECK: ttnn.full | ||
// CHECK-SAME: fillValue = 3.000000e+00 : f32 | ||
// CHECK-SAME: -> tensor<64x128xui32 | ||
%0 = stablehlo.constant dense<3> : tensor<64x128xui32> | ||
return %0 : tensor<64x128xui32> | ||
} | ||
} |
Oops, something went wrong.