Skip to content

Commit

Permalink
#0: Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sankarmanoj-tt committed Feb 6, 2025
1 parent b285a9d commit 62b6161
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions tests/ttnn/unit_tests/operations/test_new_conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ def run_conv(
)
if config_override and "act_block_h" in config_override and not auto_shard:
conv_config.act_block_h_override = config_override["act_block_h"]
if fp32_accum and packer_l1_acc and output_layout == ttnn.ROW_MAJOR_LAYOUT:
conv_config.output_layout = ttnn.TILE_LAYOUT
logger.warning(
"Forcing output_layout to TILE when act_block_h_override, fp32_accum and packer_l1_acc are enabled"
)

if config_override and "act_block_w_div" in config_override and not auto_shard:
conv_config.act_block_w_div = config_override["act_block_w_div"]
Expand All @@ -153,7 +158,6 @@ def run_conv(
if config_override["num_cores_nhw"] == 98:
conv_config.core_grid = ttnn.CoreRangeSet({ttnn.CoreRange((0, 0), (11, 7)), ttnn.CoreRange((0, 8), (1, 8))})
conv_config.override_sharding_config = True
print("Setting num_cores_nhw to 98")

[tt_output_tensor_on_device, [out_height, out_width], [weights_device, bias_device]] = ttnn.conv2d(
input_tensor=tt_input_tensor,
Expand All @@ -178,7 +182,8 @@ def run_conv(
return_weights_and_bias=True,
return_output_dim=True,
)

# import numpy as np
# np.save("ref.npy",weights_device.cpu().to_torch().numpy())
tt_output_tensor = ttnn.from_device(tt_output_tensor_on_device)
torch_output_tensor = ttnn.to_torch(tt_output_tensor, mesh_composer=output_mesh_composer)

Expand Down Expand Up @@ -1336,8 +1341,6 @@ def test_sd_conv(
(2, 320, 320, 64, 64, 3, 3, 1, 1, 1, 1, False, {"act_block_h": 64}),
(2, 320, 320, 64, 64, 3, 3, 2, 2, 1, 1, False, None), # fits with bfloat8_b
(2, 640, 640, 32, 32, 3, 3, 1, 1, 1, 1, False, {"act_block_h": 32}),
(2, 640, 640, 32, 32, 3, 3, 2, 2, 1, 1, False, None), # bfloat16 doesnt fit
(2, 1280, 1280, 16, 16, 3, 3, 1, 1, 1, 1, False, None), # bfloat16 doesnt fit
(2, 1280, 1280, 16, 16, 3, 3, 2, 2, 1, 1, False, {"act_block_h": 32}), # bfloat16 doesnt fit
(2, 1280, 1280, 8, 8, 3, 3, 1, 1, 1, 1, False, {"act_block_h": 32}),
(2, 1280, 1280, 32, 32, 3, 3, 1, 1, 1, 1, False, {"act_block_h": 32}), # bfloat16 doesnt fit
Expand All @@ -1362,7 +1365,7 @@ def test_sd_conv(
)
@pytest.mark.parametrize(
"activations_dtype",
[ttnn.bfloat16, ttnn.bfloat8_b],
[ttnn.bfloat16],
)
@pytest.mark.parametrize(
"fp32_accum",
Expand All @@ -1372,7 +1375,6 @@ def test_sd_conv(
],
)
@pytest.mark.parametrize("math_fidelity", [ttnn.MathFidelity.LoFi])
@pytest.mark.parametrize("enable_auto_formatting", [True, False])
def test_sd_conv_wh(
device,
use_program_cache,
Expand All @@ -1393,7 +1395,6 @@ def test_sd_conv_wh(
pad_w,
use_1d_systolic_array,
config_override,
enable_auto_formatting,
):
if device.core_grid.y == 7:
pytest.skip("This test is not supported for N300")
Expand All @@ -1407,14 +1408,11 @@ def test_sd_conv_wh(
and input_height == 32
and activations_dtype == ttnn.bfloat16
and weights_dtype == ttnn.bfloat16
and enable_auto_formatting == False
)
):
pytest.skip("Skip the test cases raising OOM but not affecting e2e test")

if filter_height > 1 and (input_channels > 1280 or (input_channels > 640 and input_height > 16)):
if enable_auto_formatting:
pytest.skip("Not running split SD conv with auto formatting")
run_conv_with_split(
device,
math_fidelity,
Expand Down Expand Up @@ -1458,7 +1456,6 @@ def test_sd_conv_wh(
config_override,
use_shallow_conv_variant=(input_channels == 16),
transpose_mcast=use_1d_systolic_array, ## use RM (transpose_mcast=False) with 2D on WH
enable_auto_formatting=enable_auto_formatting,
padded_input_channels=16 if input_channels == 16 else None,
fp32_accum=fp32_accum,
packer_l1_acc=True,
Expand Down
2 changes: 1 addition & 1 deletion ttnn/cpp/ttnn/operations/conv/conv2d/conv2d_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool check_non_tile_mul_width(
auto elem_size = conv_config.weights_dtype == DataType::BFLOAT8_B ? 1 : 2;
bool is_non_tile_mul_width =
(conv_config.shard_layout.has_value() && conv_config.shard_layout == TensorMemoryLayout::BLOCK_SHARDED) &&
conv_config.act_block_h_override == 0 &&
// conv_config.act_block_h_override == 0 &&
(conv_config.weights_dtype == DataType::BFLOAT8_B || conv_config.weights_dtype == DataType::BFLOAT16) &&
conv_config.output_layout == Layout::ROW_MAJOR && ((elem_size * in_channels) % (16 * num_cores_c)) == 0;
return is_non_tile_mul_width;
Expand Down

0 comments on commit 62b6161

Please sign in to comment.