Skip to content

Commit

Permalink
#0: Allow ttnn.pad to pad Tensor to an odd width in row major (#16079)
Browse files Browse the repository at this point in the history
### Ticket
#15603

### Problem description
ttnn.pad call throws an error when user attempts to pad a tensor to an
odd number of elements in width dimension

### What's changed
Remove the check, it is outdated since we resolved the underlying
constraint

### Checklist
- [x] [Post commit
CI](https://github.com/tenstorrent/tt-metal/actions/runs/12363708529)
  • Loading branch information
ayerofieiev-tt authored Dec 17, 2024
1 parent 60f2d28 commit bbce2c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/ttnn/unit_tests/operations/test_pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
@pytest.mark.parametrize("w", [224])
@pytest.mark.parametrize(
"padding,torch_padding",
[(((0, 1), (3, 25), (32, 32)), (32, 32, 3, 25, 0, 1)), (((0, 1), (3, 25), (4, 6)), (4, 6, 3, 25, 0, 1))],
[
(((0, 1), (3, 25), (32, 32)), (32, 32, 3, 25, 0, 1)),
(((0, 1), (3, 25), (4, 6)), (4, 6, 3, 25, 0, 1)),
(((0, 1), (3, 25), (4, 7)), (4, 7, 3, 25, 0, 1)), # Odd padding widths (5 and 7)
],
)
@pytest.mark.parametrize("value", [0])
def test_pad_rm(device, n, c, h, w, padding, torch_padding, value):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void Pad::validate_with_output_tensors(
input_tensor.get_dtype() == DataType::FLOAT32 || input_tensor.get_dtype() == DataType::BFLOAT16,
"Cannot pad tilized tensor with specified format");
} else if (input_tensor.get_layout() == Layout::ROW_MAJOR) {
TT_FATAL(this->output_tensor_shape[3] % 2 == 0, "RM padding requires output X dim to be a multiple of 2");
TT_FATAL(
input_tensor.get_dtype() == DataType::FLOAT32 || input_tensor.get_dtype() == DataType::BFLOAT16,
"Cannot pad RM tensor with specified format");
Expand Down

0 comments on commit bbce2c3

Please sign in to comment.