blob: ad4e72d927b50506d46c8e2c1816f57917c00613 [file] [log] [blame]
Jakub Kuderskic6c713c2023-04-21 18:36:38 -04001func.func @broadcast_2D_3D() {
2 %input = util.unfoldable_constant dense<[[1, 2, 3, 4],
3 [5, 6, 7, 8]]> : tensor<2x4xi32>
Jacques Pienaar124d5622024-01-05 12:10:39 -08004 %result = "stablehlo.broadcast"(%input) {broadcast_sizes = array<i64: 3>} : (tensor<2x4xi32>) -> tensor<3x2x4xi32>
Jakub Kuderskic6c713c2023-04-21 18:36:38 -04005 check.expect_eq_const(%result, dense<[
6 [[1, 2, 3, 4], [5, 6, 7, 8]],
7 [[1, 2, 3, 4], [5, 6, 7, 8]],
8 [[1, 2, 3, 4], [5, 6, 7, 8]]]> : tensor<3x2x4xi32>) : tensor<3x2x4xi32>
9 return
10}
11
12func.func @broadcast_3D_scalar() {
13 %input = util.unfoldable_constant dense<42> : tensor<i32>
Jacques Pienaar124d5622024-01-05 12:10:39 -080014 %result = "stablehlo.broadcast"(%input) {broadcast_sizes = array<i64: 3, 2, 4>} : (tensor<i32>) -> tensor<3x2x4xi32>
Jakub Kuderskic6c713c2023-04-21 18:36:38 -040015 check.expect_eq_const(%result, dense<[
16 [[42, 42, 42, 42], [42, 42, 42, 42]],
17 [[42, 42, 42, 42], [42, 42, 42, 42]],
18 [[42, 42, 42, 42], [42, 42, 42, 42]]]> : tensor<3x2x4xi32>) : tensor<3x2x4xi32>
19 return
20}