Jakub Kuderski | c6c713c | 2023-04-21 18:36:38 -0400 | [diff] [blame] | 1 | func.func @broadcast_2D_3D() { |
| 2 | %input = util.unfoldable_constant dense<[[1, 2, 3, 4], |
| 3 | [5, 6, 7, 8]]> : tensor<2x4xi32> |
Jacques Pienaar | 124d562 | 2024-01-05 12:10:39 -0800 | [diff] [blame] | 4 | %result = "stablehlo.broadcast"(%input) {broadcast_sizes = array<i64: 3>} : (tensor<2x4xi32>) -> tensor<3x2x4xi32> |
Jakub Kuderski | c6c713c | 2023-04-21 18:36:38 -0400 | [diff] [blame] | 5 | 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 | |
| 12 | func.func @broadcast_3D_scalar() { |
| 13 | %input = util.unfoldable_constant dense<42> : tensor<i32> |
Jacques Pienaar | 124d562 | 2024-01-05 12:10:39 -0800 | [diff] [blame] | 14 | %result = "stablehlo.broadcast"(%input) {broadcast_sizes = array<i64: 3, 2, 4>} : (tensor<i32>) -> tensor<3x2x4xi32> |
Jakub Kuderski | c6c713c | 2023-04-21 18:36:38 -0400 | [diff] [blame] | 15 | 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 | } |