diff --git a/docs/source/ttnn/ttnn/dependencies/tt_lib.rst b/docs/source/ttnn/ttnn/dependencies/tt_lib.rst index 69e74080e58..f37a6405946 100644 --- a/docs/source/ttnn/ttnn/dependencies/tt_lib.rst +++ b/docs/source/ttnn/ttnn/dependencies/tt_lib.rst @@ -34,7 +34,7 @@ New Device Operation struct { void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; @@ -48,7 +48,7 @@ New Device Operation with a member int some_member void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; @@ -61,7 +61,7 @@ New Device Operation with Optional Input Tensors struct { void validate(const std::vector &input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, @@ -80,7 +80,7 @@ and create_output_tensors with the additional parameter for the output_tensors. struct { void validate_with_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector> create_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithOptionalOutputTensors create_program(const std::vector& input_tensors, std::vector> &output_tensors) const; diff --git a/tests/tt_eager/integration_tests/test_bert.cpp b/tests/tt_eager/integration_tests/test_bert.cpp index 76730fd3adf..fa3788b24a4 100644 --- a/tests/tt_eager/integration_tests/test_bert.cpp +++ b/tests/tt_eager/integration_tests/test_bert.cpp @@ -253,7 +253,7 @@ void test_bert() { "qa_head_bias", ttnn::reshape( tt::numpy::random::uniform(bfloat16(-1.0f), bfloat16(1.0f), {1, 1, TILE_HEIGHT, TILE_WIDTH}, Layout::TILE).to(device, dram_memory_config), - ttnn::Shape{tt::tt_metal::Shape{{1, 1, 1, TILE_WIDTH}, {1, 1, TILE_HEIGHT, TILE_WIDTH}}})); + ttnn::Shape{tt::tt_metal::LegacyShape{{1, 1, 1, TILE_WIDTH}, {1, 1, TILE_HEIGHT, TILE_WIDTH}}})); auto run_bert = [&]() { tt::log_debug(tt::LogTest, "run_bert started"); diff --git a/tests/tt_eager/ops/test_average_pool.cpp b/tests/tt_eager/ops/test_average_pool.cpp index 18b5672c735..f0bcae7fe08 100644 --- a/tests/tt_eager/ops/test_average_pool.cpp +++ b/tests/tt_eager/ops/test_average_pool.cpp @@ -13,9 +13,9 @@ using tt::tt_metal::Device; using tt::tt_metal::Tensor; using tt::tt_metal::DataType; using tt::tt_metal::Layout; -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; -Tensor run_avg_pool_2d_resnet(Shape& tensor_shape, Device* device) { +Tensor run_avg_pool_2d_resnet(tt::tt_metal::LegacyShape& tensor_shape, Device* device) { using ttnn::operations::experimental::auto_format::AutoFormat; auto input_tensor = tt::numpy::random::random(tensor_shape, DataType::BFLOAT16); auto padded_input_shape = AutoFormat::pad_to_tile_shape(tensor_shape, false, false); @@ -31,11 +31,11 @@ int main () { int device_id = 0; auto device = tt::tt_metal::CreateDevice(device_id); - Shape resnet18_shape = {1, 1, 7 * 7, 2048}; + tt::tt_metal::LegacyShape resnet18_shape = {1, 1, 7 * 7, 2048}; auto result = run_avg_pool_2d_resnet(resnet18_shape, device); - TT_FATAL(result.get_legacy_shape() == Shape({1, 1, tt::constants::TILE_HEIGHT, 2048}), "Incorrect shape {}.", result.get_legacy_shape()); - TT_FATAL(result.get_legacy_shape().without_padding() == Shape({1, 1, 1, 2048}), "Incorrect shape {}.", result.get_legacy_shape().without_padding()); + TT_FATAL(result.get_legacy_shape() == tt::tt_metal::LegacyShape({1, 1, tt::constants::TILE_HEIGHT, 2048}), "Incorrect shape {}.", result.get_legacy_shape()); + TT_FATAL(result.get_legacy_shape().without_padding() == tt::tt_metal::LegacyShape({1, 1, 1, 2048}), "Incorrect shape {}.", result.get_legacy_shape().without_padding()); TT_FATAL(tt::tt_metal::CloseDevice(device), "Error"); return 0; diff --git a/tests/tt_eager/ops/test_bcast_op.cpp b/tests/tt_eager/ops/test_bcast_op.cpp index 3b919bfa542..4fed1d14fb9 100644 --- a/tests/tt_eager/ops/test_bcast_op.cpp +++ b/tests/tt_eager/ops/test_bcast_op.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - auto shapes = std::vector{{1, 1, TILE_HEIGHT, TILE_WIDTH}, {1, 1, TILE_HEIGHT * 2, TILE_WIDTH * 2}, {1, 1, TILE_HEIGHT * 3, TILE_WIDTH * 4}}; + auto shapes = std::vector{{1, 1, TILE_HEIGHT, TILE_WIDTH}, {1, 1, TILE_HEIGHT * 2, TILE_WIDTH * 2}, {1, 1, TILE_HEIGHT * 3, TILE_WIDTH * 4}}; auto run_operations = [&shapes, device] { for (const auto shape : shapes) { diff --git a/tests/tt_eager/ops/test_bmm_op.cpp b/tests/tt_eager/ops/test_bmm_op.cpp index 29122973dd2..051a502bac6 100644 --- a/tests/tt_eager/ops/test_bmm_op.cpp +++ b/tests/tt_eager/ops/test_bmm_op.cpp @@ -41,9 +41,9 @@ int main(int argc, char **argv) { uint32_t Kt = 2; uint32_t Nt = 4; uint32_t B = 5; - Shape shapea = {B, 1, Mt*TILE_HEIGHT, Kt*TILE_WIDTH}; - Shape shapeb = {B, 1, Kt*TILE_HEIGHT, Nt*TILE_WIDTH}; - Shape shapeb1 = {1, 1, Kt*TILE_HEIGHT, Nt*TILE_WIDTH}; + tt::tt_metal::LegacyShape shapea = {B, 1, Mt*TILE_HEIGHT, Kt*TILE_WIDTH}; + tt::tt_metal::LegacyShape shapeb = {B, 1, Kt*TILE_HEIGHT, Nt*TILE_WIDTH}; + tt::tt_metal::LegacyShape shapeb1 = {1, 1, Kt*TILE_HEIGHT, Nt*TILE_WIDTH}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shapea).to(Layout::TILE).to(device); diff --git a/tests/tt_eager/ops/test_eltwise_binary_op.cpp b/tests/tt_eager/ops/test_eltwise_binary_op.cpp index 4de38f4d79b..f0217a5e9ff 100644 --- a/tests/tt_eager/ops/test_eltwise_binary_op.cpp +++ b/tests/tt_eager/ops/test_eltwise_binary_op.cpp @@ -14,7 +14,7 @@ using tt::tt_metal::Device; using tt::tt_metal::Layout; using tt::tt_metal::Tensor; using tt::tt_metal::OwnedStorage; -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; template Tensor host_function(const Tensor& input_tensor_a, const Tensor& input_tensor_b) { @@ -31,7 +31,7 @@ Tensor host_function(const Tensor& input_tensor_a, const Tensor& input_tensor_b) } template -bool run_test(const Shape& shape, const DeviceFunction& device_function, Device* device, Args... args) { +bool run_test(const tt::tt_metal::LegacyShape& shape, const DeviceFunction& device_function, Device* device, Args... args) { auto input_tensor_a = tt::numpy::random::random(shape, DataType::BFLOAT16); auto input_tensor_b = tt::numpy::random::random(shape, DataType::BFLOAT16); @@ -51,51 +51,51 @@ int main() { { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; auto allclose = run_test>>(shape, ttnn::add, device); TT_FATAL(allclose, "Error"); } { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; auto allclose = run_test>>(shape, ttnn::subtract, device); TT_FATAL(allclose, "Error"); } { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; auto allclose = run_test>>(shape, ttnn::multiply, device, 1e-2f, 1e-3f); TT_FATAL(allclose, "Error"); } auto run_binary_ops = [&] { { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; auto allclose = run_test>>(shape, ttnn::add, device); TT_FATAL(allclose, "Error"); } { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; auto allclose = run_test>>(shape, ttnn::subtract, device); TT_FATAL(allclose, "Error"); } { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT * 2, tt::constants::TILE_WIDTH * 2}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT * 2, tt::constants::TILE_WIDTH * 2}; auto allclose = run_test>>(shape, ttnn::add, device); TT_FATAL(allclose, "Error"); } { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; auto allclose = run_test>>(shape, ttnn::multiply, device, 1e-2f, 1e-3f); TT_FATAL(allclose, "Error"); } { - Shape shape = {1, 1, tt::constants::TILE_HEIGHT * 4, tt::constants::TILE_WIDTH * 4}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT * 4, tt::constants::TILE_WIDTH * 4}; auto allclose = run_test>>(shape, ttnn::add, device); TT_FATAL(allclose, "Error"); } diff --git a/tests/tt_eager/ops/test_eltwise_unary_op.cpp b/tests/tt_eager/ops/test_eltwise_unary_op.cpp index a9eef9d94c1..0281ec7d3b6 100644 --- a/tests/tt_eager/ops/test_eltwise_unary_op.cpp +++ b/tests/tt_eager/ops/test_eltwise_unary_op.cpp @@ -20,7 +20,7 @@ using tt::tt_metal::Device; using tt::tt_metal::Layout; using tt::tt_metal::OwnedStorage; -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; using tt::tt_metal::Tensor; namespace detail { @@ -57,7 +57,7 @@ Tensor host_function(const Tensor& input_tensor) { } template -bool run_test(Device* device, const Shape& shape, float low, float high, Args... args) { +bool run_test(Device* device, const tt::tt_metal::LegacyShape& shape, float low, float high, Args... args) { auto input_tensor = tt::numpy::random::uniform(bfloat16(low), bfloat16(high), shape).to(Layout::TILE); using ttnn::operations::unary::UnaryWithParam; @@ -110,7 +110,7 @@ void test_operation_infrastructure() { int device_id = 0; auto device = tt::tt_metal::CreateDevice(device_id); - auto shape = Shape{1, 1, TILE_HEIGHT, TILE_WIDTH}; + auto shape = tt::tt_metal::LegacyShape{1, 1, TILE_HEIGHT, TILE_WIDTH}; auto input_tensor = tt::numpy::random::uniform(bfloat16(0), bfloat16(1), shape).to(Layout::TILE).to(device); ttnn::operations::unary::operation_attributes_t op_args { @@ -149,8 +149,9 @@ void test_shape_padding() { output_tensor = output_tensor.cpu(); auto output_shape = output_tensor.get_legacy_shape(); - TT_FATAL(output_shape == tt::tt_metal::Shape(padded_input_shape), "Error"); - TT_FATAL(output_shape.without_padding() == tt::tt_metal::Shape(input_shape), "Error"); + + TT_FATAL(output_shape == tt::tt_metal::LegacyShape(padded_input_shape), "Error"); + TT_FATAL(output_shape.without_padding() == tt::tt_metal::LegacyShape(input_shape), "Error"); TT_FATAL(tt::tt_metal::CloseDevice(device), "Error"); } @@ -177,7 +178,7 @@ void test_numerically() { int device_id = 0; auto device = tt::tt_metal::CreateDevice(device_id); - auto shape = Shape{1, 1, TILE_HEIGHT, TILE_WIDTH}; + auto shape = tt::tt_metal::LegacyShape{1, 1, TILE_HEIGHT, TILE_WIDTH}; { auto allclose = run_test(device, shape, 0.0f, 1.0f, 1e-1f, 1e-5f); TT_FATAL(allclose, "Error"); diff --git a/tests/tt_eager/ops/test_fold_op.cpp b/tests/tt_eager/ops/test_fold_op.cpp index e81fdf19ff9..d285450f631 100644 --- a/tests/tt_eager/ops/test_fold_op.cpp +++ b/tests/tt_eager/ops/test_fold_op.cpp @@ -15,7 +15,7 @@ using namespace tt; using namespace tt::tt_metal; using namespace constants; -void run_fold(Device *device, Shape shape) { +void run_fold(Device *device, tt::tt_metal::LegacyShape shape) { Tensor input_tensor = tt::numpy::random::random(shape).to(Layout::ROW_MAJOR).to(device); uint32_t stride_h = 2; uint32_t stride_w = 2; diff --git a/tests/tt_eager/ops/test_layernorm_op.cpp b/tests/tt_eager/ops/test_layernorm_op.cpp index b5595681205..e3d8d050380 100644 --- a/tests/tt_eager/ops/test_layernorm_op.cpp +++ b/tests/tt_eager/ops/test_layernorm_op.cpp @@ -29,7 +29,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// int device_id = 0; tt_metal::Device *device = tt_metal::CreateDevice(device_id); - Shape shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; Tensor a = tt::numpy::random::random(shape).to(Layout::TILE).to(device); Tensor c = ttnn::layer_norm(a, 1e-4f); Tensor d = c.cpu(); diff --git a/tests/tt_eager/ops/test_pad_op.cpp b/tests/tt_eager/ops/test_pad_op.cpp index a8357d43668..143d77f4843 100644 --- a/tests/tt_eager/ops/test_pad_op.cpp +++ b/tests/tt_eager/ops/test_pad_op.cpp @@ -32,8 +32,9 @@ void test_operation_infrastructure() { auto output_tensor = ttnn::pad(input_tensor, padded_shape, tt::tt_metal::Array4D({0, 0, 0, 0}), 0); auto output_shape = output_tensor.get_legacy_shape(); - TT_FATAL(output_shape == tt::tt_metal::Shape(padded_shape), "Error"); - TT_FATAL(output_shape.without_padding() == tt::tt_metal::Shape(input_shape), "Error"); + + TT_FATAL(output_shape == tt::tt_metal::LegacyShape(padded_shape), "Error"); + TT_FATAL(output_shape.without_padding() == tt::tt_metal::LegacyShape(input_shape), "Error"); } int main(int argc, char** argv) { diff --git a/tests/tt_eager/ops/test_sliding_window_ops.cpp b/tests/tt_eager/ops/test_sliding_window_ops.cpp index 23cb93c71f6..9c5e165d7dd 100644 --- a/tests/tt_eager/ops/test_sliding_window_ops.cpp +++ b/tests/tt_eager/ops/test_sliding_window_ops.cpp @@ -14,7 +14,7 @@ #include "ttnn/deprecated/tt_numpy/functions.hpp" #include "ttnn/tensor/types.hpp" -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; using tt::tt_metal::Tensor; using namespace ttnn::operations::sliding_window; @@ -370,12 +370,12 @@ int main() { .pad_hw = {tc.pad_h, tc.pad_w}, .dilation_hw = {1, 1}, .num_cores_nhw = tc.num_cores_nhw}; - Shape input_tensor_shape = { + tt::tt_metal::LegacyShape input_tensor_shape = { config.batch_size, config.input_hw.first + 2 * config.pad_hw.first, config.input_hw.second + 2 * config.pad_hw.second}; - Shape output_tensor_shape = config.get_output_shape().value; - Shape filter_tensor_shape = {config.window_hw.first, config.window_hw.second}; + tt::tt_metal::LegacyShape output_tensor_shape = config.get_output_shape().value; + tt::tt_metal::LegacyShape filter_tensor_shape = {config.window_hw.first, config.window_hw.second}; Tensor input_padded_tensor = tt::numpy::random::random(input_tensor_shape, DataType::BFLOAT16).to(Layout::ROW_MAJOR).cpu(); @@ -387,12 +387,12 @@ int main() { vector filter_vector = create_filter_vec(filter_tensor_buf, tc.filter_h, tc.filter_w); owned_buffer::Buffer out_golden_tensor_buf = ref_conv_op( input_padded_tensor, - ttnn::types::Shape(input_tensor_shape), + ttnn::Shape(input_tensor_shape), tc.stride_h, tc.stride_w, filter_vector, - ttnn::types::Shape(filter_tensor_shape), - ttnn::types::Shape(output_tensor_shape)); + ttnn::Shape(filter_tensor_shape), + ttnn::Shape(output_tensor_shape)); auto failed_tests = validate_generate_functions( device, diff --git a/tests/tt_eager/ops/test_softmax_op.cpp b/tests/tt_eager/ops/test_softmax_op.cpp index 90f1911ca42..7d0eed9cc16 100644 --- a/tests/tt_eager/ops/test_softmax_op.cpp +++ b/tests/tt_eager/ops/test_softmax_op.cpp @@ -15,7 +15,7 @@ using namespace tt; using namespace tt::tt_metal; using namespace constants; -void run_softmax(Device* device, Shape shape) { +void run_softmax(Device* device, tt::tt_metal::LegacyShape shape) { Tensor input_tensor = tt::numpy::random::random(shape).to(Layout::TILE).to(device); Tensor device_output_tensor = ttnn::softmax_in_place(input_tensor); Tensor output_tensor = device_output_tensor.cpu(); diff --git a/tests/tt_eager/ops/test_tilize_op.cpp b/tests/tt_eager/ops/test_tilize_op.cpp index 1f57617f18d..c9a09ef762b 100644 --- a/tests/tt_eager/ops/test_tilize_op.cpp +++ b/tests/tt_eager/ops/test_tilize_op.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 64, 32, 64}; + tt::tt_metal::LegacyShape shape = {1, 64, 32, 64}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shape).to(device); Tensor b = ttnn::tilize(a); diff --git a/tests/tt_eager/ops/test_tilize_op_channels_last.cpp b/tests/tt_eager/ops/test_tilize_op_channels_last.cpp index b82b9659c91..d09379d4047 100644 --- a/tests/tt_eager/ops/test_tilize_op_channels_last.cpp +++ b/tests/tt_eager/ops/test_tilize_op_channels_last.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 32, 32, 64}; + tt::tt_metal::LegacyShape shape = {1, 32, 32, 64}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shape).to(device); Tensor b = ttnn::tilize(a); diff --git a/tests/tt_eager/ops/test_tilize_zero_padding.cpp b/tests/tt_eager/ops/test_tilize_zero_padding.cpp index 1792889ee2b..73e85d4c1e1 100644 --- a/tests/tt_eager/ops/test_tilize_zero_padding.cpp +++ b/tests/tt_eager/ops/test_tilize_zero_padding.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 32, 45, 64}; + tt::tt_metal::LegacyShape shape = {1, 32, 45, 64}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shape).to(device); Tensor b = ttnn::tilize_with_zero_padding(a); diff --git a/tests/tt_eager/ops/test_tilize_zero_padding_channels_last.cpp b/tests/tt_eager/ops/test_tilize_zero_padding_channels_last.cpp index 31ddbe429be..0879da3725b 100644 --- a/tests/tt_eager/ops/test_tilize_zero_padding_channels_last.cpp +++ b/tests/tt_eager/ops/test_tilize_zero_padding_channels_last.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 32, 61, 32}; + tt::tt_metal::LegacyShape shape = {1, 32, 61, 32}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::arange(0, tt_metal::compute_volume(shape), 1).reshape(shape).to(device); Tensor b = ttnn::tilize_with_zero_padding(a); diff --git a/tests/tt_eager/ops/test_transpose_op.cpp b/tests/tt_eager/ops/test_transpose_op.cpp index 82948c3e0f4..b0c6993736e 100644 --- a/tests/tt_eager/ops/test_transpose_op.cpp +++ b/tests/tt_eager/ops/test_transpose_op.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shape).to(Layout::TILE).to(device); diff --git a/tests/tt_eager/ops/test_transpose_wh_multi_core.cpp b/tests/tt_eager/ops/test_transpose_wh_multi_core.cpp index f55fe92c920..c07c6db1b9c 100644 --- a/tests/tt_eager/ops/test_transpose_wh_multi_core.cpp +++ b/tests/tt_eager/ops/test_transpose_wh_multi_core.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 1, 10*TILE_HEIGHT, 12*TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, 10*TILE_HEIGHT, 12*TILE_WIDTH}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shape).to(Layout::TILE).to(device); diff --git a/tests/tt_eager/ops/test_transpose_wh_single_core.cpp b/tests/tt_eager/ops/test_transpose_wh_single_core.cpp index f55fe92c920..c07c6db1b9c 100644 --- a/tests/tt_eager/ops/test_transpose_wh_single_core.cpp +++ b/tests/tt_eager/ops/test_transpose_wh_single_core.cpp @@ -77,7 +77,7 @@ int main(int argc, char **argv) { //////////////////////////////////////////////////////////////////////////// // Application Setup //////////////////////////////////////////////////////////////////////////// - Shape shape = {1, 1, 10*TILE_HEIGHT, 12*TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, 10*TILE_HEIGHT, 12*TILE_WIDTH}; // Allocates a DRAM buffer on device populated with values specified by initialize Tensor a = tt::numpy::random::random(shape).to(Layout::TILE).to(device); diff --git a/tests/tt_eager/tensors/test_async_tensor_apis.cpp b/tests/tt_eager/tensors/test_async_tensor_apis.cpp index ffa2c612b40..20dce0e4ad7 100644 --- a/tests/tt_eager/tensors/test_async_tensor_apis.cpp +++ b/tests/tt_eager/tensors/test_async_tensor_apis.cpp @@ -99,7 +99,7 @@ TEST_F(CommonFixture, TestTensorOwnershipSanity) { readback_tensor.get_storage()); EXPECT_EQ(readback_tensor.get_dtype(), DataType::FLOAT32); EXPECT_EQ(readback_tensor.get_layout(), Layout::ROW_MAJOR); - EXPECT_EQ(readback_tensor.get_shape(), ttnn::Shape(Shape({1, 1, 32, 128}))); + EXPECT_EQ(readback_tensor.get_shape(), ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 32, 128}))); } TEST_F(CommonFixture, TestAsyncEltwiseBinary) { @@ -115,15 +115,15 @@ TEST_F(CommonFixture, TestAsyncEltwiseBinary) { for (int i = 0; i < 5; i++) { // Initialize tensors and move them to DRAM Tensor input_tensor_a = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16, Layout::TILE).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16, Layout::TILE).to(device); Tensor input_tensor_b = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16, Layout::TILE).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16, Layout::TILE).to(device); Tensor input_tensor_c = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16, Layout::TILE).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16, Layout::TILE).to(device); Tensor output_tensor_device = ttnn::multiply(ttnn::add(input_tensor_a, input_tensor_b), input_tensor_c); Tensor output_tensor_device_2 = ttnn::neg(ttnn::subtract(output_tensor_device, input_tensor_c)); - EXPECT_EQ(output_tensor_device.get_shape(), ttnn::Shape(Shape({1, 1, 1024, 1024}))); + EXPECT_EQ(output_tensor_device.get_shape(), ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}))); EXPECT_EQ(output_tensor_device.get_dtype(), DataType::BFLOAT16); Tensor output_tensor_host = output_tensor_device_2.cpu(); @@ -168,9 +168,9 @@ TEST_F(CommonFixture, TestAsyncRefCountManager) { // Run for multiple loops to ensure deterministic behaviour with device addresses // Initialize 2 tensors on device Tensor tensor1 = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); Tensor tensor2 = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); uint32_t tensor2_device_buf_addr = tensor2.device_buffer()->address(); // Assign tensor1 to tensor2 and ensure that ref counts are appropriately updated with the buffer for tensor2 // deallocated @@ -180,14 +180,14 @@ TEST_F(CommonFixture, TestAsyncRefCountManager) { // To check if tensor2 is deallocated, create a third tensor on device and ensure that its address matches the // prev addr for tensor2 Tensor tensor3 = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); EXPECT_EQ(tensor3.device_buffer()->address(), tensor2_device_buf_addr); EXPECT_EQ(tensor1.device_buffer()->address(), tensor2.device_buffer()->address()); } log_info(LogTest, "Testing Device tensor self-assignment through function"); for (int i = 0; i < 5; i++) { Tensor device_tensor = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); uint32_t device_tensor_address = device_tensor.device_buffer()->address(); // This step will copy the tensor to a temp rval and std::move it back to the caller's instance of device_tensor // Ensure ref count and address remain unchanged @@ -199,7 +199,7 @@ TEST_F(CommonFixture, TestAsyncRefCountManager) { log_info(LogTest, "Testing Device tensor move assignment"); for (int i = 0; i < 5; i++) { Tensor tensor1 = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(i), DataType::BFLOAT16).to(device); Tensor tensor2 = std::move(tensor1); EXPECT_EQ(tensor2.tensor_attributes->main_thread_ref_count, 1); EXPECT_EQ(tensor1.tensor_attributes, nullptr); @@ -207,7 +207,7 @@ TEST_F(CommonFixture, TestAsyncRefCountManager) { log_info(LogTest, "Testing Device tensor self-assignment"); Tensor tensor_to_self_assign = - tt::numpy::full(Shape({1, 1, 1024, 1024}), static_cast(0), DataType::BFLOAT16).to(device); + tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1024, 1024}), static_cast(0), DataType::BFLOAT16).to(device); uint32_t tensor_to_self_assign_address = tensor_to_self_assign.device_buffer()->address(); tensor_to_self_assign = tensor_to_self_assign; EXPECT_EQ(tensor_to_self_assign.tensor_attributes->main_thread_ref_count, 1); @@ -227,15 +227,15 @@ TEST_F(CommonFixture, TestAsyncRefCountManager) { // // Initialize tensors and keep them on host. Since none of the tensors are divisible by tile dims, the inputs // // and outputs are on host. // Tensor input_tensor_a = -// tt::numpy::full(Shape({1, 1, 1023, 1023}), static_cast(i), DataType::BFLOAT16); +// tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1023, 1023}), static_cast(i), DataType::BFLOAT16); // Tensor input_tensor_b = -// tt::numpy::full(Shape({1, 1, 1023, 1023}), static_cast(i), DataType::BFLOAT16); +// tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1023, 1023}), static_cast(i), DataType::BFLOAT16); // Tensor input_tensor_c = -// tt::numpy::full(Shape({1, 1, 1023, 1023}), static_cast(i), DataType::BFLOAT16); +// tt::numpy::full(tt::tt_metal::LegacyShape({1, 1, 1023, 1023}), static_cast(i), DataType::BFLOAT16); // Tensor output_tensor_device = ttnn::multiply(ttnn::add(input_tensor_a, input_tensor_b), input_tensor_c); // Tensor output_tensor_device_2 = neg(ttnn::subtract(output_tensor_device, input_tensor_c)); -// EXPECT_EQ(output_tensor_device.get_shape(), ttnn::Shape(Shape({1, 1, 1023, 1023}))); +// EXPECT_EQ(output_tensor_device.get_shape(), ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1023, 1023}))); // EXPECT_EQ(output_tensor_device.get_dtype(), DataType::BFLOAT16); // Tensor output_tensor_host = output_tensor_device_2.cpu(); @@ -350,5 +350,5 @@ TEST_F(CommonFixture, TestTensorAsyncDataMovement) { readback_tensor.get_storage()); EXPECT_EQ(readback_tensor.get_dtype(), DataType::FLOAT32); EXPECT_EQ(readback_tensor.get_layout(), Layout::ROW_MAJOR); - EXPECT_EQ(readback_tensor.get_shape(), ttnn::Shape(Shape({1, 1, 32, tensor_stop / 32}))); + EXPECT_EQ(readback_tensor.get_shape(), ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 32, tensor_stop / 32}))); } diff --git a/tests/tt_eager/tensors/test_copy_and_move.cpp b/tests/tt_eager/tensors/test_copy_and_move.cpp index d24d591217e..127f07577a3 100644 --- a/tests/tt_eager/tensors/test_copy_and_move.cpp +++ b/tests/tt_eager/tensors/test_copy_and_move.cpp @@ -23,7 +23,7 @@ using namespace constants; bool test_tensor_copy_semantics(Device *device) { bool pass = true; - Shape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; // host tensor to host tensor copy constructor Tensor host_a = tt::numpy::random::random(single_tile_shape).to(Layout::TILE); @@ -82,7 +82,7 @@ bool test_tensor_copy_semantics(Device *device) { bool test_tensor_move_semantics(Device *device) { bool pass = true; - Shape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; auto random_tensor = tt::numpy::random::uniform(bfloat16(-1.0f), bfloat16(1.0f), single_tile_shape); auto bfloat_data = owned_buffer::get_as(random_tensor); @@ -149,7 +149,7 @@ bool test_tensor_move_semantics(Device *device) { bool test_tensor_deallocate_semantics(Device *device) { bool pass = true; - Shape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; MemoryConfig dram_mem_config = MemoryConfig{.memory_layout=TensorMemoryLayout::INTERLEAVED, .buffer_type=BufferType::DRAM}; MemoryConfig l1_mem_config = MemoryConfig{.memory_layout=TensorMemoryLayout::INTERLEAVED, .buffer_type=BufferType::L1}; @@ -189,7 +189,7 @@ bool test_tensor_deallocate_semantics(Device *device) { bool test_tensor_deallocate_and_close_device(Device *device) { bool pass = true; - Shape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; MemoryConfig dram_mem_config = MemoryConfig{.memory_layout = TensorMemoryLayout::INTERLEAVED, .buffer_type = BufferType::DRAM}; diff --git a/tests/tt_eager/tensors/test_host_device_loopback.cpp b/tests/tt_eager/tensors/test_host_device_loopback.cpp index 7031e9a99c5..2bf9ddddc64 100644 --- a/tests/tt_eager/tensors/test_host_device_loopback.cpp +++ b/tests/tt_eager/tensors/test_host_device_loopback.cpp @@ -20,7 +20,7 @@ using namespace constants; bool test_single_tile_single_dram_bank_loopback(Device *device) { bool pass = true; - Shape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; + tt::tt_metal::LegacyShape single_tile_shape = {1, 1, TILE_HEIGHT, TILE_WIDTH}; Tensor host_a = tt::numpy::random::random(single_tile_shape).to(Layout::TILE); Tensor device_a = host_a.to(device); @@ -34,7 +34,7 @@ bool test_single_tile_single_dram_bank_loopback(Device *device) { bool test_multi_tile_multi_dram_bank_loopback(Device *device) { bool pass = true; - Shape multi_tile_shape = {1, 1, 4*TILE_HEIGHT, 3*TILE_WIDTH}; + tt::tt_metal::LegacyShape multi_tile_shape = {1, 1, 4*TILE_HEIGHT, 3*TILE_WIDTH}; Tensor host_a = tt::numpy::random::random(multi_tile_shape).to(Layout::TILE); Tensor device_a = host_a.to(device); diff --git a/tests/tt_eager/tensors/test_raw_host_memory_pointer.cpp b/tests/tt_eager/tensors/test_raw_host_memory_pointer.cpp index 5cf9b195613..b2b92869ae4 100644 --- a/tests/tt_eager/tensors/test_raw_host_memory_pointer.cpp +++ b/tests/tt_eager/tensors/test_raw_host_memory_pointer.cpp @@ -46,10 +46,10 @@ namespace numpy { template struct ndarray { - Shape shape; + tt::tt_metal::LegacyShape shape; void* data; - ndarray(Shape shape) : shape(shape), data(malloc(tt::tt_metal::compute_volume(shape) * sizeof(DataType))) {} + ndarray(tt::tt_metal::LegacyShape shape) : shape(shape), data(malloc(tt::tt_metal::compute_volume(shape) * sizeof(DataType))) {} ~ndarray() { free(data); } std::size_t size() const { return tt::tt_metal::compute_volume(shape); } @@ -61,7 +61,7 @@ void test_raw_host_memory_pointer() { using tt::tt_metal::BorrowedStorage; using tt::tt_metal::DataType; using tt::tt_metal::OwnedStorage; - using tt::tt_metal::Shape; + using tt::tt_metal::LegacyShape; using tt::tt_metal::Tensor; using namespace tt::tt_metal::borrowed_buffer; using namespace tt::tt_metal::owned_buffer; @@ -69,7 +69,7 @@ void test_raw_host_memory_pointer() { int device_id = 0; tt::tt_metal::Device* device = tt::tt_metal::CreateDevice(device_id); - Shape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; + tt::tt_metal::LegacyShape shape = {1, 1, tt::constants::TILE_HEIGHT, tt::constants::TILE_WIDTH}; // Host tensor to print the output Tensor tensor_for_printing = Tensor( diff --git a/tests/ttnn/unit_tests/gtests/test_async_runtime.cpp b/tests/ttnn/unit_tests/gtests/test_async_runtime.cpp index dfe01e7174d..a189b1f5a92 100644 --- a/tests/ttnn/unit_tests/gtests/test_async_runtime.cpp +++ b/tests/ttnn/unit_tests/gtests/test_async_runtime.cpp @@ -31,7 +31,7 @@ TEST_F(MultiCommandQueueSingleDeviceFixture, TestAsyncPreallocatedOutputs) { uint32_t io_cq = 1; // Data reads and writes done through CQ0 uint32_t workload_dispatch_cq = 0; // Workload dispatched through CQ1 - ttnn::Shape input_shape = ttnn::Shape(Shape({1, 1, 1024, 1024})); + ttnn::Shape input_shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1024, 1024})); auto host_data = std::shared_ptr(new bfloat16[input_buf_size_datums]); auto readback_data = std::shared_ptr(new bfloat16[output_buf_size_datums]); @@ -105,7 +105,7 @@ TEST_F(MultiCommandQueueSingleDeviceFixture, TestAsyncRuntimeAllocatedBuffers) { std::vector inputs = {4, 9, 16, 25, 36, 64}; uint32_t io_cq = 1; uint32_t workload_dispatch_cq = 0; - ttnn::Shape shape = ttnn::Shape(Shape({1, 1, 1024, 1024})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1024, 1024})); auto host_data = std::shared_ptr(new bfloat16[buf_size_datums]); auto readback_data = std::shared_ptr(new bfloat16[buf_size_datums]); @@ -158,7 +158,7 @@ TEST_F(MultiCommandQueueSingleDeviceFixture, TestAsyncRuntimeBufferDestructor) { uint32_t buf_size_datums = 1024 * 1024; uint32_t datum_size_bytes = 2; - ttnn::Shape shape = ttnn::Shape(Shape({1, 1, 1024, 1024})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1024, 1024})); // Inside the loop, initialize a buffer with limited lifetime. // This will asynchronously allocate the buffer, wait for the allocation to complete (address to be assigned to the buffer), destroy the buffer (which will asynchronously // deallocate the buffer) in a loop diff --git a/tests/ttnn/unit_tests/gtests/test_ccl_on_tg.cpp b/tests/ttnn/unit_tests/gtests/test_ccl_on_tg.cpp index 0e28fe822e0..fe2b76abc96 100644 --- a/tests/ttnn/unit_tests/gtests/test_ccl_on_tg.cpp +++ b/tests/ttnn/unit_tests/gtests/test_ccl_on_tg.cpp @@ -72,7 +72,7 @@ TEST(TGTests, TestAllGatherDeadlock) { .memory_layout = tt::tt_metal::TensorMemoryLayout::INTERLEAVED, .buffer_type = BufferType::DRAM, .shard_spec = std::nullopt}; - ttnn::Shape shape = ttnn::Shape(Shape({1, 1, 32, 16384})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 32, 16384})); uint32_t buf_size_datums = 32 * 16384; uint32_t datum_size_bytes = 2; auto host_data = std::shared_ptr(new bfloat16[buf_size_datums]); @@ -123,7 +123,7 @@ TEST(TGTests, TestAllGatherDeadlock) { } // Readback data and verify correctness. for (auto& tensor : output_tensors) { - ASSERT_EQ(tensor.get_shape(), ttnn::Shape(Shape({1, 1, 32, static_cast(16384 * device_ids.size())}))); + ASSERT_EQ(tensor.get_shape(), ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 32, static_cast(16384 * device_ids.size())}))); ttnn::read_buffer(0, tensor, {readback_data}); for (int j = 0; j < device_ids.size() * 32 * 16384; j++) { ASSERT_EQ(readback_data[j].to_float(), 1); @@ -178,7 +178,7 @@ TEST(TGTests, TestReduceScatterDeadlock) { .memory_layout = tt::tt_metal::TensorMemoryLayout::INTERLEAVED, .buffer_type = BufferType::DRAM, .shard_spec = std::nullopt}; - ttnn::Shape shape = ttnn::Shape(Shape({1, 2, 256, static_cast(256 * ring_devices.size())})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 2, 256, static_cast(256 * ring_devices.size())})); uint32_t buf_size_datums = 2 * 256 * 256 * 20; uint32_t datum_size_bytes = 2; // Output of reduce scatter is input_numel / num_devices_used_in_scatter_op @@ -234,7 +234,7 @@ TEST(TGTests, TestReduceScatterDeadlock) { } // Readback data and verify correctness. for (auto& tensor : output_tensors) { - ASSERT_EQ(tensor.get_shape(), ttnn::Shape(Shape({1, 2, 256, 256}))); + ASSERT_EQ(tensor.get_shape(), ttnn::Shape(tt::tt_metal::LegacyShape({1, 2, 256, 256}))); ttnn::read_buffer(0, tensor, {readback_data}); for (int j = 0; j < 512 * 256; j++) { ASSERT_EQ(readback_data[j].to_float(), 20); diff --git a/tests/ttnn/unit_tests/gtests/test_multi_cq_multi_dev.cpp b/tests/ttnn/unit_tests/gtests/test_multi_cq_multi_dev.cpp index 38616c75b55..f2bbbebb633 100644 --- a/tests/ttnn/unit_tests/gtests/test_multi_cq_multi_dev.cpp +++ b/tests/ttnn/unit_tests/gtests/test_multi_cq_multi_dev.cpp @@ -44,7 +44,7 @@ TEST_F(MultiCommandQueueT3KFixture, Test2CQMultiDeviceProgramsOnCQ1) { .buffer_type = BufferType::DRAM, .shard_spec = std::nullopt}; - ttnn::Shape shape = ttnn::Shape(Shape({1, 3, 2048, 2048})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 3, 2048, 2048})); uint32_t buf_size_datums = 2048 * 2048 * 3; uint32_t datum_size_bytes = 2; auto host_data = std::shared_ptr(new bfloat16[buf_size_datums]); @@ -94,7 +94,7 @@ TEST_F(MultiCommandQueueT3KFixture, Test2CQMultiDeviceProgramsOnCQ0) { .buffer_type = BufferType::DRAM, .shard_spec = std::nullopt}; - ttnn::Shape shape = ttnn::Shape(Shape({1, 3, 2048, 2048})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 3, 2048, 2048})); uint32_t buf_size_datums = 2048 * 2048 * 3; uint32_t datum_size_bytes = 2; auto host_data = std::shared_ptr(new bfloat16[buf_size_datums]); @@ -145,7 +145,7 @@ TEST_F(MultiCommandQueueT3KFixture, Test2CQMultiDeviceWithCQ1Only) { .buffer_type = BufferType::DRAM, .shard_spec = std::nullopt}; - ttnn::Shape shape = ttnn::Shape(Shape({1, 3, 2048, 2048})); + ttnn::Shape shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 3, 2048, 2048})); uint32_t buf_size_datums = 2048 * 2048 * 3; uint32_t datum_size_bytes = 2; auto host_data = std::shared_ptr(new bfloat16[buf_size_datums]); diff --git a/tests/ttnn/unit_tests/gtests/test_multi_device.cpp b/tests/ttnn/unit_tests/gtests/test_multi_device.cpp index 6105fbeb294..1b51605d4bd 100644 --- a/tests/ttnn/unit_tests/gtests/test_multi_device.cpp +++ b/tests/ttnn/unit_tests/gtests/test_multi_device.cpp @@ -13,7 +13,7 @@ using namespace tt::tt_metal; Tensor create_host_multi_device_tensor(const Tensor& tensor, const ReplicateTensor& strategy) { std::vector owned_buffers; - std::vector shapes; + std::vector shapes; for (int i = 0; i < strategy.replication_factor; i++) { owned_buffers.push_back(std::get(tensor.get_storage()).buffer); diff --git a/tests/ttnn/unit_tests/gtests/test_multiprod_queue.cpp b/tests/ttnn/unit_tests/gtests/test_multiprod_queue.cpp index 8656ac4fd58..d552d5dd88a 100644 --- a/tests/ttnn/unit_tests/gtests/test_multiprod_queue.cpp +++ b/tests/ttnn/unit_tests/gtests/test_multiprod_queue.cpp @@ -39,7 +39,7 @@ TEST_F(MultiCommandQueueSingleDeviceFixture, TestMultiProducerLockBasedQueue) { uint32_t tensor_buf_size = 1024 * 1024; uint32_t datum_size_bytes = 2; - ttnn::Shape tensor_shape = ttnn::Shape(Shape({1, 1, 1024, 1024})); + ttnn::Shape tensor_shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1024, 1024})); auto t0_host_data = std::shared_ptr(new bfloat16[tensor_buf_size]); auto t0_readback_data = std::shared_ptr(new bfloat16[tensor_buf_size]); auto t1_host_data = std::shared_ptr(new bfloat16[tensor_buf_size]); @@ -117,7 +117,7 @@ TEST_F(MultiCommandQueueSingleDeviceFixture, TestMultiAppThreadSync) { std::shared_ptr write_event = std::make_shared(); std::shared_ptr read_event = std::make_shared(); - ttnn::Shape tensor_shape = ttnn::Shape(Shape({1, 1, 1024, 1024})); + ttnn::Shape tensor_shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 1024, 1024})); auto host_data = std::shared_ptr(new bfloat16[tensor_buf_size]); auto allocated_buffer = ttnn::allocate_buffer_on_device(tensor_buf_size * datum_size_bytes, device, tensor_shape, DataType::BFLOAT16, Layout::TILE, mem_cfg); auto allocated_storage = tt::tt_metal::DeviceStorage{allocated_buffer}; diff --git a/tests/ttnn/unit_tests/gtests/test_repeat_interleave.cpp b/tests/ttnn/unit_tests/gtests/test_repeat_interleave.cpp index b316d090bc2..e3683cc5a78 100644 --- a/tests/ttnn/unit_tests/gtests/test_repeat_interleave.cpp +++ b/tests/ttnn/unit_tests/gtests/test_repeat_interleave.cpp @@ -30,7 +30,7 @@ void run_repeat_interleave_test(tt::tt_metal::Device* device, const uint32_t rep const uint32_t input_buf_size_datums = 32 * 32; const uint32_t output_buf_size_datums = input_buf_size_datums * repeats; const uint32_t datum_size_bytes = 2; - ttnn::Shape input_shape = ttnn::Shape(tt::tt_metal::Shape({1, 1, 32, 32})); + ttnn::Shape input_shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, 32, 32})); auto host_data = std::shared_ptr(new uint16_t[input_buf_size_datums]); auto readback_data = std::shared_ptr(new uint16_t[output_buf_size_datums]); diff --git a/ttnn/cpp/pybind11/device.cpp b/ttnn/cpp/pybind11/device.cpp index 815fe267950..de95dd286bd 100644 --- a/ttnn/cpp/pybind11/device.cpp +++ b/ttnn/cpp/pybind11/device.cpp @@ -236,7 +236,7 @@ void device_module(py::module &m_device) { bool pad_c = false, bool pad_n = false, bool pad_h = true, - bool pad_w = true) -> tt::tt_metal::Shape { + bool pad_w = true) -> tt::tt_metal::LegacyShape { return ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(unpadded_shape, pad_c, pad_n, pad_h, pad_w); }); diff --git a/ttnn/cpp/pybind11/operations/creation.hpp b/ttnn/cpp/pybind11/operations/creation.hpp index 6feabd48a74..71623cc843c 100644 --- a/ttnn/cpp/pybind11/operations/creation.hpp +++ b/ttnn/cpp/pybind11/operations/creation.hpp @@ -38,7 +38,7 @@ void bind_full_operation(py::module& module, const creation_operation_t& operati const std::optional& memory_config, std::optional &optional_output_tensor, uint8_t queue_id) -> ttnn::Tensor { - return self(queue_id, ttnn::Shape{tt::tt_metal::Shape{shape}}, fill_value, dtype, layout, device, memory_config, optional_output_tensor); + return self(queue_id, ttnn::Shape{tt::tt_metal::LegacyShape{shape}}, fill_value, dtype, layout, device, memory_config, optional_output_tensor); }, py::arg("shape"), py::arg("fill_value"), @@ -58,7 +58,7 @@ void bind_full_operation(py::module& module, const creation_operation_t& operati const std::optional& memory_config, std::optional &optional_output_tensor, uint8_t queue_id) -> ttnn::Tensor { - return self(queue_id, ttnn::Shape{tt::tt_metal::Shape{shape}}, fill_value, dtype, layout, device, memory_config, optional_output_tensor); + return self(queue_id, ttnn::Shape{tt::tt_metal::LegacyShape{shape}}, fill_value, dtype, layout, device, memory_config, optional_output_tensor); }, py::arg("shape"), py::arg("fill_value"), @@ -87,7 +87,7 @@ void bind_full_operation_with_hard_coded_value(py::module& module, const creatio const std::optional& layout, const std::optional>& device, const std::optional& memory_config) -> ttnn::Tensor { - return self(ttnn::Shape{tt::tt_metal::Shape{shape}}, dtype, layout, device, memory_config); + return self(ttnn::Shape{tt::tt_metal::LegacyShape{shape}}, dtype, layout, device, memory_config); }, py::arg("shape"), py::arg("dtype") = std::nullopt, diff --git a/ttnn/cpp/pybind11/pytensor.cpp b/ttnn/cpp/pybind11/pytensor.cpp index feddb572634..425ac2810e0 100644 --- a/ttnn/cpp/pybind11/pytensor.cpp +++ b/ttnn/cpp/pybind11/pytensor.cpp @@ -419,7 +419,7 @@ Tensor convert_python_tensors_to_tt_tensors(py::list tensor_shards, std::optiona tt_shards.push_back(detail::convert_python_tensor_to_tt_tensor(shard, data_type, false)); } std::vector host_owned_buffers; - std::vector host_owned_shapes; + std::vector host_owned_shapes; for (const auto &shard : tt_shards) { TT_ASSERT(std::holds_alternative(shard.get_storage()), "Unexpected type {}", tt::stl::get_active_type_name_in_variant(shard.get_storage())); host_owned_buffers.push_back(std::get(shard.get_storage()).buffer); @@ -646,7 +646,7 @@ Tensor convert_python_tensors_to_tt_tensors(py::list tensor_shards, std::optiona } // namespace detail void pytensor_module_types(py::module &m_tensor) { - using tt::tt_metal::Shape; + using tt::tt_metal::LegacyShape; // Tensor constructors that accept device and .to(device) function use keep alive call policy to communicate that Device needs to outlive Tensor. // This is because when tensors on device are destroyed they need to deallocate their buffers via device. // keep_alive increases the ref count of the Device object being passed into the constructor and .to() function. @@ -1588,7 +1588,7 @@ void pytensor_module(py::module &m_tensor) { )doc") .def( "reshape", - [](Tensor &self, const tt::tt_metal::Shape &shape) -> Tensor { return self.reshape(shape); }, + [](Tensor &self, const tt::tt_metal::LegacyShape &shape) -> Tensor { return self.reshape(shape); }, R"doc( Reshapes TT tensor diff --git a/ttnn/cpp/pybind11/tensor.cpp b/ttnn/cpp/pybind11/tensor.cpp index 9a0bb65322a..1925da8ec9d 100644 --- a/ttnn/cpp/pybind11/tensor.cpp +++ b/ttnn/cpp/pybind11/tensor.cpp @@ -81,7 +81,7 @@ void tensor_mem_config_module_types(py::module& m_tensor) { Class defining core coordinate )doc"); - py::class_(m_tensor, "Shape", R"doc( + py::class_(m_tensor, "Shape", R"doc( Class defining tensor shape )doc"); @@ -116,7 +116,7 @@ void tensor_mem_config_module_types(py::module& m_tensor) { } void tensor_mem_config_module(py::module& m_tensor) { - using tt::tt_metal::Shape; + using tt::tt_metal::LegacyShape; auto py_core_coord = static_cast>(m_tensor.attr("CoreCoord")); py_core_coord.def(py::init()) @@ -128,29 +128,29 @@ void tensor_mem_config_module(py::module& m_tensor) { .def_readonly("y", &CoreCoord::y); py::implicitly_convertible, CoreCoord>(); - auto py_shape = static_cast>(m_tensor.attr("Shape")); + auto py_shape = static_cast>(m_tensor.attr("Shape")); py_shape.def(py::init>()) .def( py::init( [](const std::vector& shape, - const std::optional>& padded_shape) -> tt::tt_metal::Shape { + const std::optional>& padded_shape) -> tt::tt_metal::LegacyShape { if (padded_shape.has_value()) { - return tt::tt_metal::Shape{shape, padded_shape.value()}; + return tt::tt_metal::LegacyShape{shape, padded_shape.value()}; } else { - return tt::tt_metal::Shape{shape}; + return tt::tt_metal::LegacyShape{shape}; } }), py::arg("shape"), py::arg("padded_shape") = std::nullopt) - .def("__len__", [](const Shape& self) { return self.rank(); }) - .def("__eq__", [](const Shape& self, const Shape& other) { return self == other; }) - .def("__eq__", [](const Shape& self, const std::vector& other) { return self == Shape{other}; }) - .def("__eq__", [](const Shape& self, const std::array& other) { return self == Shape{other}; }) - .def("__eq__", [](const Shape& self, const py::none) { return false; }) - .def("__getitem__", [](const Shape& self, const std::int64_t index) { return self[index]; }) + .def("__len__", [](const LegacyShape& self) { return self.rank(); }) + .def("__eq__", [](const LegacyShape& self, const LegacyShape& other) { return self == other; }) + .def("__eq__", [](const LegacyShape& self, const std::vector& other) { return self == LegacyShape{other}; }) + .def("__eq__", [](const LegacyShape& self, const std::array& other) { return self == LegacyShape{other}; }) + .def("__eq__", [](const LegacyShape& self, const py::none) { return false; }) + .def("__getitem__", [](const LegacyShape& self, const std::int64_t index) { return self[index]; }) .def( "__getitem__", - [](const Shape& self, const py::slice slice) { + [](const LegacyShape& self, const py::slice slice) { size_t start = 0, stop = 0, step = 0, slicelength = 0; if (!slice.compute(self.rank(), &start, &stop, &step, &slicelength)) { throw std::runtime_error("Invalid slice"); @@ -160,16 +160,16 @@ void tensor_mem_config_module(py::module& m_tensor) { for (auto index = start; index < stop; index += step) { output.push_back(self[index]); } - return Shape{output}; + return LegacyShape{output}; }) .def( "__iter__", - [](const tt::tt_metal::Shape& self) { return py::make_iterator(self.begin(), self.end()); }, + [](const tt::tt_metal::LegacyShape& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()) - .def("__repr__", [](const Shape& self) { return fmt::format("{}", self); }) - .def("without_padding", [](const tt::tt_metal::Shape& self) -> tt::tt_metal::Shape { return self.without_padding(); }); + .def("__repr__", [](const tt::tt_metal::LegacyShape& self) { return fmt::format("{}", self); }) + .def("without_padding", [](const tt::tt_metal::LegacyShape& self) -> tt::tt_metal::LegacyShape { return self.without_padding(); }); - py::implicitly_convertible, Shape>(); + py::implicitly_convertible, LegacyShape>(); auto pyMemoryConfig = static_cast>(m_tensor.attr("MemoryConfig")); pyMemoryConfig diff --git a/ttnn/cpp/pybind11/types.hpp b/ttnn/cpp/pybind11/types.hpp index c3e0ab59788..ba41f2fa636 100644 --- a/ttnn/cpp/pybind11/types.hpp +++ b/ttnn/cpp/pybind11/types.hpp @@ -42,7 +42,7 @@ void py_module(py::module& module) { }); auto PyShape = static_cast>(module.attr("Shape")); - PyShape.def(py::init()) + PyShape.def(py::init()) .def_property_readonly("value", [](const Shape& self) { return self.value; }) .def("__len__", [](const Shape& self) { return self.rank(); }) .def("__getitem__", [](const Shape& self, std::int64_t index) { return self[index]; }) diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.cpp index 4d57fddbbcf..13b3ce7d65f 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.cpp @@ -62,7 +62,7 @@ void MorehAdamW::validate_with_output_tensors( } } -std::vector MorehAdamW::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehAdamW::compute_output_shapes(const std::vector& input_tensors) const { auto output_shape = input_tensors.at(0).get_legacy_shape(); return {output_shape, output_shape, output_shape, output_shape}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.hpp index f971215a93d..ab4470521eb 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_adamw/moreh_adamw_op.hpp @@ -34,7 +34,7 @@ struct MorehAdamW { const std::vector &input_tensors, const std::vector> &optional_input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.cpp index 1e11eb5a40b..b054fbedff6 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.cpp @@ -48,7 +48,7 @@ void MorehClipGradNormStep1::validate( check_tensor(tmp_pow_sum, "moreh_clip_grad_norm_step1", "tmp_pow_sum"); }; -std::vector MorehClipGradNormStep1::compute_output_shapes(const std::vector &) const { return {}; } +std::vector MorehClipGradNormStep1::compute_output_shapes(const std::vector &) const { return {}; } std::vector MorehClipGradNormStep1::create_output_tensors(const std::vector &) const { return {}; } @@ -105,7 +105,7 @@ void MorehClipGradNormStep2::validate(const std::vector &input_tensors) check_tensor(total_norm, "moreh_clip_grad_norm_step2", "total_norm"); } -std::vector MorehClipGradNormStep2::compute_output_shapes(const std::vector &) const { return {}; } +std::vector MorehClipGradNormStep2::compute_output_shapes(const std::vector &) const { return {}; } std::vector MorehClipGradNormStep2::create_output_tensors(const std::vector &) const { return {}; } @@ -146,7 +146,7 @@ void MorehClipGradNormStep3::validate( check_tensor(clip_coef_clamped, "moreh_clip_grad_norm_step3", "clip_coef_clamped"); } -std::vector MorehClipGradNormStep3::compute_output_shapes(const std::vector &) const { return {}; } +std::vector MorehClipGradNormStep3::compute_output_shapes(const std::vector &) const { return {}; } std::vector MorehClipGradNormStep3::create_output_tensors(const std::vector &) const { return {}; } @@ -239,7 +239,7 @@ Tensor moreh_clip_grad_norm_impl( using namespace tt::constants; // Create tmp_pow_sum[1, 1, TILE_HEIGHT, TILE_WIDTH * total_num_inputs] const auto total_num_inputs = static_cast(inputs.size()); - Shape tmp_pow_sum_shape{1, 1, TILE_HEIGHT, TILE_WIDTH * total_num_inputs}; + tt::tt_metal::LegacyShape tmp_pow_sum_shape{1, 1, TILE_HEIGHT, TILE_WIDTH * total_num_inputs}; const auto &tmp_pow_sum = create_device_tensor(tmp_pow_sum_shape, inputs.at(0).get_dtype(), Layout::TILE, inputs.at(0).device()); @@ -250,7 +250,7 @@ Tensor moreh_clip_grad_norm_impl( // Create total_norm[1, 1, 1, 1] Padding padding{{{0, 0}, {0, 0}, {0, TILE_HEIGHT - 1}, {0, TILE_WIDTH - 1}}, Padding::PadValue::Zero}; - Shape total_norm_shape{{1, 1, TILE_HEIGHT, TILE_WIDTH}, padding}; + tt::tt_metal::LegacyShape total_norm_shape{{1, 1, TILE_HEIGHT, TILE_WIDTH}, padding}; const auto &created_total_norm = create_device_tensor( total_norm_shape, inputs.at(0).get_dtype(), Layout::TILE, inputs.at(0).device(), output_mem_config); diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.hpp index 4a0045dcccc..c946befe11d 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_clip_grad_norm/moreh_clip_grad_norm_op.hpp @@ -32,7 +32,7 @@ struct MorehClipGradNormStep1 { void validate( const std::vector &input_tensors, const std::vector> &optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &) const; + std::vector compute_output_shapes(const std::vector &) const; std::vector create_output_tensors(const std::vector &) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, @@ -49,7 +49,7 @@ struct MorehClipGradNormStep2 { float norm_type; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &) const; + std::vector compute_output_shapes(const std::vector &) const; std::vector create_output_tensors(const std::vector &) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &) const; @@ -64,7 +64,7 @@ struct MorehClipGradNormStep3 { void validate( const std::vector &input_tensors, const std::vector> &optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &) const; + std::vector compute_output_shapes(const std::vector &) const; std::vector create_output_tensors(const std::vector &) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.cpp index d0df1c8c216..11737ca926f 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.cpp @@ -35,7 +35,7 @@ std::vector MorehCumSum::create_output_tensors(const std::vector return {}; } -std::vector MorehCumSum::compute_output_shapes(const std::vector& inputs) const { +std::vector MorehCumSum::compute_output_shapes(const std::vector& inputs) const { // Inplace return {}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.hpp index eae1d8e5839..0669a801667 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_cumsum/moreh_cumsum_op.hpp @@ -24,7 +24,7 @@ struct MorehCumSum { int64_t dim; bool flip; void validate(const std::vector &inputs) const; - std::vector compute_output_shapes(const std::vector &inputs) const; + std::vector compute_output_shapes(const std::vector &inputs) const; std::vector create_output_tensors(const std::vector &inputs) const; operation::ProgramWithCallbacks create_program( const std::vector &inputs, std::vector &outputs) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.cpp index 6a2961bb6d5..dabf8dd64ba 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.cpp @@ -46,13 +46,13 @@ void MorehDot::validate(const std::vector& input_tensors) const { "Operands to matmul need to be allocated in buffers on device!"); } -std::vector MorehDot::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehDot::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto output_shape = input_tensor.get_legacy_shape(); auto padding = output_shape.padding(); output_shape[3] = TILE_WIDTH; padding[3] = Padding::PadDimension{0, 31}; - return {Shape(output_shape, padding)}; + return {tt::tt_metal::LegacyShape(output_shape, padding)}; } std::vector MorehDot::create_output_tensors(const std::vector& input_tensors) const { diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.hpp index daf4d5462b6..0be70fedaa7 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot/moreh_dot_op.hpp @@ -27,7 +27,7 @@ struct MorehDot { const DataType output_dtype; // TODO: Uplift output_dtype as an option for general dot/bmm void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.cpp index 558108f9673..dfa0fec1c50 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.cpp @@ -63,7 +63,7 @@ void MorehDotBackward::validate( } } -std::vector MorehDotBackward::compute_output_shapes(const std::vector& inputs) const { +std::vector MorehDotBackward::compute_output_shapes(const std::vector& inputs) const { // Inplace return {}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.hpp index 001c527db21..6e073dd5723 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_dot_backward/moreh_dot_backward_op.hpp @@ -29,7 +29,7 @@ operation::ProgramWithCallbacks moreh_dot_backward_single_core( struct MorehDotBackward { void validate( const std::vector &inputs, const std::vector> &optional_inputs) const; - std::vector compute_output_shapes(const std::vector &inputs) const; + std::vector compute_output_shapes(const std::vector &inputs) const; std::vector create_output_tensors(const std::vector &inputs) const; operation::ProgramWithCallbacks create_program( const std::vector &inputs, diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm/moreh_groupnorm_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm/moreh_groupnorm_op.cpp index bdd01370720..332bf5c2f79 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm/moreh_groupnorm_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm/moreh_groupnorm_op.cpp @@ -71,7 +71,7 @@ void MorehGroupNorm::validate_with_output_tensors( } } -std::vector MorehGroupNorm::compute_output_shapes(const std::vector &input_tensors) const { +std::vector MorehGroupNorm::compute_output_shapes(const std::vector &input_tensors) const { using namespace tt::constants; // mean, rstd (1, 1, N, num_groups) const auto output_shape = input_tensors.at(0).get_legacy_shape(); @@ -87,7 +87,7 @@ std::vector MorehGroupNorm::compute_output_shapes(const std::vector> &optional_input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.cpp index 1b332119fcf..379b6d3da5d 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.cpp @@ -63,7 +63,7 @@ void MorehGroupNormBackwardInputGrad::validate_with_output_tensors( rstd.get_legacy_shape().without_padding()[-1] == this->num_groups, "rstd_shape[-1] must match num_groups."); } -std::vector MorehGroupNormBackwardInputGrad::compute_output_shapes( +std::vector MorehGroupNormBackwardInputGrad::compute_output_shapes( const std::vector &input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } @@ -170,7 +170,7 @@ void MorehGroupNormBackwardGammaBetaGrad::validate_with_output_tensors( rstd.get_legacy_shape().without_padding()[-1] == this->num_groups, "rstd_shape[-1] must match num_groups."); } -std::vector MorehGroupNormBackwardGammaBetaGrad::compute_output_shapes( +std::vector MorehGroupNormBackwardGammaBetaGrad::compute_output_shapes( const std::vector &input_tensors) const { using namespace tt::constants; const auto &output_grad = input_tensors.at(0); @@ -189,7 +189,7 @@ std::vector MorehGroupNormBackwardGammaBetaGrad::compute_output_shapes( dgamma_dbeta_padding[2] = Padding::PadDimension{0, TILE_HEIGHT - 1}; dgamma_dbeta_padding[3] = Padding::PadDimension{0, TILE_WIDTH - (c % TILE_WIDTH)}; - Shape dgamma_dbeta_shape(dgamma_dbeta_origin_shape, dgamma_dbeta_padding); + tt::tt_metal::LegacyShape dgamma_dbeta_shape(dgamma_dbeta_origin_shape, dgamma_dbeta_padding); return {dgamma_dbeta_shape, dgamma_dbeta_shape}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.hpp index ef3bc0fd197..cc19cde9a7d 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_groupnorm_backward/moreh_groupnorm_backward_op.hpp @@ -31,7 +31,7 @@ struct MorehGroupNormBackwardInputGrad { const std::vector> &optional_input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; @@ -70,7 +70,7 @@ struct MorehGroupNormBackwardGammaBetaGrad { void validate_with_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector> create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.cpp index 77a688aeaeb..8ec1114e52c 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.cpp @@ -302,7 +302,7 @@ bool is_hw_dim(uint32_t dim, uint32_t rank) { return (dim >= rank - 2); } -uint32_t compute_inner(Shape shape, uint32_t dim) { +uint32_t compute_inner(tt::tt_metal::LegacyShape shape, uint32_t dim) { uint32_t num_inner = 1; auto rank = shape.rank(); @@ -317,7 +317,7 @@ uint32_t compute_inner(Shape shape, uint32_t dim) { return num_inner; } -uint32_t compute_outer(Shape shape, uint32_t dim) { +uint32_t compute_outer(tt::tt_metal::LegacyShape shape, uint32_t dim) { uint32_t num_outer = 1; auto rank = shape.rank(); @@ -331,7 +331,7 @@ uint32_t compute_outer(Shape shape, uint32_t dim) { return num_outer; } -void expand_to_max_dim(std::vector &dim, const Shape &shape) { +void expand_to_max_dim(std::vector &dim, const tt::tt_metal::LegacyShape &shape) { const auto rank = shape.rank(); for (auto i = 0; i < rank; ++i) { auto idx = rank - 1 - i; @@ -440,7 +440,7 @@ std::vector get_dim( return dims; } -std::tuple extract_spatial_dims(const Shape& shape) { +std::tuple extract_spatial_dims(const tt::tt_metal::LegacyShape& shape) { const auto rank = shape.rank(); TT_FATAL(rank >= 2, "Shape must have at least two dims."); @@ -455,7 +455,7 @@ std::tuple extract_spatial_dims(const Shape& shape return { W, H, other_dims_product}; } -std::tuple extract_and_scale_spatial_dims(const Shape& shape, uint32_t dim) { +std::tuple extract_and_scale_spatial_dims(const tt::tt_metal::LegacyShape& shape, uint32_t dim) { const auto rank = shape.rank(); TT_FATAL(rank >= 2, "Shape must have at least two dims."); diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.hpp index d0f311ecfe5..2bb33f180ee 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_helper_functions.hpp @@ -289,11 +289,11 @@ auto create_override_addresses_callback( bool is_hw_dim(uint32_t dim, uint32_t rank); -uint32_t compute_inner(Shape shape, uint32_t dim); +uint32_t compute_inner(tt::tt_metal::LegacyShape shape, uint32_t dim); -uint32_t compute_outer(Shape shape, uint32_t dim); +uint32_t compute_outer(tt::tt_metal::LegacyShape shape, uint32_t dim); -void expand_to_max_dim(std::vector &dim, const Shape &shape); +void expand_to_max_dim(std::vector &dim, const tt::tt_metal::LegacyShape &shape); void validate_input_with_dim(const Tensor &input, const int64_t &dim); @@ -304,9 +304,9 @@ void initialize_dims_with_range(std::vector &dims, uint32_t input_rank) std::vector get_dim( const std::optional>> &dim, uint32_t input_rank); -std::tuple extract_spatial_dims(const Shape& shape); +std::tuple extract_spatial_dims(const tt::tt_metal::LegacyShape& shape); -std::tuple extract_and_scale_spatial_dims(const Shape& shape, uint32_t dim); +std::tuple extract_and_scale_spatial_dims(const tt::tt_metal::LegacyShape& shape, uint32_t dim); } // namespace primary } // namespace operations diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm/moreh_layernorm_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm/moreh_layernorm_op.cpp index 1a4e6cbce53..49a037f6e68 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm/moreh_layernorm_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm/moreh_layernorm_op.cpp @@ -405,11 +405,11 @@ void MorehLayerNorm::validate_with_output_tensors( } } -std::vector MorehLayerNorm::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehLayerNorm::compute_output_shapes(const std::vector& input_tensors) const { auto input = input_tensors.at(0); // compute mean_rstd_shape - Shape input_shape = input.get_legacy_shape(); + tt::tt_metal::LegacyShape input_shape = input.get_legacy_shape(); auto input_shape_without_padding = input_shape.without_padding(); auto input_rank = input_shape.rank(); auto output_rank = input_rank - normalized_dims; @@ -437,7 +437,7 @@ std::vector MorehLayerNorm::compute_output_shapes(const std::vector &input_tensors, const std::vector> &optional_input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.cpp index def8739a010..2f09730b4a6 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.cpp @@ -62,7 +62,7 @@ void MorehLayerNormBackwardInputGrad::validate_with_output_tensors( } } -std::vector MorehLayerNormBackwardInputGrad::compute_output_shapes( +std::vector MorehLayerNormBackwardInputGrad::compute_output_shapes( const std::vector& input_tensors) const { auto input = input_tensors.at(0); auto input_shape = input.get_legacy_shape(); @@ -131,7 +131,7 @@ void MorehLayerNormBackwardGammaBetaGrad::validate_with_output_tensors( } } -std::vector MorehLayerNormBackwardGammaBetaGrad::compute_output_shapes( +std::vector MorehLayerNormBackwardGammaBetaGrad::compute_output_shapes( const std::vector& input_tensors) const { TT_THROW("The compute_output_shapes function in MorehLayerNormBackwardGammaBetaGrad is not implemented."); return {}; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.hpp index 4ebb5ada657..6e46832f6e7 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_layernorm_backward/moreh_layernorm_backward_op.hpp @@ -30,7 +30,7 @@ struct MorehLayerNormBackwardInputGrad { const std::vector &input_tensors, const std::vector> &optional_input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, @@ -46,7 +46,7 @@ struct MorehLayerNormBackwardGammaBetaGrad { void validate_with_output_tensors( const std::vector &input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.cpp index fdf2c22ce78..6d77fecc96a 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.cpp @@ -42,7 +42,7 @@ void MorehBiasAddBackward::validate_with_output_tensors( } } -std::vector MorehBiasAddBackward::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehBiasAddBackward::compute_output_shapes(const std::vector& input_tensors) const { return {input_tensors.at(1).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.hpp index feface1fdb2..b5ab2a1cfc9 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_linear_backward/moreh_linear_backward_op.hpp @@ -31,7 +31,7 @@ struct MorehBiasAddBackward { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate_with_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp index 1bdd0addcb1..24815c2a061 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.cpp @@ -31,8 +31,8 @@ inline bool is_dot_forward(const Tensor& input, const Tensor& other, bool transp return is_1d_tensor(input) && is_1d_tensor(other) && is_same_shape(input, other); } -inline Shape compute_output_shape( - const Shape& input_shape, const Shape& other_shape, bool transpose_input, bool transpose_other) { +tt::tt_metal::LegacyShape compute_output_shape( + const tt::tt_metal::LegacyShape& input_shape, const tt::tt_metal::LegacyShape& other_shape, bool transpose_input, bool transpose_other) { const auto& input_shape_wo_padding = input_shape.without_padding(); const auto& other_shape_wo_padding = other_shape.without_padding(); @@ -68,17 +68,17 @@ inline Shape compute_output_shape( output_dim[output_rank - 2] = h; output_dim[output_rank - 1] = w; - Shape output_shape{output_dim}; + tt::tt_metal::LegacyShape output_shape{output_dim}; auto padding = output_shape.padding(); // padding for t logmatrix dims padding[output_rank - 2] = Padding::PadDimension{0, h - h_wo_padding}; padding[output_rank - 1] = Padding::PadDimension{0, w - w_wo_padding}; - return {Shape(output_shape, padding)}; + return {tt::tt_metal::LegacyShape(output_shape, padding)}; } } // namespace -void get_tensor_dim(std::vector& dim, const Shape& shape) { +void get_tensor_dim(std::vector& dim, const tt::tt_metal::LegacyShape& shape) { const auto rank = shape.rank(); for (auto i = 0; i < rank; ++i) { auto idx = rank - 1 - i; @@ -97,7 +97,7 @@ void get_tensor_dim(std::vector& dim, const Shape& shape) { } } -std::vector find_reduce_dim(const Shape& a_shape, const Shape& b_shape) { +std::vector find_reduce_dim(const tt::tt_metal::LegacyShape& a_shape, const tt::tt_metal::LegacyShape& b_shape) { std::vector a_dim(tt::tt_metal::MAX_NUM_DIMENSIONS, 1); std::vector b_dim(tt::tt_metal::MAX_NUM_DIMENSIONS, 1); get_tensor_dim(a_dim, a_shape); @@ -154,7 +154,7 @@ operation::ProgramWithCallbacks MorehMatmul::create_program( } // Must be provided in the case where an optional output tensor was not provided -std::vector MorehMatmul::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehMatmul::compute_output_shapes(const std::vector& input_tensors) const { return {compute_output_shape( input_tensors.at(0).get_legacy_shape(), input_tensors.at(1).get_legacy_shape(), diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.hpp index c78188908d9..82ae710c93f 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_matmul/moreh_matmul_op.hpp @@ -17,8 +17,8 @@ namespace primary { using namespace tt_metal; -void get_tensor_dim(std::vector &dim, const Shape& shape); -std::vector find_reduce_dim(const Shape& a_shape, const Shape& b_shape); +void get_tensor_dim(std::vector &dim, const tt::tt_metal::LegacyShape& shape); +std::vector find_reduce_dim(const tt::tt_metal::LegacyShape& a_shape, const tt::tt_metal::LegacyShape& b_shape); bool is_same_batch_dim(const Tensor &tensor_a, const Tensor &tensor_b); operation::ProgramWithCallbacks moreh_matmul_multi_core( @@ -39,7 +39,7 @@ struct MorehMatmul { const std::vector &input_tensors, const std::vector> &optional_input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss/moreh_nll_loss_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss/moreh_nll_loss_op.cpp index 85590298d03..b481da9dc42 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss/moreh_nll_loss_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss/moreh_nll_loss_op.cpp @@ -42,7 +42,7 @@ void MorehNllLossStep1::validate( } } -std::vector MorehNllLossStep1::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehNllLossStep1::compute_output_shapes(const std::vector& input_tensors) const { const auto& target_tensor = input_tensors.at(0); auto target_shape = target_tensor.get_legacy_shape(); @@ -121,7 +121,7 @@ void MorehNllLossStep2::validate( } } -std::vector MorehNllLossStep2::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehNllLossStep2::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto input_shape = input_tensor.get_legacy_shape(); auto input_shape_without_padding = input_shape.without_padding(); @@ -161,7 +161,7 @@ std::vector MorehNllLossStep2::compute_output_shapes(const std::vector &input_tensors, const std::vector> &optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, @@ -80,7 +80,7 @@ struct MorehNllLossStep2 { void validate( const std::vector &input_tensors, const std::vector> &optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss_unreduced_backward/moreh_nll_loss_unreduced_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss_unreduced_backward/moreh_nll_loss_unreduced_backward_op.cpp index ec4abc7ffa5..0d9691a4013 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss_unreduced_backward/moreh_nll_loss_unreduced_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_nll_loss_unreduced_backward/moreh_nll_loss_unreduced_backward_op.cpp @@ -88,7 +88,7 @@ void MorehNllLossUnreducedBackward::validate_with_output_tensors( } } -std::vector MorehNllLossUnreducedBackward::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehNllLossUnreducedBackward::compute_output_shapes(const std::vector& input_tensors) const { // To calculate the output shape, we need the channel_size. However, the required tensors, target and output_grad, // do not contain the channel_size information. TT_THROW("moreh_nll_loss_unreduced_backward not support create output tensors."); diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.cpp index 7279512a65c..90436a521c2 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.cpp @@ -137,7 +137,7 @@ void MorehNorm::validate_with_output_tensors( } } -std::vector MorehNorm::compute_output_shapes(const std::vector &input_tensors) const { +std::vector MorehNorm::compute_output_shapes(const std::vector &input_tensors) const { using namespace tt::constants; const auto& input = input_tensors.at(0); const auto& input_shape = input.get_legacy_shape(); @@ -145,7 +145,7 @@ std::vector MorehNorm::compute_output_shapes(const std::vector &i const bool is_tile_dim = (this->dim == input_rank - 1 || this->dim == input_rank - 2); log_debug(LogOp, "{}:{} dim {}, keepdim {}", __func__, __LINE__, this->dim, this->keepdim); - Shape output_shape = input_shape; + tt::tt_metal::LegacyShape output_shape = input_shape; if (this->keepdim) { auto shape = input_shape; auto padding = shape.padding(); @@ -159,7 +159,7 @@ std::vector MorehNorm::compute_output_shapes(const std::vector &i shape[this->dim] = 1; } - output_shape = Shape(shape, padding); + output_shape = tt::tt_metal::LegacyShape(shape, padding); } else { std::vector shape; std::vector pad_dimensions; @@ -179,7 +179,7 @@ std::vector MorehNorm::compute_output_shapes(const std::vector &i } auto padding = Padding(pad_dimensions, input_padding.pad_value()); - output_shape = Shape(shape, padding); + output_shape = tt::tt_metal::LegacyShape(shape, padding); } log_debug(LogOp, "{}:{} output_shape {}", __func__, __LINE__, output_shape); diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.hpp index d358a63f8d7..3fef53fe741 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm/moreh_norm_op.hpp @@ -41,7 +41,7 @@ struct MorehNorm { const std::vector &input_tensors, const std::vector> &output_tensors ) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector>& output_tensors diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward.cpp index 28d3058ce3c..ad899c8674a 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward.cpp @@ -36,7 +36,7 @@ std::tuple get_floored_p_and_decimal_and_p_is_negative(fl } -void get_tensor_dim(std::vector &dim, const Shape& shape) { +void get_tensor_dim(std::vector &dim, const tt::tt_metal::LegacyShape& shape) { const auto rank = shape.rank(); for (auto i = 0; i < rank; ++i) { auto idx = rank - 1 - i; @@ -56,7 +56,7 @@ void get_tensor_dim(std::vector &dim, const Shape& shape) { } } -Shape get_output_grad_shape(const Tensor &output_grad, const Tensor &input_grad, const std::vector &dims, const bool &keep_batch_dim) { +tt::tt_metal::LegacyShape get_output_grad_shape(const Tensor &output_grad, const Tensor &input_grad, const std::vector &dims, const bool &keep_batch_dim) { if (keep_batch_dim) { return output_grad.get_legacy_shape(); } @@ -75,7 +75,7 @@ Shape get_output_grad_shape(const Tensor &output_grad, const Tensor &input_grad, } } - return Shape(shape, padding); + return tt::tt_metal::LegacyShape(shape, padding); } } // namespace diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.cpp index e0f91d8eb76..2d3f2bbb3f6 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.cpp @@ -40,7 +40,7 @@ void MorehNormBackward::validate_with_output_tensors( check_tensor(input_grad, "moreh_norm_backward", "input_grad"); } -std::vector MorehNormBackward::compute_output_shapes(const std::vector &input_tensors) const { +std::vector MorehNormBackward::compute_output_shapes(const std::vector &input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.hpp index f6b65f90d7f..e12349a4ca3 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_norm_backward/moreh_norm_backward_op.hpp @@ -38,7 +38,7 @@ struct MorehNormBackward { const std::vector &input_tensors, const std::vector> &output_tensors ) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.cpp index 785651c314a..b9274aacbe6 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.cpp @@ -49,7 +49,7 @@ void MorehSGD::validate_with_output_tensors( } } -std::vector MorehSGD::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehSGD::compute_output_shapes(const std::vector& input_tensors) const { auto output_shape = input_tensors.at(0).get_legacy_shape(); return {output_shape, output_shape}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.hpp index 21ba6b8a1d1..dddffcb4f89 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sgd/moreh_sgd_op.hpp @@ -49,7 +49,7 @@ struct MorehSGD { const std::vector &input_tensors, const std::vector> &optional_input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.cpp index ea1c2794d8d..f81696a2d1c 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.cpp @@ -42,7 +42,7 @@ void MorehSoftmax::validate_with_output_tensors( TT_ASSERT(output_tensors.size() == 1, "Must have 1 output tensors"); } -std::vector MorehSoftmax::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehSoftmax::compute_output_shapes(const std::vector& input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.hpp index bf804f3b1f2..97ea874759d 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax/moreh_softmax_op.hpp @@ -55,7 +55,7 @@ struct MorehSoftmax { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate_with_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; MorehSoftmaxOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.cpp index dbb460e9829..82ca9ceba8d 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.cpp @@ -49,7 +49,7 @@ void MorehSoftmaxBackward::validate_with_output_tensors( TT_ASSERT(output_tensors.size() == 1, "Must have 1 output tensors"); } -std::vector MorehSoftmaxBackward::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehSoftmaxBackward::compute_output_shapes(const std::vector& input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.hpp index 8dc4efed659..ab80e275a24 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_softmax_backward/moreh_softmax_backward_op.hpp @@ -80,7 +80,7 @@ struct MorehSoftmaxBackward { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate_with_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.cpp index 99628c691b0..27626900376 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.cpp @@ -75,14 +75,14 @@ void MorehSum::validate_with_output_tensors( } } -std::vector MorehSum::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MorehSum::compute_output_shapes(const std::vector& input_tensors) const { const auto& input = input_tensors.at(0); const auto& input_shape = input.get_legacy_shape(); const auto input_rank = input_shape.rank(); const bool is_tile_dim = (this->dim == input_rank - 1 || this->dim == input_rank - 2); log_debug(LogOp, "{}:{} dim {}, keep_batch_dim {}", __func__, __LINE__, this->dim, this->keep_batch_dim); - Shape output_shape = input_shape; + tt::tt_metal::LegacyShape output_shape = input_shape; if (this->keep_batch_dim) { auto shape = input_shape; auto padding = shape.padding(); @@ -96,7 +96,7 @@ std::vector MorehSum::compute_output_shapes(const std::vector& in shape[this->dim] = 1; } - output_shape = Shape(shape, padding); + output_shape = tt::tt_metal::LegacyShape(shape, padding); } else { std::vector shape; std::vector pad_dimensions; @@ -116,7 +116,7 @@ std::vector MorehSum::compute_output_shapes(const std::vector& in } auto padding = Padding(pad_dimensions, input_padding.pad_value()); - output_shape = Shape(shape, padding); + output_shape = tt::tt_metal::LegacyShape(shape, padding); } log_debug(LogOp, "{}:{} output_shape {}", __func__, __LINE__, output_shape); diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.hpp index a2fccfd98fb..dcf3631f93f 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum/moreh_sum_op.hpp @@ -32,7 +32,7 @@ struct MorehSum { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate_with_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_impl/moreh_sum_backward_impl.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_impl/moreh_sum_backward_impl.cpp index 3d0424ffe86..120d480bb85 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_impl/moreh_sum_backward_impl.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_impl/moreh_sum_backward_impl.cpp @@ -18,7 +18,7 @@ namespace primary { namespace { -void get_tensor_dim(std::vector &dim, const Shape &shape) { +void get_tensor_dim(std::vector &dim, const tt::tt_metal::LegacyShape &shape) { const auto rank = shape.rank(); for (auto i = 0; i < rank; ++i) { auto idx = rank - 1 - i; @@ -37,7 +37,7 @@ void get_tensor_dim(std::vector &dim, const Shape &shape) { } } -Shape get_output_grad_shape( +tt::tt_metal::LegacyShape get_output_grad_shape( const Tensor &output_grad, const Tensor &input_grad, const std::vector &dims, const bool &keep_batch_dim) { if (keep_batch_dim) { return output_grad.get_legacy_shape(); @@ -57,7 +57,7 @@ Shape get_output_grad_shape( } } - return Shape(shape, padding); + return tt::tt_metal::LegacyShape(shape, padding); } } // namespace diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.cpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.cpp index 038e7c72afc..d25f4e061f6 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.cpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.cpp @@ -81,7 +81,7 @@ void MorehSumBackward::validate_with_output_tensors( } } -std::vector MorehSumBackward::compute_output_shapes(const std::vector &input_tensors) const { +std::vector MorehSumBackward::compute_output_shapes(const std::vector &input_tensors) const { return {input_tensors.at(1).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.hpp b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.hpp index ec87b4c8f8b..1c0d121ea2e 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_dnn/op_library/moreh_sum_backward/moreh_sum_backward_op.hpp @@ -26,7 +26,7 @@ struct MorehSumBackward { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate_with_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/deprecated/tt_numpy/functions.hpp b/ttnn/cpp/ttnn/deprecated/tt_numpy/functions.hpp index 3ba2b7f6bf2..b1607e9d1f9 100644 --- a/ttnn/cpp/ttnn/deprecated/tt_numpy/functions.hpp +++ b/ttnn/cpp/ttnn/deprecated/tt_numpy/functions.hpp @@ -24,7 +24,6 @@ using tt_metal::Device; using tt_metal::Layout; using tt_metal::MemoryConfig; using tt_metal::OwnedStorage; -using tt_metal::Shape; using tt_metal::StorageType; using tt_metal::Tensor; namespace detail { @@ -51,7 +50,7 @@ constexpr static DataType get_data_type() { template static Tensor full( uint8_t queue_id, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, T value, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -108,7 +107,7 @@ static Tensor full( template static Tensor full_impl( uint8_t queue_id, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const T value, const DataType data_type, const Layout layout = Layout::ROW_MAJOR, @@ -139,7 +138,7 @@ static Tensor full_impl( template static Tensor full( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const T value, const DataType data_type, const Layout layout = Layout::ROW_MAJOR, @@ -150,7 +149,7 @@ static Tensor full( } static Tensor zeros( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const DataType data_type = DataType::BFLOAT16, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -160,7 +159,7 @@ static Tensor zeros( } static Tensor ones( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const DataType data_type = DataType::BFLOAT16, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -253,7 +252,7 @@ static Tensor arange( template static Tensor index_trilu( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const int32_t diag, DataType data_type, const Layout layout = Layout::ROW_MAJOR, @@ -292,7 +291,7 @@ static Tensor index_trilu( template static Tensor index_width( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -328,7 +327,7 @@ static Tensor index_width( template static Tensor index_height( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -364,7 +363,7 @@ static Tensor index_height( template static Tensor index_all( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -399,8 +398,8 @@ static Tensor index_all( template static Tensor mask_padded_input( - const Shape& padded_shape, - const Shape& unpadded_shape, + const tt::tt_metal::LegacyShape& padded_shape, + const tt::tt_metal::LegacyShape& unpadded_shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -441,7 +440,7 @@ static Tensor fill_first_val_into_tensor( Device* device = nullptr, const MemoryConfig& output_mem_config = MemoryConfig{ .memory_layout = tt::tt_metal::TensorMemoryLayout::INTERLEAVED}) { - const Shape& s_a = input_tensor.get_legacy_shape(); + const tt::tt_metal::LegacyShape& s_a = input_tensor.get_legacy_shape(); auto owned_buffer = tt_metal::owned_buffer::create(tt_metal::compute_volume(s_a)); // ouput auto device_buffer = input_tensor.device_buffer(); uint32_t size_in_bytes = device_buffer->size(); @@ -455,7 +454,7 @@ static Tensor fill_first_val_into_tensor( tt::tt_metal::tensor_impl::read_data_from_device_buffer(device_buffer, data_vec); } auto input_buffer = owned_buffer::create(std::move(data_vec)); - const Shape input_tensor_strides = input_tensor.strides(); + const tt::tt_metal::LegacyShape input_tensor_strides = input_tensor.strides(); for (uint32_t i = 0; i < tt_metal::compute_volume(s_a); i++) { owned_buffer[i] = input_buffer[0]; } @@ -474,7 +473,7 @@ static Tensor prod_result_computation_GS( Device* device = nullptr, const MemoryConfig& output_mem_config = MemoryConfig{ .memory_layout = tt::tt_metal::TensorMemoryLayout::INTERLEAVED}) { - const Shape& s_a = input_tensor.get_legacy_shape(); + const tt::tt_metal::LegacyShape& s_a = input_tensor.get_legacy_shape(); auto owned_buffer = tt_metal::owned_buffer::create(tt_metal::compute_volume(s_a)); // ouput auto device_buffer = input_tensor.device_buffer(); uint32_t size_in_bytes = device_buffer->size(); @@ -488,7 +487,7 @@ static Tensor prod_result_computation_GS( tt::tt_metal::tensor_impl::read_data_from_device_buffer(device_buffer, data_vec); } auto input_buffer = owned_buffer::create(std::move(data_vec)); - const Shape input_tensor_strides = input_tensor.strides(); + const tt::tt_metal::LegacyShape input_tensor_strides = input_tensor.strides(); auto result = static_cast(1.0f); for (uint32_t i = s_a[0] - 1; i < s_a[0]; i++) { for (int32_t j = s_a[1] - 1; j < s_a[1]; j++) { @@ -523,7 +522,7 @@ static Tensor prod_result_computation_WH_B0( Device* device = nullptr, const MemoryConfig& output_mem_config = MemoryConfig{ .memory_layout = tt::tt_metal::TensorMemoryLayout::INTERLEAVED}) { - const Shape& s_a = input_tensor.get_legacy_shape(); + const tt::tt_metal::LegacyShape& s_a = input_tensor.get_legacy_shape(); auto owned_buffer = tt_metal::owned_buffer::create(tt_metal::compute_volume(s_a)); // ouput auto device_buffer = input_tensor.device_buffer(); uint32_t size_in_bytes = device_buffer->size(); @@ -537,7 +536,7 @@ static Tensor prod_result_computation_WH_B0( tt::tt_metal::tensor_impl::read_data_from_device_buffer(device_buffer, data_vec); } auto input_buffer = owned_buffer::create(std::move(data_vec)); - const Shape input_tensor_strides = input_tensor.strides(); + const tt::tt_metal::LegacyShape input_tensor_strides = input_tensor.strides(); auto result = static_cast(1.0f); // need to access the last 4 rows and alternating columns of index 17 ,19, 21, 23, 25, 27, 29, 31 for (uint32_t i = s_a[0] - 1; i < s_a[0]; i++) { @@ -570,7 +569,7 @@ static Tensor prod_result_computation_WH_B0( template static Tensor index_channel( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -606,7 +605,7 @@ static Tensor index_channel( template static Tensor index_batch( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -642,7 +641,7 @@ static Tensor index_batch( template static Tensor manual_insertion( const Tensor& input_tensor, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, const Layout layout = Layout::ROW_MAJOR, Device* device = nullptr, @@ -673,7 +672,7 @@ static Tensor manual_insertion( template static Tensor index_tril( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const int32_t diag, DataType data_type, const Layout layout = Layout::ROW_MAJOR, @@ -685,7 +684,7 @@ static Tensor index_tril( template static Tensor index_triu( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, const int32_t diag, DataType data_type, const Layout layout = Layout::ROW_MAJOR, @@ -702,7 +701,7 @@ inline auto RANDOM_GENERATOR = std::mt19937(0); static void seed(std::size_t seed) { RANDOM_GENERATOR = std::mt19937(seed); } template -static Tensor uniform(T low, T high, const Shape& shape, const Layout layout = Layout::ROW_MAJOR) { +static Tensor uniform(T low, T high, const tt::tt_metal::LegacyShape& shape, const Layout layout = Layout::ROW_MAJOR) { constexpr DataType data_type = detail::get_data_type(); auto owned_buffer = tt_metal::owned_buffer::create(tt_metal::compute_volume(shape)); @@ -729,7 +728,7 @@ static Tensor uniform(T low, T high, const Shape& shape, const Layout layout = L } static Tensor random( - const Shape& shape, const DataType data_type = DataType::BFLOAT16, const Layout layout = Layout::ROW_MAJOR) { + const tt::tt_metal::LegacyShape& shape, const DataType data_type = DataType::BFLOAT16, const Layout layout = Layout::ROW_MAJOR) { switch (data_type) { case DataType::UINT8: return uniform(uint8_t(0), uint8_t(1), shape, layout); case DataType::UINT16: return uniform(uint16_t(0), uint16_t(1), shape, layout); diff --git a/ttnn/cpp/ttnn/multi_device.cpp b/ttnn/cpp/ttnn/multi_device.cpp index 032270a0912..fe77a9f5fe4 100644 --- a/ttnn/cpp/ttnn/multi_device.cpp +++ b/ttnn/cpp/ttnn/multi_device.cpp @@ -57,7 +57,7 @@ Tensor aggregate_as_tensor(std::vector& tensor_shards) // we want to use MultiDeviceHostStorage or MultiDeviceStorage StorageType storage_type = tensor_shards.at(0).storage_type(); if (storage_type == StorageType::OWNED) { - std::vector shapes; + std::vector shapes; std::vector host_owned_buffers; for (const auto &shard : tensor_shards) { host_owned_buffers.push_back(std::get(shard.get_storage()).buffer); @@ -67,7 +67,7 @@ Tensor aggregate_as_tensor(std::vector& tensor_shards) return Tensor(std::move(storage), tensor_shards.at(0).get_legacy_shape(), tensor_shards.at(0).get_dtype(), tensor_shards.at(0).get_layout()); } else { std::vector ordered_device_ids; - std::unordered_map shapes; + std::unordered_map shapes; std::unordered_map device_buffers; for (const auto &shard : tensor_shards) { Device* device = std::get(shard.get_storage()).buffer->device(); diff --git a/ttnn/cpp/ttnn/operation.hpp b/ttnn/cpp/ttnn/operation.hpp index ab63f411a4d..5f5efc1b85e 100644 --- a/ttnn/cpp/ttnn/operation.hpp +++ b/ttnn/cpp/ttnn/operation.hpp @@ -395,7 +395,7 @@ struct DeviceOperation final { this->type_erased_storage, input_tensors, optional_input_tensors, optional_output_tensors); } - inline const std::vector compute_output_shapes(const Tensors& input_tensors) const { + inline const std::vector compute_output_shapes(const Tensors& input_tensors) const { return this->compute_output_shapes_impl_(this->type_erased_storage, input_tensors); } @@ -544,7 +544,7 @@ struct DeviceOperation final { } }}, compute_output_shapes_impl_{ - [](const storage_t& storage, const Tensors& input_tensors) -> const std::vector { + [](const storage_t& storage, const Tensors& input_tensors) -> const std::vector { const auto& operation = *reinterpret_cast*>(&storage); return operation.compute_output_shapes(input_tensors); }}, @@ -753,7 +753,7 @@ struct DeviceOperation final { const Tensors&, const std::vector>&, const OptionalTensors&); - const std::vector (*compute_output_shapes_impl_)(const storage_t& value, const Tensors&); + const std::vector (*compute_output_shapes_impl_)(const storage_t& value, const Tensors&); const OutputTensors (*create_output_tensors_impl_)(const storage_t& value, const Tensors&, const OptionalTensors&); CacheableProgram (*create_program_impl_)( diff --git a/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.cpp b/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.cpp index 0a7ab607625..ecc4f9698f6 100644 --- a/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.cpp +++ b/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.cpp @@ -157,10 +157,10 @@ void AllGather::validate(const std::vector &input_tensors) const { } } -std::vector AllGather::compute_output_shapes(const std::vector &input_tensors) const { +std::vector AllGather::compute_output_shapes(const std::vector &input_tensors) const { auto shape = input_tensors[0].get_legacy_shape(); shape[this->dim] *= this->ring_size; - return std::vector(input_tensors.size(), shape); + return std::vector(input_tensors.size(), shape); } std::vector AllGather::create_output_tensors(const std::vector &input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.hpp b/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.hpp index 2397acc04a9..0c504add2e3 100644 --- a/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.hpp +++ b/ttnn/cpp/ttnn/operations/ccl/all_gather/device/all_gather_op.hpp @@ -136,7 +136,7 @@ struct AllGather { const all_gather_op::Topology topology; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/ccl/ccl_common.cpp b/ttnn/cpp/ttnn/operations/ccl/ccl_common.cpp index 1bbfde486bf..1354f7efc7d 100644 --- a/ttnn/cpp/ttnn/operations/ccl/ccl_common.cpp +++ b/ttnn/cpp/ttnn/operations/ccl/ccl_common.cpp @@ -536,7 +536,7 @@ std::vector RingReduceScatterBaseTensorSlicer::cre } std::vector RingReduceScatterTensorSlicer::create_worker_slice_shapes_for_tile_layout( - tt::tt_metal::Shape const& tensor_shape, + tt::tt_metal::LegacyShape const& tensor_shape, tt_xy_pair const& tensor_slice_shape_in_tiles, uint32_t num_workers, uint32_t max_slice_size_in_pages, @@ -747,7 +747,7 @@ std::vector RingReduceScatterTensorSlicer::create_worker_slice_shape } std::vector RingReduceScatterWrappedTensorSlicer::create_worker_slice_shapes_for_tile_layout( - tt::tt_metal::Shape const& tensor_shape, + tt::tt_metal::LegacyShape const& tensor_shape, tt_xy_pair const& tensor_slice_shape_in_tiles, uint32_t num_workers, uint32_t max_slice_size_in_pages, diff --git a/ttnn/cpp/ttnn/operations/ccl/ccl_common.hpp b/ttnn/cpp/ttnn/operations/ccl/ccl_common.hpp index bce52480851..5fc77deb4b7 100644 --- a/ttnn/cpp/ttnn/operations/ccl/ccl_common.hpp +++ b/ttnn/cpp/ttnn/operations/ccl/ccl_common.hpp @@ -74,9 +74,9 @@ class CclOpShardedTensorConfig final : public virtual CclOpTensorConfig { struct CclTensorSlicer { CclTensorSlicer( - tt::tt_metal::Shape tensor_shape, - tt::tt_metal::Shape dim_slice_factors, - // tt::tt_metal::Shape page_shape, + tt::tt_metal::LegacyShape tensor_shape, + tt::tt_metal::LegacyShape dim_slice_factors, + // tt::tt_metal::LegacyShape page_shape, std::size_t num_pages, std::size_t elem_size, std::size_t page_size_in_bytes) : @@ -103,12 +103,12 @@ struct CclTensorSlicer { return n; } - tt::tt_metal::Shape const tensor_shape; - tt::tt_metal::Shape const dim_slice_factors_per_rank; - // tt::tt_metal::Shape const page_shape; + tt::tt_metal::LegacyShape const tensor_shape; + tt::tt_metal::LegacyShape const dim_slice_factors_per_rank; + // tt::tt_metal::LegacyShape const page_shape; std::size_t const num_pages; - // tt::tt_metal::Shape rank_slice_shape; + // tt::tt_metal::LegacyShape rank_slice_shape; std::size_t const page_size_in_bytes; std::size_t const elem_size; @@ -274,7 +274,7 @@ class RingReduceScatterBaseTensorSlicer : public LegacyCclTensorSlicer { std::vector const& worker_slice_shapes, tt_xy_pair const& tensor_slice_shape); static std::vector create_worker_slice_shapes_for_tile_layout( - tt::tt_metal::Shape const& tensor_shape, + tt::tt_metal::LegacyShape const& tensor_shape, tt_xy_pair const& tensor_slice_shape_in_tiles, uint32_t num_workers, uint32_t max_slice_size_in_pages, @@ -313,7 +313,7 @@ class RingReduceScatterTensorSlicer : public RingReduceScatterBaseTensorSlicer const& worker_slice_shapes, tt_xy_pair const& tensor_slice_shape); static std::vector create_worker_slice_shapes_for_tile_layout( - tt::tt_metal::Shape const& tensor_shape, + tt::tt_metal::LegacyShape const& tensor_shape, tt_xy_pair const& tensor_slice_shape_in_tiles, uint32_t num_workers, uint32_t max_slice_size_in_pages, @@ -341,7 +341,7 @@ class RingReduceScatterWrappedTensorSlicer : public RingReduceScatterBaseTensorS std::vector const& worker_slice_shapes, tt_xy_pair const& tensor_slice_shape); static std::vector create_worker_slice_shapes_for_tile_layout( - tt::tt_metal::Shape const& tensor_shape, + tt::tt_metal::LegacyShape const& tensor_shape, tt_xy_pair const& tensor_slice_shape_in_tiles, uint32_t num_workers, uint32_t max_slice_size_in_pages, diff --git a/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.cpp b/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.cpp index c8dd27d2c0d..27e8920a1d8 100644 --- a/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.cpp +++ b/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.cpp @@ -50,10 +50,10 @@ void LineAllGather::validate(const std::vector &input_tensors) const { } } -std::vector LineAllGather::compute_output_shapes(const std::vector &input_tensors) const { +std::vector LineAllGather::compute_output_shapes(const std::vector &input_tensors) const { auto shape = input_tensors[0].get_legacy_shape(); shape[this->dim] *= this->ring_size; - return std::vector(input_tensors.size(), shape); + return std::vector(input_tensors.size(), shape); } std::vector LineAllGather::create_output_tensors(const std::vector &input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.hpp b/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.hpp index 7982f7d4bb8..4278448c9fa 100644 --- a/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.hpp +++ b/ttnn/cpp/ttnn/operations/ccl/line_all_gather/device/line_all_gather_op.hpp @@ -42,7 +42,7 @@ struct LineAllGather { const all_gather_op::Topology topology; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.cpp b/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.cpp index 84f5d3bc9c5..20279b557e3 100644 --- a/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.cpp +++ b/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.cpp @@ -24,13 +24,13 @@ void ReduceScatter::validate(const std::vector& input_tensors) const { } } -std::vector ReduceScatter::compute_output_shapes(const std::vector& input_tensors) const { +std::vector ReduceScatter::compute_output_shapes(const std::vector& input_tensors) const { auto shape = input_tensors[0].get_legacy_shape(); TT_ASSERT( shape[this->scatter_dim] % this->ring_size == 0, "The size of the scatter dimension must be a multiple of the ring size"); shape[this->scatter_dim] /= this->ring_size; - return std::vector(input_tensors.size(), shape); + return std::vector(input_tensors.size(), shape); } std::vector ReduceScatter::create_output_tensors(const std::vector& input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.hpp b/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.hpp index ae142fdae11..ba02c81aed8 100644 --- a/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.hpp +++ b/ttnn/cpp/ttnn/operations/ccl/reduce_scatter/device/reduce_scatter_op.hpp @@ -23,7 +23,7 @@ struct ReduceScatter { const ttnn::ccl::Topology topology; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.cpp b/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.cpp index aa5daf1510e..1cccd78b188 100644 --- a/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.cpp +++ b/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.cpp @@ -199,7 +199,7 @@ uint32_t get_num_cores_channels_from_parallel_config(const ParallelConfig& pconf } MemoryConfig create_sharded_memory_config_from_parallel_config( - const Shape& tensor_shape, ParallelConfig& parallel_config, uint32_t tile_size) { + const ttnn::Shape& tensor_shape, ParallelConfig& parallel_config, uint32_t tile_size) { log_debug(tt::LogOp, "create_sharded_memory_config_from_parallel_config: tensor_shape: {}, parallel_config: {}, tile_size: {}", tensor_shape, parallel_config, tile_size); // tensor_shape is [N, H, W, C] @@ -411,14 +411,14 @@ std::tuple get_conv_padded_input_shape_an tt::round_up(tensor_width, conv_config.input_channels_alignment); TT_ASSERT(input_tensor_width_snapped_to_channels_alignment >= tensor_width); - auto input_padded_shape = Shape(std::array{ + auto input_padded_shape = ttnn::Shape(std::array{ 1, 1, input_tensor_height_snapped_to_tile, input_tensor_width_snapped_to_channels_alignment}); // TODO: resolve ttnn::types::Shape and - // tt::tt_metal::Shape issue to clean up next line + // tt::tt_metal::LegacyShape issue to clean up next line auto input_tensor_sharded_memory_config = create_sharded_memory_config_from_parallel_config( - Shape(std::array{ + ttnn::Shape(std::array{ input_padded_shape[0], input_padded_shape[1], input_padded_shape[2], input_padded_shape[3]}), parallel_config, 32); @@ -452,7 +452,7 @@ std::tuple shard_or_reshard_tensor_if_requir // reshape to [1, 1, N*H*W, C] input_tensor = ttnn::operations::core::reshape( input_tensor, - Shape(std::array{ + ttnn::Shape(std::array{ 1, 1, input_tensor.get_shape()[0] * input_tensor.get_shape()[1] * input_tensor.get_shape()[2], @@ -555,7 +555,7 @@ std::pair> prepare_conv_weights_biases uint32_t in_channels = weights_shape[1]; uint32_t window_h = weights_shape[2]; uint32_t window_w = weights_shape[3]; - tt::tt_metal::Shape weights_channels_padded_shape = tt::tt_metal::Shape(std::array( + tt::tt_metal::LegacyShape weights_channels_padded_shape = tt::tt_metal::LegacyShape(std::array( {tt::round_up(out_channels, 32), tt::round_up(in_channels, input_channels_alignment), window_h, window_w})); if (weights_bias_dtype == DataType::BFLOAT8_B) { @@ -586,7 +586,7 @@ std::pair> prepare_conv_weights_biases bias_tensor_ = bias_tensor.value(); auto bias_shape = bias_tensor_.get_shape(); TT_ASSERT(bias_shape[3] == out_channels && bias_shape[0] == 1 && bias_shape[1] == 1 && bias_shape[2] == 1); - tt::tt_metal::Shape bias_channels_padded_shape = tt::tt_metal::Shape( + tt::tt_metal::LegacyShape bias_channels_padded_shape = tt::tt_metal::LegacyShape( std::array({1, 1, 32, tt::round_up(out_channels, weight_block_w_ntiles * 32)})); bias_tensor_ = ttnn::pad(bias_tensor_, bias_channels_padded_shape.to_array_4D(), tt::tt_metal::Array4D({0, 0, 0, 0}), 0); bias_tensor_ = ttnn::to_layout( @@ -670,7 +670,7 @@ std::tuple{1, 1, batch_size * output_height * output_width, tt::round_up(out_channels, 32)}), + ttnn::Shape(std::array{1, 1, batch_size * output_height * output_width, tt::round_up(out_channels, 32)}), parallel_config, 32); auto opt_conv_op_parallel_config = determine_conv_op_parallel_config_from_conv_output_mem_config( diff --git a/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.hpp b/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.hpp index eb1613dbc86..97302a83727 100644 --- a/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.hpp +++ b/ttnn/cpp/ttnn/operations/conv/conv2d/conv2d.hpp @@ -117,7 +117,7 @@ uint32_t get_num_cores_nhw_from_parallel_config(const sliding_window::ParallelCo uint32_t get_num_cores_channels_from_parallel_config(const sliding_window::ParallelConfig& pconfig); -MemoryConfig create_sharded_memory_config_from_parallel_config(const Shape& tensor_shape, sliding_window::ParallelConfig& parallel_config, uint32_t tile_size); +MemoryConfig create_sharded_memory_config_from_parallel_config(const ttnn::Shape& tensor_shape, sliding_window::ParallelConfig& parallel_config, uint32_t tile_size); OptimizedConvParallelizationConfig determine_conv_op_parallel_config_from_conv_output_mem_config(const MemoryConfig& conv_output_mem_config, uint32_t num_cores_nhw); diff --git a/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_sharded_v2.cpp b/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_sharded_v2.cpp index e96f8904cda..9d1fab94d26 100644 --- a/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_sharded_v2.cpp +++ b/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_sharded_v2.cpp @@ -40,7 +40,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_width_sharded_v2_impl( tt_metal::Program& program, const Tensor& a, const Tensor& b, - const Shape& ashape, + const ttnn::Shape& ashape, std::optional bias, const std::optional conv_reader_indices, sliding_window::SlidingWindowConfig sliding_window_config, @@ -337,7 +337,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_sharded_v2_impl( tt_metal::Program& program, const Tensor& a, const Tensor& b, - const Shape& ashape, + const ttnn::Shape& ashape, std::optional bias, const std::optional conv_reader_indices, sliding_window::SlidingWindowConfig sliding_window_config, @@ -516,7 +516,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_sharded_v2_impl( block_config.act_block_h_ntiles % block_config.out_subblock_h_ntiles == 0, "Out_block_h must be divisible by out_subblock_h!"); } - Shape ashape_with_channels_padded(std::vector({ashape[0], ashape[1], ashape[2], input_channels_padded})); + ttnn::Shape ashape_with_channels_padded(std::vector({ashape[0], ashape[1], ashape[2], input_channels_padded})); uint32_t conv_act_size_h = ashape_with_channels_padded[1]; uint32_t conv_act_size_w = ashape_with_channels_padded[2]; uint32_t conv_act_size_c = ashape_with_channels_padded[3]; @@ -528,7 +528,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_sharded_v2_impl( uint32_t pad_w = (uint32_t)sliding_window_config.pad_hw.second; uint32_t dilation_h = (uint32_t)sliding_window_config.dilation_hw.first; uint32_t dilation_w = (uint32_t)sliding_window_config.dilation_hw.second; - + // Compute the 2d matrix shape auto [act_matrix_shape, act_matrix_shape_unpadded] = optimized_conv_op_utils::compute_opt_conv_activation_as_mm_shape( @@ -1734,7 +1734,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_sharded_v2_new( program, a, b, - Shape(input_tensor_shape), + ttnn::Shape(input_tensor_shape), bias, conv_reader_indices_tensor, sliding_window_config, @@ -1758,7 +1758,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_sharded_v2_new( program, a, b, - Shape(input_tensor_shape), + ttnn::Shape(input_tensor_shape), bias, conv_reader_indices_tensor, sliding_window_config, diff --git a/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_width_sharded_v2.cpp b/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_width_sharded_v2.cpp index 40438d0fbd1..ed817b1b627 100644 --- a/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_width_sharded_v2.cpp +++ b/ttnn/cpp/ttnn/operations/conv/conv2d/device/multi_core_optimized_conv_sharded/optimized_conv_op_width_sharded_v2.cpp @@ -39,7 +39,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_width_sharded_v2_impl( tt_metal::Program& program, const Tensor& a, const Tensor& b, - const Shape& ashape, + const ttnn::Shape& ashape, std::optional bias, const std::optional conv_reader_indices, sliding_window::SlidingWindowConfig sliding_window_config, @@ -211,7 +211,7 @@ operation::ProgramWithCallbacks multi_core_optimized_conv_width_sharded_v2_impl( "Out_block_h must be divisible by out_subblock_h!"); } - Shape ashape_with_channels_padded(std::vector{ashape[0], ashape[1], ashape[2], input_channels_padded}); + ttnn::Shape ashape_with_channels_padded(std::vector{ashape[0], ashape[1], ashape[2], input_channels_padded}); uint32_t conv_act_size_h = ashape_with_channels_padded[1]; uint32_t conv_act_size_w = ashape_with_channels_padded[2]; diff --git a/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op.hpp b/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op.hpp index 93b0e33fdb9..d3b5c853eb9 100644 --- a/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op.hpp +++ b/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op.hpp @@ -106,7 +106,7 @@ struct OptimizedConvNew { enable_subblock_padding(enable_subblock_padding) {} void validate(const std::vector& input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, const std::vector>& optional_input_tensors, std::vector &output_tensors) const; @@ -177,7 +177,7 @@ using namespace tt::tt_metal; pair compute_opt_conv_output_face_shape(uint32_t conv_activation_h, uint32_t conv_activation_w, uint32_t filter_h, uint32_t filter_w, uint32_t stride_h, uint32_t stride_w, uint32_t pad_h, uint32_t pad_w, uint32_t padding_for_32B_alignment=0); -pair, vector> compute_opt_conv_activation_as_mm_shape(const Shape& conv_activation_shape, vector conv_params, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment); -pair, vector> compute_opt_conv_activation_as_mm_shape(const Shape& conv_activation_shape, ttnn::operations::sliding_window::SlidingWindowConfig sliding_window_config, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment); +pair, vector> compute_opt_conv_activation_as_mm_shape(const tt::tt_metal::LegacyShape& conv_activation_shape, vector conv_params, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment); +pair, vector> compute_opt_conv_activation_as_mm_shape(const tt::tt_metal::LegacyShape& conv_activation_shape, ttnn::operations::sliding_window::SlidingWindowConfig sliding_window_config, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment); } // optimized_conv_op_utils diff --git a/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op_program_factory.cpp b/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op_program_factory.cpp index 3ccf8bdd304..1d93f9b35f6 100644 --- a/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/conv/conv2d/device/optimized_conv_op_program_factory.cpp @@ -29,7 +29,7 @@ pair compute_opt_conv_output_face_shape(uint32_t conv_activa uint32_t conv_output_w = ((conv_activation_w - filter_w + (2 * pad_w) - padding_for_32B_alignment) / stride_w) + 1; return {conv_output_h, conv_output_w}; } -pair, vector> compute_opt_conv_activation_as_mm_shape(const Shape& conv_activation_shape, vector conv_params, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment) { +pair, vector> compute_opt_conv_activation_as_mm_shape(const tt::tt_metal::LegacyShape& conv_activation_shape, vector conv_params, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment) { uint32_t filter_h = (uint32_t) conv_params[0]; uint32_t filter_w = (uint32_t) conv_params[1]; uint32_t stride_h = (uint32_t) conv_params[2]; @@ -47,7 +47,7 @@ pair, vector> compute_opt_conv_activation_as_mm_shape return {{1, num_rows_padded, num_cols_padded}, {1, num_rows, num_cols}}; } -pair, vector> compute_opt_conv_activation_as_mm_shape(const Shape& conv_activation_shape, ttnn::operations::sliding_window::SlidingWindowConfig sliding_window_config, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment) { +pair, vector> compute_opt_conv_activation_as_mm_shape(const tt::tt_metal::LegacyShape& conv_activation_shape, ttnn::operations::sliding_window::SlidingWindowConfig sliding_window_config, uint32_t act_block_h_ntiles, uint32_t padding_for_32B_alignment) { uint32_t filter_h = (uint32_t)sliding_window_config.window_hw.first; // filter_h uint32_t filter_w = (uint32_t)sliding_window_config.window_hw.second; // filter_W @@ -96,8 +96,8 @@ Tensor optimized_conv_new(const Tensor& a, const Tensor &b, std::optional{ashape[0], ashape[1], ashape[2], tt::round_up(ashape[3], 16)}); + const auto& ashape = tt::tt_metal::LegacyShape(input_tensor_shape); + auto padded_a_shape = ttnn::Shape(std::array{ashape[0], ashape[1], ashape[2], tt::round_up(ashape[3], 16)}); FormatParams input_a_format_params = {.pad_shape=padded_a_shape.value, .pad_value=0.0, .target_layout=Layout::ROW_MAJOR}; FormatParams input_b_format_params = {.pad_shape=b.get_legacy_shape(), .pad_value=0.0, .target_layout=Layout::TILE}; FormatParams input_bias_format_params = {}; @@ -146,7 +146,7 @@ void OptimizedConvNew::validate(const std::vector& input_tensors, const } } -std::vector OptimizedConvNew::compute_output_shapes(const std::vector& input_tensors) const { +std::vector OptimizedConvNew::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor_a_shape = this->input_tensor_shape; uint32_t batch_size = input_tensor_a_shape[0]; uint32_t conv_activation_h = input_tensor_a_shape[1]; @@ -168,7 +168,7 @@ std::vector OptimizedConvNew::compute_output_shapes(const s auto padded_shape_c = tt::round_up(this->output_channels, TILE_WIDTH); auto output_padding = Padding( {{0, 0}, {0, 0}, {0, (padded_shape_w - shape_w)}, {0, (padded_shape_c - shape_c)}}, Padding::PadValue::Zero); - auto output_tensor_shape = Shape(tt::tt_metal::Shape({1, 1, padded_shape_w, padded_shape_c}, output_padding)); + auto output_tensor_shape = ttnn::Shape(tt::tt_metal::LegacyShape({1, 1, padded_shape_w, padded_shape_c}, output_padding)); return {output_tensor_shape.value}; } diff --git a/ttnn/cpp/ttnn/operations/core/to_layout/to_layout_op.cpp b/ttnn/cpp/ttnn/operations/core/to_layout/to_layout_op.cpp index f58fe6445c5..f55057eabff 100644 --- a/ttnn/cpp/ttnn/operations/core/to_layout/to_layout_op.cpp +++ b/ttnn/cpp/ttnn/operations/core/to_layout/to_layout_op.cpp @@ -146,7 +146,7 @@ Tensor to_layout_impl( tensor = ttnn::untilize_with_unpadding(tensor, output_tensor_end, output_memory_config, use_multicore_untilize); - return reshape(tensor, ttnn::Shape(tt::tt_metal::Shape{output_shape})); + return reshape(tensor, ttnn::Shape(tt::tt_metal::LegacyShape{output_shape})); } else if (layout == ttnn::TILE_LAYOUT) { std::vector padded_output_shape; @@ -161,7 +161,7 @@ Tensor to_layout_impl( tensor = ttnn::tilize_with_val_padding( tensor, padded_output_shape, 0, output_memory_config, dtype, use_multicore_tilize); - return reshape(tensor, ttnn::Shape(tt::tt_metal::Shape{output_shape, padded_output_shape})); + return reshape(tensor, ttnn::Shape(tt::tt_metal::LegacyShape{output_shape, padded_output_shape})); } else { TT_THROW("ttnn::to_layout: Unsupported output layout: {}!", layout); @@ -173,7 +173,7 @@ Tensor to_layout_impl( } else if (layout == ttnn::ROW_MAJOR_LAYOUT) { tensor = device ? tensor.to(layout, device) : tensor.to(layout); tensor = tensor.unpad_from_tile(tensor.get_shape().value.without_padding()); - return reshape(tensor, ttnn::Shape(tt::tt_metal::Shape{output_shape})); + return reshape(tensor, ttnn::Shape(tt::tt_metal::LegacyShape{output_shape})); } else if (layout == ttnn::TILE_LAYOUT) { std::vector padded_output_shape; std::vector padded_input_start; @@ -187,7 +187,7 @@ Tensor to_layout_impl( } tensor = tensor.pad(padded_output_shape, padded_input_start, 0); tensor = device ? tensor.to(layout, device) : tensor.to(layout); - return reshape(tensor, ttnn::Shape(tt::tt_metal::Shape{output_shape, padded_output_shape})); + return reshape(tensor, ttnn::Shape(tt::tt_metal::LegacyShape{output_shape, padded_output_shape})); } else { TT_THROW("ttnn::to_layout: Unsupported output layout: {}!", layout); diff --git a/ttnn/cpp/ttnn/operations/core/work_split/work_split_tilize.hpp b/ttnn/cpp/ttnn/operations/core/work_split/work_split_tilize.hpp index a89bdd91306..c10f45983b1 100644 --- a/ttnn/cpp/ttnn/operations/core/work_split/work_split_tilize.hpp +++ b/ttnn/cpp/ttnn/operations/core/work_split/work_split_tilize.hpp @@ -176,7 +176,7 @@ struct FullRep { }; inline std::vector> distribute_work( - const tt::tt_metal::Shape& unpadded, const Padding& padding, uint32_t num_cores, uint32_t blocks_per_core, bool has_cliff, uint32_t nblocks_per_core_cliff) { + const tt::tt_metal::LegacyShape& unpadded, const Padding& padding, uint32_t num_cores, uint32_t blocks_per_core, bool has_cliff, uint32_t nblocks_per_core_cliff) { auto input_w = unpadded.rank() >= 4 ? unpadded[-4] : 1; auto input_z = unpadded.rank() >= 3 ? unpadded[-3] : 1; auto input_y = unpadded.rank() >= 2 ? unpadded[-2] : 1; diff --git a/ttnn/cpp/ttnn/operations/creation.hpp b/ttnn/cpp/ttnn/operations/creation.hpp index 25f98c42c67..e629e77a2b2 100644 --- a/ttnn/cpp/ttnn/operations/creation.hpp +++ b/ttnn/cpp/ttnn/operations/creation.hpp @@ -68,7 +68,7 @@ inline ttnn::Tensor full_impl( Device* device = optional_output_tensor.has_value() ? optional_output_tensor.value().device() : device_arg.has_value() ? &(device_arg.value().get()) : nullptr; Layout layout_value = optional_output_tensor.has_value() ? optional_output_tensor.value().get_layout() : layout.value_or(ttnn::ROW_MAJOR_LAYOUT); DataType dtype_value = optional_output_tensor.has_value() ? optional_output_tensor.value().get_dtype() : dtype.value_or(ttnn::bfloat16); - tt::tt_metal::Shape shape_value = optional_output_tensor.has_value() ? optional_output_tensor.value().get_legacy_shape() : shape.value; + tt::tt_metal::LegacyShape shape_value = optional_output_tensor.has_value() ? optional_output_tensor.value().get_legacy_shape() : shape.value; MemoryConfig mem_cfg = optional_output_tensor.has_value() ? optional_output_tensor.value().memory_config() : memory_config.value_or(ttnn::DRAM_MEMORY_CONFIG); return tt::numpy::full_impl( queue_id, diff --git a/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.cpp b/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.cpp index f3a4af2ce58..0a310ac4b75 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.cpp @@ -47,7 +47,7 @@ void EltwiseBinaryBroadcast::validate_with_output_tensors(const std::vector output_shape_required = this->compute_output_shapes(input_tensors); + const std::vector output_shape_required = this->compute_output_shapes(input_tensors); const auto& out_tensor = output_tensors.at(0).value(); TT_FATAL(out_tensor.get_legacy_shape() == output_shape_required.at(0), "The input tensors need a shape of {}, however the output tensor is only {}", output_shape_required, out_tensor.get_legacy_shape()); } @@ -109,7 +109,7 @@ void EltwiseBinaryBroadcast::validate_with_output_tensors(const std::vector EltwiseBinaryBroadcast::compute_output_shapes(const std::vector &input_tensors) const { +std::vector EltwiseBinaryBroadcast::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.hpp b/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.hpp index c2356c755a2..a7fcb22f395 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/bcast/device/bcast_device_operation.hpp @@ -29,7 +29,7 @@ struct EltwiseBinaryBroadcast { const bool in_place; void validate_with_output_tensors(const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.cpp b/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.cpp index 169c1b156dc..472b107a4e6 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.cpp @@ -24,7 +24,7 @@ ConcatOpParallelizationStrategy ConcatDeviceOperation::get_parallelization_strat void ConcatDeviceOperation::validate(const std::vector &input_tensors) const { const auto &first_input = input_tensors[0]; - tt::tt_metal::Shape shape_first = first_input.get_legacy_shape(); + tt::tt_metal::LegacyShape shape_first = first_input.get_legacy_shape(); TT_FATAL(this->dim < shape_first.rank(), "ConcatDeviceOperation dim specified is larger than input tensor rank."); shape_first[this->dim] = 0; bool shard_first = input_tensors[0].is_sharded(); @@ -36,7 +36,7 @@ void ConcatDeviceOperation::validate(const std::vector &input_tensors) c TT_FATAL(in_ref.device() == first_input.device(), "Operands to concat need to be on the same device."); TT_FATAL(in_ref.get_layout() == first_input.get_layout(), "All Tensors should have same layouts."); TT_FATAL(in_ref.get_dtype() == first_input.get_dtype(), "All Tensors should have same dtypes."); - tt::tt_metal::Shape curr_shape = in_ref.get_legacy_shape(); + tt::tt_metal::LegacyShape curr_shape = in_ref.get_legacy_shape(); TT_FATAL(curr_shape.rank() == shape_first.rank(), "Input tensor ranks must be equal"); curr_shape[this->dim] = 0; // last tensor can support without any kernel changes @@ -61,11 +61,11 @@ void ConcatDeviceOperation::validate(const std::vector &input_tensors) c } } -std::vector ConcatDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { - tt::tt_metal::Shape shape_out = input_tensors[0].get_legacy_shape(); +std::vector ConcatDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { + tt::tt_metal::LegacyShape shape_out = input_tensors[0].get_legacy_shape(); shape_out[this->dim] = 0; for (const Tensor &in_ref : input_tensors) { - tt::tt_metal::Shape curr_shape = in_ref.get_legacy_shape(); + tt::tt_metal::LegacyShape curr_shape = in_ref.get_legacy_shape(); shape_out[this->dim] += curr_shape[this->dim]; } return {shape_out}; @@ -143,7 +143,7 @@ Tensor concat_impl(std::vector &input_tensors, const std::int64_t dim, c .pad_value = 0.0, .target_layout = target_layout}); } else { - tt::tt_metal::Shape pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(input_tensor.get_legacy_shape()); + tt::tt_metal::LegacyShape pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(input_tensor.get_legacy_shape()); input_format_params.push_back( ttnn::operations::experimental::auto_format::FormatParams{.pad_shape = pad_shape, .pad_value = 0.0, .target_layout = target_layout}); } diff --git a/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.hpp b/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.hpp index fcb5618b4af..0e5a35500a1 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/concat/device/concat_device_operation.hpp @@ -15,7 +15,7 @@ struct ConcatDeviceOperation { uint32_t dim; const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.cpp b/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.cpp index 75186da89fe..6109ad685e4 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.cpp @@ -44,7 +44,7 @@ void CopyDeviceOperation::validate_with_output_tensors(const std::vector TT_FATAL(out_mem_config.memory_layout == TensorMemoryLayout::INTERLEAVED, "Copy does not currently support sharding"); } -std::vector CopyDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector CopyDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { if (input_tensors.size() == 2) { return {input_tensors[1].get_legacy_shape()}; } else { diff --git a/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.hpp b/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.hpp index 696bd5de7c3..5d80f25ebc1 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/copy/device/copy_device_operation.hpp @@ -23,7 +23,8 @@ struct CopyDeviceOperation { const DataType output_dtype; void validate_with_output_tensors(const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector create_output_tensors(const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; CopyOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.cpp index 008e50a2d01..bcfe3f71ca5 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.cpp @@ -78,8 +78,8 @@ void FillRM::validate(const std::vector &input_tensors) const { TT_FATAL(this->output_mem_config.memory_layout == TensorMemoryLayout::INTERLEAVED, "FillRM does not currently support sharding"); } -std::vector FillRM::compute_output_shapes(const std::vector &input_tensors) const { - tt::tt_metal::Shape output_shape = {this->N, this->C, this->H, this->W}; +std::vector FillRM::compute_output_shapes(const std::vector &input_tensors) const { + tt::tt_metal::LegacyShape output_shape = {this->N, this->C, this->H, this->W}; return {output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.hpp index 23a100ce07a..bef18e06649 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/fill_rm/device/fill_rm_op.hpp @@ -26,7 +26,7 @@ struct FillRM { const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.cpp index b7e1e8fb7a6..a4deb4e6a16 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.cpp @@ -50,7 +50,7 @@ Fold::shape_return_value_t Fold::compute_output_shapes(const operation_attribute auto input_tensor = tensors.input_tensor; const Shape &input_shape = Shape(input_tensor.get_legacy_shape()); // we concatenate (stride_h sticks in H-dim) * (stride_w in W-dim) into 1 stick along C-dim - Shape output_shape = Shape(tt::tt_metal::Shape({1, 1, input_shape[0] * input_shape[1] * input_shape[2] / (op_attr.stride_h * op_attr.stride_w), input_shape[3] * op_attr.stride_h * op_attr.stride_w})); + Shape output_shape = Shape(tt::tt_metal::LegacyShape({1, 1, input_shape[0] * input_shape[1] * input_shape[2] / (op_attr.stride_h * op_attr.stride_w), input_shape[3] * op_attr.stride_h * op_attr.stride_w})); return output_shape; } @@ -82,7 +82,7 @@ std::tuple const ttnn::Tensor &input_tensor, uint32_t stride_h, uint32_t stride_w, - const std::optional &output_shape, + const std::optional &output_shape, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w) { diff --git a/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.hpp index a5d511a76e5..87b1e13294f 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/fold/device/fold_device_op.hpp @@ -76,7 +76,7 @@ struct Fold { const ttnn::Tensor& input_tensor, uint32_t stride_h, uint32_t stride_w, - const std::optional& output_shape, + const std::optional& output_shape, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w); diff --git a/ttnn/cpp/ttnn/operations/data_movement/fold/fold.cpp b/ttnn/cpp/ttnn/operations/data_movement/fold/fold.cpp index c3ce7aecd11..8bdbdaf59db 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/fold/fold.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/fold/fold.cpp @@ -19,7 +19,7 @@ namespace ttnn::operations::data_movement { std::vector fold_with_transpose_( - uint8_t queue_id, const Tensor& input, const std::optional& output_shape, uint32_t stride_h, uint32_t stride_w, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w) { + uint8_t queue_id, const Tensor& input, const std::optional& output_shape, uint32_t stride_h, uint32_t stride_w, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w) { using namespace tt::constants; Device * device; @@ -131,7 +131,7 @@ ttnn::MemoryConfig create_sharded_memory_config(ttnn::Shape tensor_shape, CoreCo } std::vector fold_with_transpose_sharded_( - uint8_t queue_id, const Tensor& input, const std::optional& output_shape, uint32_t stride_h, uint32_t stride_w, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w, CoreCoord grid_size, const std::optional override_memory_config) { + uint8_t queue_id, const Tensor& input, const std::optional& output_shape, uint32_t stride_h, uint32_t stride_w, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w, CoreCoord grid_size, const std::optional override_memory_config) { using namespace tt::constants; Device * device; @@ -285,7 +285,7 @@ Tensor FoldOperation::invoke(uint8_t queue_id, uint32_t stride_h, uint32_t stride_w, bool use_transpose_as_fold, - const std::optional &output_shape, + const std::optional &output_shape, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w, @@ -309,7 +309,7 @@ Tensor FoldOperation::invoke(const ttnn::Tensor &input_tensor, uint32_t stride_h, uint32_t stride_w, bool use_transpose_as_fold, - const std::optional &output_shape, + const std::optional &output_shape, uint32_t pad_c, uint32_t pad_h, uint32_t pad_w, diff --git a/ttnn/cpp/ttnn/operations/data_movement/fold/fold.hpp b/ttnn/cpp/ttnn/operations/data_movement/fold/fold.hpp index 23ae50892dc..e23e9aff858 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/fold/fold.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/fold/fold.hpp @@ -23,7 +23,7 @@ struct FoldOperation { uint32_t stride_h, uint32_t stride_w, bool use_transpose_as_fold = false, - const std::optional &output_shape = std::nullopt, + const std::optional &output_shape = std::nullopt, uint32_t pad_c = 0, uint32_t pad_h = 0, uint32_t pad_w = 0, @@ -35,7 +35,7 @@ struct FoldOperation { uint32_t stride_h, uint32_t stride_w, bool use_transpose_as_fold = false, - const std::optional &output_shape = std::nullopt, + const std::optional &output_shape = std::nullopt, uint32_t pad_c = 0, uint32_t pad_h = 0, uint32_t pad_w = 0, diff --git a/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.cpp index c3ee7ee7fbe..52d757020eb 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.cpp @@ -28,7 +28,7 @@ void IndexedFill::validate(const std::vector &input_tensors) const { TT_FATAL(input_tensor_a.memory_config().memory_layout == TensorMemoryLayout::INTERLEAVED, "Index Fill does not currently support sharding"); } -std::vector IndexedFill::compute_output_shapes(const std::vector &input_tensors) const { +std::vector IndexedFill::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(1); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.hpp index cc27a7b594a..7644fcc8a7e 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/indexed_fill/device/indexed_fill_op.hpp @@ -13,7 +13,7 @@ struct IndexedFill { const MemoryConfig output_mem_config; const int64_t dim; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.cpp b/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.cpp index 350f403a932..a0cc69edb59 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.cpp @@ -15,7 +15,7 @@ void MoveDeviceOperation::validate(const std::vector &input_tensors) con const auto& input_tensor_a = input_tensors.at(0); } -std::vector MoveDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector MoveDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.hpp b/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.hpp index 3b872c694bf..f3704578f05 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/move/device/move_device_operation.hpp @@ -21,7 +21,7 @@ struct MoveDeviceOperation { const MoveOpParallelizationStrategy move_op_parallelization_strategy; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; MoveOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.cpp index 192e448bcc4..27be12387fe 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.cpp @@ -21,9 +21,9 @@ void NonZeroIndices::validate(const std::vector &input_tensors) const { TT_FATAL(input_tensor_a.memory_config().memory_layout == TensorMemoryLayout::INTERLEAVED, "Non-zero does not currently support sharding"); } -std::vector NonZeroIndices::compute_output_shapes(const std::vector &input_tensors) const { +std::vector NonZeroIndices::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); - tt::tt_metal::Shape num_non_zero_shape({1,1,1,8}); + tt::tt_metal::LegacyShape num_non_zero_shape({1,1,1,8}); return {num_non_zero_shape, input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.hpp index dcaeca479cc..a12bd14ac6e 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/non_zero_indices/device/non_zero_indices_op.hpp @@ -19,7 +19,7 @@ namespace operations::data_movement { struct NonZeroIndices { const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.cpp index 6e44aa28c27..87735ab19fe 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.cpp @@ -44,8 +44,8 @@ void Pad::validate_with_output_tensors( } } -std::vector Pad::compute_output_shapes(const std::vector& input_tensors) const { - return {tt::tt_metal::Shape(this->output_tensor_shape)}; +std::vector Pad::compute_output_shapes(const std::vector& input_tensors) const { + return {tt::tt_metal::LegacyShape(this->output_tensor_shape)}; } std::vector Pad::create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.hpp index 493ed5af947..b4ba5a3ced3 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_op.hpp @@ -12,14 +12,14 @@ namespace ttnn::operations::data_movement { struct Pad { - const tt::tt_metal::Shape output_tensor_shape; - const tt::tt_metal::Shape input_tensor_start; + const tt::tt_metal::LegacyShape output_tensor_shape; + const tt::tt_metal::LegacyShape input_tensor_start; const float pad_value; const MemoryConfig output_mem_config; const bool use_multicore; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.cpp b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.cpp index 84ebda5c50d..0bd5839f471 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.cpp @@ -16,8 +16,8 @@ namespace ttnn::operations::data_movement::detail { operation::ProgramWithCallbacks pad_rm_reader_writer(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value) { Program program{}; @@ -388,7 +388,7 @@ operation::ProgramWithCallbacks pad_rm(const Tensor &a, Tensor &output, const Sh return {std::move(program), override_runtime_args_callback}; } -operation::ProgramWithCallbacks pad_tile(const Tensor &a, Tensor& output, const tt::tt_metal::Shape &output_tensor_shape, const tt::tt_metal::Shape &input_tensor_start, const float pad_value) { +operation::ProgramWithCallbacks pad_tile(const Tensor &a, Tensor& output, const tt::tt_metal::LegacyShape &output_tensor_shape, const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value) { tt::tt_metal::Program program{}; @@ -637,8 +637,8 @@ inline std::tuple, std::vector > > get_runtime_args_rm(const Tensor &input_tensor, Tensor &output_tensor, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &input_tensor_start, uint32_t num_cores_total, uint32_t num_cores, uint32_t num_cores_y, @@ -974,8 +974,8 @@ std::vector, std::vector > > get_runti operation::ProgramWithCallbacks pad_rm_reader_writer_multi_core_v2(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value) { Program program{}; @@ -1160,7 +1160,7 @@ inline std::vector> group_contiguous_and_repeated_values(s inline std::vector, std::vector>> get_pad_runtime_args_rm_sharded( const Tensor& input_tensor, Tensor& output_tensor, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &input_tensor_start, uint32_t num_cores_padded, bool row_major, uint32_t num_cores_x_padded, @@ -1320,8 +1320,8 @@ inline std::vector, std::vector>> get_ operation::ProgramWithCallbacks pad_rm_sharded(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value) { Program program{}; diff --git a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.hpp b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.hpp index 18e7495c04d..3aadc72228e 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/pad/device/pad_program_factory.hpp @@ -9,8 +9,8 @@ namespace ttnn::operations::data_movement::detail { operation::ProgramWithCallbacks pad_rm_reader_writer(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value); @@ -22,27 +22,27 @@ operation::ProgramWithCallbacks pad_rm_opt(const Tensor &a, operation::ProgramWithCallbacks pad_rm(const Tensor &a, Tensor &output, const Shape &output_tensor_shape, const Shape &input_tensor_start, const float pad_value); -operation::ProgramWithCallbacks pad_tile(const Tensor &a, Tensor& output, const tt::tt_metal::Shape &output_tensor_shape, const tt::tt_metal::Shape &input_tensor_start, const float pad_value); +operation::ProgramWithCallbacks pad_tile(const Tensor &a, Tensor& output, const tt::tt_metal::LegacyShape &output_tensor_shape, const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value); operation::ProgramWithCallbacks pad_rm_reader_writer_multi_core(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value); operation::ProgramWithCallbacks pad_rm_reader_writer_multi_core_v2(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value); operation::ProgramWithCallbacks pad_rm_sharded(const Tensor &a, Tensor &output, - const tt::tt_metal::Shape &output_tensor_shape, - const tt::tt_metal::Shape &input_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_shape, + const tt::tt_metal::LegacyShape &input_tensor_start, const float pad_value); diff --git a/ttnn/cpp/ttnn/operations/data_movement/pad/pad.cpp b/ttnn/cpp/ttnn/operations/data_movement/pad/pad.cpp index 49d4fa537b5..3ddc894af9f 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/pad/pad.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/pad/pad.cpp @@ -30,7 +30,7 @@ static ttnn::Tensor pad_impl( return input_tensor; } else { - return input_tensor.pad(tt::tt_metal::Shape(output_padded_shape), tt::tt_metal::Shape(input_tensor_start), value); + return input_tensor.pad(tt::tt_metal::LegacyShape(output_padded_shape), tt::tt_metal::LegacyShape(input_tensor_start), value); } } // on device @@ -42,7 +42,7 @@ static ttnn::Tensor pad_impl( auto memory_config = memory_config_arg.value_or(input_tensor.memory_config()); auto output_tensor = operation::run( - Pad{tt::tt_metal::Shape(output_padded_shape), tt::tt_metal::Shape(input_tensor_start), value, memory_config, use_multicore}, + Pad{tt::tt_metal::LegacyShape(output_padded_shape), tt::tt_metal::LegacyShape(input_tensor_start), value, memory_config, use_multicore}, {input_tensor}, {}, {}, queue_id).front(); return output_tensor; @@ -149,7 +149,7 @@ ttnn::Tensor ExecutePad::invoke( }; remove_first_elements(shape, rank_diff); remove_first_elements(padded_shape, rank_diff); - auto squeezedShape = ttnn::Shape(tt::tt_metal::Shape(shape, padded_shape)); + auto squeezedShape = ttnn::Shape(tt::tt_metal::LegacyShape(shape, padded_shape)); output_tensor = ttnn::reshape(output_tensor, squeezedShape); } diff --git a/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.cpp index ba3508c786b..a43a1eb67db 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.cpp @@ -14,7 +14,7 @@ namespace ttnn::operations::data_movement { void RepeatDeviceOperation::validate(const std::vector &input_tensors) const { const auto &input_tensor = input_tensors[0]; - tt::tt_metal::Shape input_shape = input_tensor.get_legacy_shape(); + tt::tt_metal::LegacyShape input_shape = input_tensor.get_legacy_shape(); TT_FATAL(this->repeat_dim < input_shape.rank(), "Repeat dim specified is larger than input tensor rank."); if (input_tensor.get_layout() == Layout::ROW_MAJOR && this->repeat_dim == input_shape.rank() - 1) { TT_FATAL( @@ -32,8 +32,8 @@ void RepeatDeviceOperation::validate(const std::vector &input_tensors) c "Output of repeat must be interleaved."); } -std::vector RepeatDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { - tt::tt_metal::Shape shape_out = input_tensors[0].get_legacy_shape(); +std::vector RepeatDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { + tt::tt_metal::LegacyShape shape_out = input_tensors[0].get_legacy_shape(); shape_out[this->repeat_dim] *= this->num_repeats; return {shape_out}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.hpp index 4597d85843c..92cb8272fd6 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/repeat/device/repeat_op.hpp @@ -17,7 +17,7 @@ struct RepeatDeviceOperation { const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; @@ -25,4 +25,3 @@ struct RepeatDeviceOperation { }; } // namespace tt_metal - diff --git a/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.cpp index 6f107d0ebf0..93c71eaf236 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.cpp @@ -41,7 +41,7 @@ void ReshapeDeviceOperation::validate(const std::vector &input_tensors) } -std::vector ReshapeDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector ReshapeDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor_a = input_tensors.at(0); return {tt::tt_metal::infer_dims_for_reshape(this->N, this->C, this->H, this->W, input_tensor_a.volume())}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.hpp index 4435736cce0..3a4e88fe7a1 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_op.hpp @@ -15,7 +15,7 @@ struct ReshapeDeviceOperation { const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_program_factory.cpp b/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_program_factory.cpp index 19063387952..ceafc7420d2 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/reshape/device/reshape_program_factory.cpp @@ -26,7 +26,7 @@ operation::ProgramWithCallbacks reshape_tile_single_core(const Tensor &a, Tensor // This should allocate a DRAM buffer on the device tt::tt_metal::Device *device = a.device(); - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Buffer *dst_buffer = output.buffer(); TT_ASSERT(dst_buffer != nullptr, "Output buffer should be allocated on device!"); @@ -111,7 +111,7 @@ operation::ProgramWithCallbacks reshape_rm_single_core(const Tensor &a, Tensor& // This should allocate a DRAM buffer on the device tt::tt_metal::Device *device = a.device(); - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Buffer *src0_buffer = a.buffer(); tt::tt_metal::Buffer *dst_buffer = output.buffer(); @@ -365,7 +365,7 @@ operation::ProgramWithCallbacks reshape_rm_multi_core(const Tensor &a, Tensor& o tt::tt_metal::Device *device = a.device(); - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Buffer *src0_buffer = a.buffer(); tt::tt_metal::Buffer *dst_buffer = output.buffer(); diff --git a/ttnn/cpp/ttnn/operations/data_movement/reshape/reshape.cpp b/ttnn/cpp/ttnn/operations/data_movement/reshape/reshape.cpp index 5a8e1c7a328..d9b3310ce25 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/reshape/reshape.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/reshape/reshape.cpp @@ -19,7 +19,7 @@ namespace detail { static Tensor manual_insertion( const Tensor& input_tensor, - const tt::tt_metal::Shape& shape, + const tt::tt_metal::LegacyShape& shape, Device* device, const MemoryConfig& output_mem_config ) { @@ -59,7 +59,7 @@ ttnn::Tensor ReshapeOperation::invoke( using namespace tt::constants; auto output_mem_config = memory_config_arg.value_or(input_tensor.memory_config()); // No-op (Will do a tensor copy) - tt::tt_metal::Shape output_shape = tt::tt_metal::infer_dims_for_reshape(N, C, H, W, input_tensor.volume()); + tt::tt_metal::LegacyShape output_shape = tt::tt_metal::infer_dims_for_reshape(N, C, H, W, input_tensor.volume()); if ( ((input_tensor.get_layout() == Layout::TILE or input_tensor.get_layout() == Layout::ROW_MAJOR) && output_shape[3] == input_tensor.get_legacy_shape()[3]) ) { diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.cpp index 54662e3081b..db668c88245 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.cpp @@ -28,7 +28,7 @@ void InterleavedToShardedDeviceOperation::validate(const std::vector& in } -std::vector InterleavedToShardedDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector InterleavedToShardedDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.hpp index 4b5bf3b9878..481ce55d736 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.hpp @@ -12,7 +12,7 @@ struct InterleavedToShardedDeviceOperation { const DataType output_dtype; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.cpp index 7bff6b73f3d..4a2d48c5634 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.cpp @@ -36,7 +36,7 @@ void ReshardDeviceOperation::validate_with_output_tensors(const std::vector ReshardDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector ReshardDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.hpp index b095c3077bc..ecfe4f19333 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded/reshard/device/reshard_op.hpp @@ -10,7 +10,7 @@ struct ReshardDeviceOperation { const MemoryConfig output_mem_config; void validate_with_output_tensors(const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.cpp index 72ac1c19bbf..5989017d10c 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.cpp @@ -28,7 +28,7 @@ void ShardedToInterleavedDeviceOperation::validate(const std::vector& in } -std::vector ShardedToInterleavedDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector ShardedToInterleavedDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.hpp index d272b57bdaf..1b0043d4d88 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.hpp @@ -11,7 +11,7 @@ struct ShardedToInterleavedDeviceOperation { const DataType output_dtype; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.cpp index a0e79ceb5d6..043dea332b1 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.cpp @@ -32,9 +32,9 @@ void InterleavedToShardedPartialDeviceOperation::validate(const std::vector InterleavedToShardedPartialDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector InterleavedToShardedPartialDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); - tt::tt_metal::Shape shape = input_tensor.get_legacy_shape(); + tt::tt_metal::LegacyShape shape = input_tensor.get_legacy_shape(); uint32_t total_height = input_tensor.volume() / shape[-1]; uint32_t new_height = total_height / this->num_slices; diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.hpp index 7c7411bc1dc..66f56ef8522 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.hpp @@ -20,7 +20,7 @@ struct InterleavedToShardedPartialDeviceOperation { const DataType output_dtype; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.cpp index fef47a9e487..220036be692 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.cpp @@ -37,7 +37,7 @@ void ShardedToInterleavedPartialDeviceOperation::validate(const std::vector ShardedToInterleavedPartialDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector ShardedToInterleavedPartialDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& output_tensor = input_tensors.at(1); return {output_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.hpp index 64a8864167a..8994aab3042 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.hpp @@ -17,7 +17,7 @@ struct ShardedToInterleavedPartialDeviceOperation { const DataType output_dtype; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.cpp index 5daf4892728..da5acf1a77a 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.cpp @@ -8,7 +8,7 @@ namespace ttnn::operations::data_movement { -inline __attribute__((always_inline)) uint32_t get_upper_dims_compressed(const tt::tt_metal::Shape& shape) { +inline __attribute__((always_inline)) uint32_t get_upper_dims_compressed(const tt::tt_metal::LegacyShape& shape) { return std::accumulate(shape.begin(), shape.end() - 2, 1, std::multiplies{}); } @@ -112,7 +112,7 @@ void SliceDeviceOperation::validate_with_output_tensors( } } -std::vector SliceDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector SliceDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { std::vector out_shape; auto rank = input_tensors[0].get_legacy_shape().rank(); out_shape.reserve(rank); @@ -133,7 +133,7 @@ std::vector SliceDeviceOperation::compute_output_shapes(con out_shape.push_back(output_dim_i(i)); } } - tt::tt_metal::Shape output_tensor_shape(out_shape); + tt::tt_metal::LegacyShape output_tensor_shape(out_shape); return {output_tensor_shape}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.hpp index 87df12b422f..88ef3613ce7 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_op.hpp @@ -15,14 +15,14 @@ uint32_t get_rm_start_offset(const Tensor &tensor, const Shape &slice_start); uint32_t get_tiled_start_offset(const Tensor &input_tensor, const Shape &slice_start); struct SliceDeviceOperation { - const tt::tt_metal::Shape slice_start; - const tt::tt_metal::Shape slice_end; - const std::optional step; + const tt::tt_metal::LegacyShape slice_start; + const tt::tt_metal::LegacyShape slice_end; + const std::optional step; const MemoryConfig output_mem_config; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.cpp b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.cpp index 26e0aaabc2c..4701e2e4b7d 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.cpp @@ -18,7 +18,7 @@ namespace ttnn::operations::data_movement::detail { inline std::vector, std::vector>> get_slice_runtime_args_rm( const Tensor& input_tensor, Tensor& output_tensor, - const tt::tt_metal::Shape& output_tensor_start, + const tt::tt_metal::LegacyShape& output_tensor_start, uint32_t num_cores_total, uint32_t num_cores, uint32_t num_cores_y, @@ -127,8 +127,8 @@ inline std::vector, std::vector>> get_ } operation::ProgramWithCallbacks slice_rm_multi_core( - const Tensor& a, Tensor& output, const tt::tt_metal::Shape& output_tensor_start, const tt::tt_metal::Shape& output_tensor_end) { - const tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + const Tensor& a, Tensor& output, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { + const tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Program program = tt::tt_metal::CreateProgram(); @@ -261,11 +261,11 @@ operation::ProgramWithCallbacks slice_rm_multi_core( return {.program = std::move(program), .override_runtime_arguments_callback = override_runtime_args_callback}; } -operation::ProgramWithCallbacks slice_rm_strided_single_core(const Tensor& a, Tensor& output, const tt::tt_metal::Shape& output_tensor_start, const tt::tt_metal::Shape& output_tensor_end, const tt::tt_metal::Shape& step) { +operation::ProgramWithCallbacks slice_rm_strided_single_core(const Tensor& a, Tensor& output, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end, const tt::tt_metal::LegacyShape& step) { // TODO: multi core implementation - work division is not trivial as we need to determine the N/C/H/W start and end points for each split, and base that off stride tt::tt_metal::Program program = tt::tt_metal::CreateProgram(); - const tt::tt_metal::Shape output_shape = output.get_legacy_shape(); - const tt::tt_metal::Shape input_shape = a.get_legacy_shape(); + const tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); + const tt::tt_metal::LegacyShape input_shape = a.get_legacy_shape(); tt::DataFormat cb_data_format = tt::tt_metal::datatype_to_dataformat_converter(a.get_dtype()); uint32_t src_is_dram = a.buffer()->buffer_type() == tt::tt_metal::BufferType::DRAM ? 1 : 0; @@ -392,7 +392,7 @@ inline std::vector> group_contiguous_values(std::vector, std::vector>> get_slice_runtime_args_rm_sharded( const Tensor& input_tensor, Tensor& output_tensor, - const tt::tt_metal::Shape& output_tensor_start, + const tt::tt_metal::LegacyShape& output_tensor_start, uint32_t num_cores_unpadded, bool row_major, uint32_t num_cores_x_unpadded, @@ -548,8 +548,8 @@ inline std::vector, std::vector>> get_ } operation::ProgramWithCallbacks slice_rm_multi_core_sharded( - const Tensor& a, Tensor& output, const tt::tt_metal::Shape& output_tensor_start, const tt::tt_metal::Shape& output_tensor_end) { - const tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + const Tensor& a, Tensor& output, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { + const tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Program program = tt::tt_metal::CreateProgram(); @@ -682,7 +682,7 @@ template inline __attribute__((always_inline)) void set_slice_runtime_args_tile( const Tensor& input_tensor, const Tensor& output_tensor, - const tt::tt_metal::Shape& output_tensor_start, + const tt::tt_metal::LegacyShape& output_tensor_start, const uint32_t& num_cores_total, const uint32_t& num_cores, const std::vector& cores, @@ -825,8 +825,8 @@ inline __attribute__((always_inline)) void set_slice_runtime_args_tile( } operation::ProgramWithCallbacks slice_tile_multi_core( - const Tensor& a, Tensor& output, const tt::tt_metal::Shape& output_tensor_start, const tt::tt_metal::Shape& output_tensor_end) { - const tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + const Tensor& a, Tensor& output, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { + const tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Program program = tt::tt_metal::CreateProgram(); @@ -949,8 +949,8 @@ operation::ProgramWithCallbacks slice_tile_multi_core( } operation::ProgramWithCallbacks slice_multi_core( - const Tensor& a, Tensor& output, const tt::tt_metal::Shape& output_tensor_start, const tt::tt_metal::Shape& output_tensor_end, const std::optional& step) { - const std::optional step_modified = step.has_value() ? (std::all_of(step->begin(), step->end(), [](int32_t i) { return i == 1; }) ? std::nullopt : step ): std::nullopt; + const Tensor& a, Tensor& output, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end, const std::optional& step) { + const std::optional step_modified = step.has_value() ? (std::all_of(step->begin(), step->end(), [](int32_t i) { return i == 1; }) ? std::nullopt : step ): std::nullopt; switch (a.get_layout()) { case Layout::ROW_MAJOR: return a.is_sharded() ? slice_rm_multi_core_sharded(a, output, output_tensor_start, output_tensor_end) : diff --git a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.hpp b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.hpp index 32961138127..753c90988fb 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/slice/device/slice_program_factory.hpp @@ -7,6 +7,6 @@ namespace ttnn::operations::data_movement::detail { -operation::ProgramWithCallbacks slice_multi_core(const Tensor& a, Tensor& output, const tt::tt_metal::Shape& output_tensor_start, const tt::tt_metal::Shape& output_tensor_end, const std::optional& step); +operation::ProgramWithCallbacks slice_multi_core(const Tensor& a, Tensor& output, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end, const std::optional& step); } // namespace ttnn::operations::data_movement::detail diff --git a/ttnn/cpp/ttnn/operations/data_movement/slice/slice.cpp b/ttnn/cpp/ttnn/operations/data_movement/slice/slice.cpp index d346cb947f8..dd54890d327 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/slice/slice.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/slice/slice.cpp @@ -15,11 +15,11 @@ namespace ttnn::operations::data_movement { ttnn::Tensor SliceOperation::invoke( uint8_t queue_id, const ttnn::Tensor& input_tensor, - tt::tt_metal::Shape output_tensor_start, - tt::tt_metal::Shape output_tensor_end, - const std::optional step, + tt::tt_metal::LegacyShape output_tensor_start, + tt::tt_metal::LegacyShape output_tensor_end, + const std::optional step, const std::optional& memory_config_arg) { - std::optional modified_step = step; + std::optional modified_step = step; if (modified_step.has_value()) { if (std::all_of(modified_step->begin(), modified_step->end(), [](int32_t s) { return s == 1; })) { modified_step = std::nullopt; @@ -27,7 +27,7 @@ ttnn::Tensor SliceOperation::invoke( } if (input_tensor.storage_type() != StorageType::DEVICE) { TT_FATAL(!modified_step.has_value(), "Host tensor slice does not support strides"); - tt::tt_metal::Shape output_tensor_shape = { + tt::tt_metal::LegacyShape output_tensor_shape = { output_tensor_end[0] - output_tensor_start[0] + 1, output_tensor_end[1] - output_tensor_start[1] + 1, output_tensor_end[2] - output_tensor_start[2] + 1, @@ -67,7 +67,7 @@ ttnn::Tensor SliceOperation::invoke( std::size_t unpad_val = input_tensor_shape[-2] - output_tensor_end[-2] - 1; new_shape[-2] -= unpad_val; new_pad[-2].back -= std::min(unpad_val, new_pad[-2].back); - auto padded_shape = ttnn::Shape(tt::tt_metal::Shape(new_shape, new_pad)); + auto padded_shape = ttnn::Shape(tt::tt_metal::LegacyShape(new_shape, new_pad)); return Tensor(input_tensor.storage(), padded_shape, input_tensor.dtype(), input_tensor.layout()); } } @@ -81,9 +81,9 @@ ttnn::Tensor SliceOperation::invoke( ttnn::Tensor SliceOperation::invoke( const ttnn::Tensor& input_tensor, - tt::tt_metal::Shape output_tensor_start, - tt::tt_metal::Shape output_tensor_end, - const std::optional step, + tt::tt_metal::LegacyShape output_tensor_start, + tt::tt_metal::LegacyShape output_tensor_end, + const std::optional step, const std::optional& memory_config_arg) { return invoke(0, input_tensor, output_tensor_start, output_tensor_end, step, memory_config_arg); } @@ -98,9 +98,9 @@ ttnn::Tensor SliceOperation::invoke( return invoke( queue_id, input_tensor, - tt::tt_metal::Shape(output_tensor_start), - tt::tt_metal::Shape(output_tensor_end), - step.has_value() ? std::optional(tt::tt_metal::Shape(step.value())) : std::nullopt, + tt::tt_metal::LegacyShape(output_tensor_start), + tt::tt_metal::LegacyShape(output_tensor_end), + step.has_value() ? std::optional(tt::tt_metal::LegacyShape(step.value())) : std::nullopt, memory_config_arg); } @@ -114,9 +114,9 @@ ttnn::Tensor SliceOperation::invoke( return invoke( queue_id, input_tensor, - tt::tt_metal::Shape(output_tensor_start), - tt::tt_metal::Shape(output_tensor_end), - step.has_value() ? std::optional(tt::tt_metal::Shape(step.value())) : std::nullopt, + tt::tt_metal::LegacyShape(output_tensor_start), + tt::tt_metal::LegacyShape(output_tensor_end), + step.has_value() ? std::optional(tt::tt_metal::LegacyShape(step.value())) : std::nullopt, memory_config_arg); } diff --git a/ttnn/cpp/ttnn/operations/data_movement/slice/slice.hpp b/ttnn/cpp/ttnn/operations/data_movement/slice/slice.hpp index a1bb86dd1de..c01889d92e1 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/slice/slice.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/slice/slice.hpp @@ -14,16 +14,16 @@ struct SliceOperation { static ttnn::Tensor invoke( uint8_t queue_id, const ttnn::Tensor& input_tensor, - tt::tt_metal::Shape output_tensor_start, - tt::tt_metal::Shape output_tensor_end, - const std::optional step, + tt::tt_metal::LegacyShape output_tensor_start, + tt::tt_metal::LegacyShape output_tensor_end, + const std::optional step, const std::optional& memory_config_arg); static ttnn::Tensor invoke( const ttnn::Tensor& input_tensor, - tt::tt_metal::Shape output_tensor_start, - tt::tt_metal::Shape output_tensor_end, - const std::optional step, + tt::tt_metal::LegacyShape output_tensor_start, + tt::tt_metal::LegacyShape output_tensor_end, + const std::optional step, const std::optional& memory_config_arg); static ttnn::Tensor invoke( diff --git a/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.cpp index d6556abf8cf..ae7db6381f2 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.cpp @@ -33,13 +33,13 @@ void SplitDeviceOperation::validate(const std::vector &input_tensors) co } -std::vector SplitDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector SplitDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto &input_tensor = input_tensors.at(0); auto input_shape_array = input_tensor.get_legacy_shape().to_array_4D(); auto output_shape_array = input_shape_array; output_shape_array[this->dim] /= this->num_splits; - tt::tt_metal::Shape output_shape(output_shape_array); - std::vector output_shape_vector(this->num_splits, output_shape); + tt::tt_metal::LegacyShape output_shape(output_shape_array); + std::vector output_shape_vector(this->num_splits, output_shape); return output_shape_vector; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.hpp index 4eac089d7f2..79722424c2c 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/split/device/split_op.hpp @@ -16,7 +16,7 @@ struct SplitDeviceOperation { const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.cpp index 38623ef19ac..084d6b98e12 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.cpp @@ -35,7 +35,7 @@ void Tilize::validate(const std::vector& input_tensors) const { } } -std::vector Tilize::compute_output_shapes(const std::vector& input_tensors) const { +std::vector Tilize::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor_a = input_tensors.at(0); auto output_shape = input_tensor_a.get_legacy_shape(); return {output_shape}; diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.hpp index eb2ad178af3..7d2953d8039 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize/device/tilize_op.hpp @@ -17,7 +17,7 @@ struct Tilize { const bool use_multicore; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors( const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.cpp index 51868943118..c9c4ae977b8 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.cpp @@ -44,7 +44,7 @@ void TilizeWithValPadding::validate(const std::vector& input_tensors) co } } -std::vector TilizeWithValPadding::compute_output_shapes( +std::vector TilizeWithValPadding::compute_output_shapes( const std::vector& input_tensors) const { auto input_shape = input_tensors.at(0).get_legacy_shape(); auto dimensions_pads = std::vector(); @@ -53,7 +53,7 @@ std::vector TilizeWithValPadding::compute_output_shapes( dimensions_pads.push_back(Padding::PadDimension{.front = 0, .back = back}); } const auto padding = Padding(dimensions_pads, Padding::PadValue::Any); - return {tt::tt_metal::Shape(this->output_tensor_shape, padding)}; + return {tt::tt_metal::LegacyShape(this->output_tensor_shape, padding)}; } std::vector TilizeWithValPadding::create_output_tensors( diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.hpp index ae59a36a01f..7ebc24c013b 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/device/tilize_with_val_padding_op.hpp @@ -12,14 +12,14 @@ namespace ttnn::operations::data_movement { struct TilizeWithValPadding { - const tt::tt_metal::Shape output_tensor_shape; + const tt::tt_metal::LegacyShape output_tensor_shape; const float pad_value; const MemoryConfig output_mem_config; const DataType output_dtype; const bool use_multicore; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors( const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.cpp b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.cpp index 94417d67872..d00d8b842aa 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.cpp @@ -13,7 +13,7 @@ namespace ttnn::operations::data_movement { ttnn::Tensor ExecuteTilizeWithValPadding::invoke( uint8_t queue_id, const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_shape, + const tt::tt_metal::LegacyShape &output_tensor_shape, float pad_value, const std::optional &memory_config, std::optional output_dtype, @@ -34,7 +34,7 @@ ttnn::Tensor ExecuteTilizeWithValPadding::invoke( ttnn::Tensor ExecuteTilizeWithValPadding::invoke( const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_shape, + const tt::tt_metal::LegacyShape &output_tensor_shape, float pad_value, const std::optional &memory_config, std::optional output_dtype, diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.hpp b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.hpp index 725e1943abc..0e0a90a3aef 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding.hpp @@ -16,7 +16,7 @@ struct ExecuteTilizeWithValPadding { static ttnn::Tensor invoke( uint8_t queue_id, const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_shape, + const tt::tt_metal::LegacyShape &output_tensor_shape, float pad_value, const std::optional &memory_config = std::nullopt, std::optional output_dtype = std::nullopt, @@ -24,7 +24,7 @@ struct ExecuteTilizeWithValPadding { static ttnn::Tensor invoke( const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_shape, + const tt::tt_metal::LegacyShape &output_tensor_shape, float pad_value, const std::optional &memory_config = std::nullopt, std::optional output_dtype = std::nullopt, diff --git a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding_pybind.hpp b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding_pybind.hpp index 2cdfefceefe..a90e13d5232 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding_pybind.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/tilize_with_val_padding/tilize_with_val_padding_pybind.hpp @@ -44,7 +44,7 @@ void bind_tilize_with_val_padding(py::module &module) { ttnn::pybind_overload_t{ [](const OperationType &self, const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_shape, + const tt::tt_metal::LegacyShape &output_tensor_shape, float value, const std::optional &memory_config, std::optional output_dtype, diff --git a/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.cpp index 007ff57f259..561445ebe8f 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.cpp @@ -72,7 +72,7 @@ void Transpose::validate(const std::vector &input_tensors) const { } -std::vector Transpose::compute_output_shapes(const std::vector &input_tensors) const { +std::vector Transpose::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto out_shape = input_tensor.get_legacy_shape(); auto padding = out_shape.padding(); @@ -102,7 +102,7 @@ std::vector Transpose::compute_output_shapes(const std::vec std::swap(padding[1], padding[3]); break; } - return {tt::tt_metal::Shape(out_shape, padding)}; + return {tt::tt_metal::LegacyShape(out_shape, padding)}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.hpp index 6fc0dadab58..776509a6c80 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_op.hpp @@ -23,7 +23,7 @@ struct Transpose { const MemoryConfig output_mem_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; TransposeOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_program_factory.cpp b/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_program_factory.cpp index e2171f1249c..e862096b938 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/transpose/device/transpose_program_factory.cpp @@ -479,7 +479,7 @@ operation::ProgramWithCallbacks transpose_hc_multi_core(const Tensor &a, Tensor auto [num_cores, all_cores, core_group_1, core_group_2, num_tiles_per_core_group_1, num_tiles_per_core_group_2] = tt::tt_metal::split_work_to_cores(compute_with_storage_grid_size, row_major ? NCH : num_tensor_tiles); - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Buffer *dst_buffer = output.buffer(); TT_ASSERT(dst_buffer != nullptr, "Output buffer should be allocated on device!"); @@ -977,7 +977,7 @@ operation::ProgramWithCallbacks transpose_hc_multi_core_sharded(const Tensor &a, tt::log_debug("all_cores: {}", all_cores); tt::log_debug("num_cores: {}", num_cores); - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Buffer *dst_buffer = output.buffer(); @@ -1580,7 +1580,7 @@ operation::ProgramWithCallbacks transpose_wh_multi_core_sharded(const Tensor &a, uint32_t num_cores = all_cores.num_cores(); uint32_t num_tiles_per_shard = shard_spec.numel() / TILE_HW; - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::tt_metal::Buffer *dst_buffer = output.buffer(); @@ -1795,7 +1795,7 @@ operation::ProgramWithCallbacks transpose_wh_multi_core_sharded_rm(const Tensor tt::log_debug("all_cores: {}", all_cores); tt::log_debug("num_cores: {}", num_cores); - tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); // sharded cb uint32_t src0_cb_index = tt::CB::c_in0; diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.cpp index 4e42a2fc711..f320b2a3d52 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.cpp @@ -58,7 +58,7 @@ void Untilize::validate(const std::vector& input_tensors) const { } } -std::vector Untilize::compute_output_shapes(const std::vector& input_tensors) const { +std::vector Untilize::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor_a = input_tensors.at(0); return {input_tensor_a.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.hpp index 00b66c4ee8d..aedf838136d 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize/device/untilize_op.hpp @@ -24,7 +24,7 @@ struct Untilize { const bool fp32_dest_acc_en; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors( const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.cpp index 13567b36ad4..92d31327d3a 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.cpp @@ -28,7 +28,7 @@ void UntilizeWithHaloV2::validate(const std::vector& input_tensors) cons TT_FATAL(input_tensor.shard_spec().has_value(), "Error"); } -std::vector UntilizeWithHaloV2::compute_output_shapes( +std::vector UntilizeWithHaloV2::compute_output_shapes( const std::vector& input_tensors) const { const auto& input = input_tensors.at(0); const auto& input_shape = input.get_legacy_shape(); diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.hpp index b4fa6aaea8f..39c852c7ace 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_halo_v2/device/untilize_with_halo_v2_op.hpp @@ -21,7 +21,7 @@ struct UntilizeWithHaloV2 { const bool transpose_mcast_; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors( const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.cpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.cpp index d832544ea0f..0959a4998b8 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.cpp @@ -71,7 +71,7 @@ void UntilizeWithUnpadding::validate(const std::vector& input_tensors) c } } -std::vector UntilizeWithUnpadding::compute_output_shapes( +std::vector UntilizeWithUnpadding::compute_output_shapes( const std::vector& input_tensors) const { std::vector out_shape; auto rank = input_tensors[0].get_legacy_shape().rank(); @@ -79,7 +79,7 @@ std::vector UntilizeWithUnpadding::compute_output_shapes( for (uint32_t i = 0; i < rank; i++) { out_shape.push_back(this->output_tensor_end[i] + 1); } - tt::tt_metal::Shape output_tensor_shape(out_shape); + tt::tt_metal::LegacyShape output_tensor_shape(out_shape); return {output_tensor_shape}; } diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.hpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.hpp index 6a9647b5dab..ed782e29d0d 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/device/untilize_with_unpadding_op.hpp @@ -12,14 +12,14 @@ namespace ttnn::operations::data_movement { struct UntilizeWithUnpadding { - const tt::tt_metal::Shape output_tensor_end; + const tt::tt_metal::LegacyShape output_tensor_end; const MemoryConfig output_mem_config; const bool use_multicore; const bool use_pack_untilize; const bool fp32_dest_acc_en; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors( const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.cpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.cpp index 679a8e17118..6e9f899ac7d 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.cpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.cpp @@ -13,7 +13,7 @@ namespace ttnn::operations::data_movement { ttnn::Tensor ExecuteUntilizeWithUnpadding::invoke( uint8_t queue_id, const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_end, + const tt::tt_metal::LegacyShape &output_tensor_end, const std::optional &memory_config, bool use_multicore, bool use_pack_untilize) { @@ -36,7 +36,7 @@ ttnn::Tensor ExecuteUntilizeWithUnpadding::invoke( ttnn::Tensor ExecuteUntilizeWithUnpadding::invoke( const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_end, + const tt::tt_metal::LegacyShape &output_tensor_end, const std::optional &memory_config, bool use_multicore, bool use_pack_untilize) { diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.hpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.hpp index 10b992c994d..7fb555eee7d 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding.hpp @@ -13,14 +13,14 @@ struct ExecuteUntilizeWithUnpadding { static ttnn::Tensor invoke( uint8_t queue_id, const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_end, + const tt::tt_metal::LegacyShape &output_tensor_end, const std::optional &memory_config, bool use_multicore = false, bool use_pack_untilize = true); static ttnn::Tensor invoke( const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_end, + const tt::tt_metal::LegacyShape &output_tensor_end, const std::optional &memory_config, bool use_multicore = false, bool use_pack_untilize = true); diff --git a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding_pybind.hpp b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding_pybind.hpp index f50c4cf907a..a52baf40034 100644 --- a/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding_pybind.hpp +++ b/ttnn/cpp/ttnn/operations/data_movement/untilize_with_unpadding/untilize_with_unpadding_pybind.hpp @@ -43,7 +43,7 @@ void bind_untilize_with_unpadding(py::module &module) { ttnn::pybind_overload_t{ [](const OperationType &self, const ttnn::Tensor &input_tensor, - const tt::tt_metal::Shape &output_tensor_end, + const tt::tt_metal::LegacyShape &output_tensor_end, const std::optional &memory_config, bool use_multicore, bool use_pack_untilize, diff --git a/ttnn/cpp/ttnn/operations/eltwise/binary/device/binary_composite_op.cpp b/ttnn/cpp/ttnn/operations/eltwise/binary/device/binary_composite_op.cpp index ff332f23a55..0ee780bbe39 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/binary/device/binary_composite_op.cpp +++ b/ttnn/cpp/ttnn/operations/eltwise/binary/device/binary_composite_op.cpp @@ -326,9 +326,9 @@ Tensor _scatter(const Tensor& input_a, const Tensor& input_b, const std::optiona * by running reshape. */ Tensor _outer(const Tensor& input_a, const Tensor& input_b, const std::optional& output_mem_config) { - const tt::tt_metal::Shape s_a = input_a.get_legacy_shape(); - const tt::tt_metal::Shape s_b = input_b.get_legacy_shape(); - auto num_ones = [](const tt::tt_metal::Shape& s) -> uint32_t { + const tt::tt_metal::LegacyShape s_a = input_a.get_legacy_shape(); + const tt::tt_metal::LegacyShape s_b = input_b.get_legacy_shape(); + auto num_ones = [](const tt::tt_metal::LegacyShape& s) -> uint32_t { uint32_t num1s = 0; for (uint32_t idx = 0; idx < 4; idx++) num1s += (uint32_t)(s[idx] == 1); return num1s; diff --git a/ttnn/cpp/ttnn/operations/eltwise/unary/device/unary_composite_op.cpp b/ttnn/cpp/ttnn/operations/eltwise/unary/device/unary_composite_op.cpp index 107dc8476d7..7db39530a6a 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/unary/device/unary_composite_op.cpp +++ b/ttnn/cpp/ttnn/operations/eltwise/unary/device/unary_composite_op.cpp @@ -524,7 +524,7 @@ Tensor _threshold(const Tensor& input_tensor, float threshold, float value, cons std::vector split_tensor_for_glu(const Tensor& input_a, int32_t dim, const std::optional& output_mem_config) { std::vector t_split; - Shape inshape(input_a.get_legacy_shape()); + tt::tt_metal::LegacyShape inshape(input_a.get_legacy_shape()); TT_FATAL(((inshape[dim] / 2) % tt::constants::TILE_WIDTH == 0), "Split tensor dimension should be in full tile"); std::vector s_a = {0, 0, 0, 0}; std::vector e_a = {input_a.get_legacy_shape()[0] - 1, inshape[1] - 1, inshape[2] - 1, inshape[3] / 2 - 1}; diff --git a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.cpp b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.cpp index 0d5ff7d2260..bc8474c5b17 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.cpp +++ b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.cpp @@ -1394,7 +1394,7 @@ std::vector> ExecuteUnaryBackwardGelu::invoke( } std::vector _repeat_bw( - const Tensor& grad, const Tensor& input, const tt::tt_metal::Shape& shape, const std::optional& output_mem_config) { + const Tensor& grad, const Tensor& input, const tt::tt_metal::LegacyShape& shape, const std::optional& output_mem_config) { std::vector grad_tensor; auto output_memory_config = output_mem_config.value_or(input.memory_config()); //TODO: Remove after ternary forward ops migration is completed diff --git a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.hpp b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.hpp index 2931d8b6ad4..b09159b328a 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.hpp +++ b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/device/unary_backward_op.hpp @@ -157,7 +157,7 @@ std::vector _clamp_bw( const Tensor& grad, const Tensor& input, std::opt std::vector _rdiv_bw( const Tensor& grad, const Tensor& input, float scalar, string round_mode = "None", const std::optional& output_mem_config = std::nullopt); -std::vector _repeat_bw(const Tensor& grad, const Tensor& input, const tt::tt_metal::Shape& shape, const std::optional& output_mem_config); +std::vector _repeat_bw(const Tensor& grad, const Tensor& input, const tt::tt_metal::LegacyShape& shape, const std::optional& output_mem_config); std::vector _prod_bw( const Tensor& grad, const Tensor& input, bool all_dimensions = true, int64_t dim = 0, const std::optional& output_mem_config = std::nullopt); Tensor change_layout_to_tile(const Tensor& temp, const MemoryConfig& output_mem_config); @@ -609,7 +609,7 @@ struct OpHandler { template <> struct OpHandler { - static std::vector handle( const Tensor& grad, const Tensor& input, const tt::tt_metal::Shape& shape, const std::optional& output_mem_config ) { + static std::vector handle( const Tensor& grad, const Tensor& input, const tt::tt_metal::LegacyShape& shape, const std::optional& output_mem_config ) { return _repeat_bw(grad, input, shape, output_mem_config); } }; diff --git a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward.hpp b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward.hpp index 4311f4141dc..113bbb97ba6 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward.hpp +++ b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward.hpp @@ -163,7 +163,7 @@ struct ExecuteUnaryBackwardShape { static std::vector invoke( const Tensor &grad_tensor_arg, const Tensor &input_tensor_arg, - const tt::tt_metal::Shape ¶meter_a, + const tt::tt_metal::LegacyShape ¶meter_a, const std::optional &memory_config = std::nullopt) { auto output_memory_config = memory_config.value_or(input_tensor_arg.memory_config()); return OpHandler::handle(grad_tensor_arg, input_tensor_arg, parameter_a, output_memory_config); diff --git a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward_pybind.hpp b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward_pybind.hpp index 7f165fd83a4..98d334d99e3 100644 --- a/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward_pybind.hpp +++ b/ttnn/cpp/ttnn/operations/eltwise/unary_backward/unary_backward_pybind.hpp @@ -709,7 +709,7 @@ void bind_unary_backward_shape( [](const unary_backward_operation_t& self, const ttnn::Tensor& grad_tensor, const ttnn::Tensor& input_tensor, - const tt::tt_metal::Shape& parameter_a, + const tt::tt_metal::LegacyShape& parameter_a, const std::optional& memory_config) { return self(grad_tensor, input_tensor, parameter_a, memory_config); }, diff --git a/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.cpp b/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.cpp index cfb314564f0..c48775b4c90 100644 --- a/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.cpp @@ -45,14 +45,14 @@ void Embeddings::validate(const std::vector &input_tensors) const { } } -std::vector Embeddings::compute_output_shapes(const std::vector &input_tensors) const { +std::vector Embeddings::compute_output_shapes(const std::vector &input_tensors) const { const auto &input_tensor = input_tensors.at(0); const auto &weight_tensor = input_tensors.at(1); auto num_output_embeddings = input_tensor.get_legacy_shape()[3]; auto batch_num = input_tensor.get_legacy_shape()[0]; auto num_embedding_dims = weight_tensor.get_legacy_shape()[3]; - tt::tt_metal::Shape output_shape({batch_num, 1, num_output_embeddings, num_embedding_dims}); + tt::tt_metal::LegacyShape output_shape({batch_num, 1, num_output_embeddings, num_embedding_dims}); return {output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.hpp b/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.hpp index b69d3123a4a..9bacd2e4501 100644 --- a/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/embedding/device/embedding_device_operation.hpp @@ -24,7 +24,7 @@ struct Embeddings { const DataType output_dtype; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.cpp b/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.cpp index 4c896b95a1f..7f610c90fc2 100644 --- a/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.cpp @@ -68,12 +68,12 @@ void EmbeddingBackward::validate(const std::vector &input_tensors) const "Number of rows in gradient tensor must be equal to number of indices in index tensor"); } -std::vector EmbeddingBackward::compute_output_shapes( +std::vector EmbeddingBackward::compute_output_shapes( const std::vector &input_tensors) const { const auto &grad_tensor = input_tensors.at(1); auto embedding_dim = grad_tensor.get_legacy_shape()[-1]; - tt::tt_metal::Shape output_shape({1, 1, this->num_embeddings, embedding_dim}); + tt::tt_metal::LegacyShape output_shape({1, 1, this->num_embeddings, embedding_dim}); return {output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.hpp b/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.hpp index 56e40c9c434..d375e44fad1 100644 --- a/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/embedding_backward/device/embedding_backward_device_operation.hpp @@ -23,7 +23,7 @@ struct EmbeddingBackward { uint32_t num_embeddings; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.cpp b/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.cpp index 28bd6ef9843..d013e3462b3 100644 --- a/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.cpp @@ -51,14 +51,14 @@ Tensor AutoFormat::move_tensor_to_device_and_pad(const Tensor& input, Device *de (device_shape[-2] % TILE_HEIGHT != 0 ? (device_shape[-2] / TILE_HEIGHT + 1) * TILE_HEIGHT : device_shape[-2]), (device_shape[-1] % TILE_WIDTH != 0 ? (device_shape[-1] / TILE_WIDTH + 1) * TILE_WIDTH : device_shape[-1]) }; - const auto new_shape = tt::tt_metal::Shape(new_intended_shape, new_device_shape); + const auto new_shape = tt::tt_metal::LegacyShape(new_intended_shape, new_device_shape); return AutoFormat::format_input_tensor(input, device, new_shape, 0.0, target_layout, target_mem_config); } Tensor AutoFormat::format_input_tensor( const Tensor& input, Device* device, - const tt::tt_metal::Shape& padded_shape, + const tt::tt_metal::LegacyShape& padded_shape, float pad_value, Layout target_layout, std::optional target_mem_config) { @@ -122,7 +122,7 @@ Tensor AutoFormat::format_input_tensor( Tensor AutoFormat::format_output_tensor( const Tensor& output, - const tt::tt_metal::Shape& shape, + const tt::tt_metal::LegacyShape& shape, Device* device, Layout target_layout, std::optional target_mem_config) { diff --git a/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.hpp b/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.hpp index 69dbc1f7a6d..c3eae3ffebb 100644 --- a/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/auto_format/auto_format.hpp @@ -16,7 +16,7 @@ namespace ttnn::operations::experimental::auto_format{ struct FormatParams { - tt::tt_metal::Shape pad_shape; + tt::tt_metal::LegacyShape pad_shape; float pad_value; Layout target_layout; }; @@ -31,24 +31,24 @@ class AutoFormat { static Device * GetDefaultDevice() { return device; } - static tt::tt_metal::Shape pad_to_tile_shape(const tt::tt_metal::Shape& unpadded_shape, bool pad_c=false, bool pad_n=false, bool pad_h=true, bool pad_w=true) { + static tt::tt_metal::LegacyShape pad_to_tile_shape(const tt::tt_metal::LegacyShape& unpadded_shape, bool pad_c=false, bool pad_n=false, bool pad_h=true, bool pad_w=true) { using namespace tt::constants; auto n = pad_n ? tt::round_up(unpadded_shape.rank() >= 4 ? unpadded_shape[-4] : 1, TILE_HEIGHT) : unpadded_shape.rank() >= 4 ? unpadded_shape[-4] : 1; auto c = pad_c ? tt::round_up(unpadded_shape.rank() >= 3 ? unpadded_shape[-3] : 1, TILE_WIDTH) : unpadded_shape.rank() >= 3 ? unpadded_shape[-3] : 1; auto h = pad_h ? tt::round_up(unpadded_shape[-2], TILE_HEIGHT) : unpadded_shape[-2]; auto w = pad_w ? tt::round_up(unpadded_shape[-1], TILE_WIDTH) : unpadded_shape[-1]; - tt::tt_metal::Shape padded_shape = {n, c, h, w}; + tt::tt_metal::LegacyShape padded_shape = {n, c, h, w}; return padded_shape; } - static tt::tt_metal::Shape pad_to_rm_shape(const tt::tt_metal::Shape& unpadded_shape) { - tt::tt_metal::Shape padded_shape = unpadded_shape; + static tt::tt_metal::LegacyShape pad_to_rm_shape(const tt::tt_metal::LegacyShape& unpadded_shape) { + tt::tt_metal::LegacyShape padded_shape = unpadded_shape; padded_shape[3] = tt::round_up(unpadded_shape[3], 2); return padded_shape; } - static tt::tt_metal::Shape pad_to_legal_shape(const tt::tt_metal::Shape& unpadded_shape, Layout layout) { - tt::tt_metal::Shape padded_shape = unpadded_shape; + static tt::tt_metal::LegacyShape pad_to_legal_shape(const tt::tt_metal::LegacyShape& unpadded_shape, Layout layout) { + tt::tt_metal::LegacyShape padded_shape = unpadded_shape; switch (layout) { case Layout::ROW_MAJOR: padded_shape = pad_to_rm_shape(unpadded_shape); break; case Layout::TILE: padded_shape = pad_to_tile_shape(unpadded_shape); @@ -58,15 +58,15 @@ class AutoFormat { } // TODO: These legal checks should probably be somewhere else like tensor class, since it is common logic not just for autoformat - static bool legal_tile_shape(const tt::tt_metal::Shape& shape) { + static bool legal_tile_shape(const tt::tt_metal::LegacyShape& shape) { return (shape[2] % tt::constants::TILE_HEIGHT == 0 && shape[3] % tt::constants::TILE_WIDTH == 0); } - static bool legal_rm_shape(const tt::tt_metal::Shape& shape) { + static bool legal_rm_shape(const tt::tt_metal::LegacyShape& shape) { return (shape[3] % 2 == 0); } - static bool legal_device_shape(const tt::tt_metal::Shape& shape, Layout layout) { + static bool legal_device_shape(const tt::tt_metal::LegacyShape& shape, Layout layout) { switch (layout) { case Layout::ROW_MAJOR: return legal_rm_shape(shape); case Layout::TILE: return legal_tile_shape(shape); @@ -75,7 +75,7 @@ class AutoFormat { } - static bool check_input_tensor_format(const Tensor &a, const tt::tt_metal::Shape& shape, Layout target_layout = Layout::TILE) { + static bool check_input_tensor_format(const Tensor &a, const tt::tt_metal::LegacyShape& shape, Layout target_layout = Layout::TILE) { if (a.get_layout() == target_layout && a.get_legacy_shape() == shape && a.storage_type() == StorageType::DEVICE) { return true; } @@ -92,9 +92,9 @@ class AutoFormat { static Tensor move_tensor_to_mem_config(const Tensor &input, const MemoryConfig& mem_config); - static Tensor format_input_tensor(const Tensor &input, Device * device, const tt::tt_metal::Shape& padded_shape, float pad_value, Layout target_layout, std::optional target_mem_config = std::nullopt); + static Tensor format_input_tensor(const Tensor &input, Device * device, const tt::tt_metal::LegacyShape& padded_shape, float pad_value, Layout target_layout, std::optional target_mem_config = std::nullopt); - static Tensor format_output_tensor(const Tensor &output, const tt::tt_metal::Shape& shape, Device* device, Layout target_layout, std::optional target_mem_config = std::nullopt); + static Tensor format_output_tensor(const Tensor &output, const tt::tt_metal::LegacyShape& shape, Device* device, Layout target_layout, std::optional target_mem_config = std::nullopt); }; diff --git a/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.cpp b/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.cpp index 5ecc5244acf..595fe103858 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.cpp @@ -54,15 +54,15 @@ void AllGatherMatmul::validate(const std::vector &input_tensors, const s } } -std::vector AllGatherMatmul::compute_output_shapes(const std::vector &input_tensors) const { +std::vector AllGatherMatmul::compute_output_shapes(const std::vector &input_tensors) const { // All Gather shape - tt::tt_metal::Shape all_gather_output_shape = this->all_gather_struct.compute_output_shapes({input_tensors[0]})[0]; - tt::tt_metal::Shape datacopy_output_shape = all_gather_output_shape; + tt::tt_metal::LegacyShape all_gather_output_shape = this->all_gather_struct.compute_output_shapes({input_tensors[0]})[0]; + tt::tt_metal::LegacyShape datacopy_output_shape = all_gather_output_shape; // Matmul shape - tt::tt_metal::Shape matmul_output_shapes = this->matmul_struct.compute_output_shapes({input_tensors[1], input_tensors[2]})[0]; + tt::tt_metal::LegacyShape matmul_output_shapes = this->matmul_struct.compute_output_shapes({input_tensors[1], input_tensors[2]})[0]; return {all_gather_output_shape, matmul_output_shapes, datacopy_output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.hpp b/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.hpp index 8ef7d324ba3..acd5f3d2133 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/ccl/all_gather_matmul/device/all_gather_matmul_op.hpp @@ -42,7 +42,7 @@ struct AllGatherMatmul { /* General */ void validate(const std::vector &input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, diff --git a/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.cpp index 5259a4d5a5b..522ae71e180 100644 --- a/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.cpp @@ -63,7 +63,7 @@ void AttnMatmulDeviceOperation::validate(const std::vector& input_tensor } } -std::vector AttnMatmulDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector AttnMatmulDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { // input_a: [q_len, q_heads, batch, head_dim] // input_b: [batch, kv_heads, head_dim, kv_len] // intermediate: [q_heads, batch, batch, kv_len] @@ -78,7 +78,7 @@ std::vector AttnMatmulDeviceOperation::compute_output_shape N = this->num_tokens.value(); } - return {tt::tt_metal::Shape{1, ashape[1], ashape[2], N}}; + return {tt::tt_metal::LegacyShape{1, ashape[1], ashape[2], N}}; } std::vector AttnMatmulDeviceOperation::create_output_tensors(const std::vector& input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.hpp index 8097555fd6d..75d45787e5b 100644 --- a/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/matmul/attn_matmul/device/attn_matmul_device_operation.hpp @@ -23,7 +23,7 @@ struct AttnMatmulDeviceOperation { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.cpp index 9cd28375e36..9e292ab102b 100644 --- a/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.cpp @@ -72,7 +72,7 @@ void GroupAttnMatmulDeviceOperation::validate(const std::vector& input_t // If user passes in output_mem_config with shard_spec, assert that it is the same as the one calculated in // GroupAttnMatmulDeviceOperation::create_output_tensors if (this->output_mem_config.shard_spec.has_value()) { - const tt::tt_metal::Shape output_shape = this->compute_output_shapes(input_tensors).at(0); + const tt::tt_metal::LegacyShape output_shape = this->compute_output_shapes(input_tensors).at(0); const uint32_t num_cores = output_shape[1]; CoreRangeSet all_cores = num_cores_to_corerange_set(num_cores, this->compute_with_storage_grid_size, this->row_major); @@ -117,7 +117,7 @@ void GroupAttnMatmulDeviceOperation::validate(const std::vector& input_t } } -std::vector GroupAttnMatmulDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector GroupAttnMatmulDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { // input_a: [q_len, q_heads, batch, head_dim] // input_b: [batch, kv_heads, head_dim, kv_len] // intermediate: [q_heads, batch, batch, kv_len] @@ -132,7 +132,7 @@ std::vector GroupAttnMatmulDeviceOperation::compute_output_ N = this->num_tokens.value(); } - return {tt::tt_metal::Shape{1, ashape[1], ashape[2], N}}; + return {tt::tt_metal::LegacyShape{1, ashape[1], ashape[2], N}}; } std::vector GroupAttnMatmulDeviceOperation::create_output_tensors(const std::vector& input_tensors) const { @@ -143,7 +143,7 @@ std::vector GroupAttnMatmulDeviceOperation::create_output_tensors(const if (this->output_mem_config.shard_spec.has_value()) { output_mem_config.shard_spec = this->output_mem_config.shard_spec.value(); } else { - const tt::tt_metal::Shape output_shape = this->compute_output_shapes(input_tensors).at(0); + const tt::tt_metal::LegacyShape output_shape = this->compute_output_shapes(input_tensors).at(0); const uint32_t num_cores = output_shape[1]; CoreRangeSet all_cores = num_cores_to_corerange_set(num_cores, this->compute_with_storage_grid_size, this->row_major); diff --git a/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.hpp index 9da7226ec75..6ddbcf5ee01 100644 --- a/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/matmul/group_attn_matmul/device/group_attn_matmul_device_operation.hpp @@ -26,7 +26,7 @@ struct GroupAttnMatmulDeviceOperation { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.cpp index 7671c6f06c6..42e1c4315b3 100644 --- a/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.cpp @@ -98,7 +98,7 @@ void PagedUpdateCacheDeviceOperation::validate(const std::vector& input_ } } -const std::vector PagedUpdateCacheDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +const std::vector PagedUpdateCacheDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { // Do nothing because it's an in-place operation return {}; } diff --git a/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.hpp index 522a18f959d..37e61a1dbec 100644 --- a/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/paged_cache/device/paged_cache_operation.hpp @@ -31,7 +31,7 @@ struct PagedUpdateCacheDeviceOperation { PagedUpdateCacheOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; void validate(const std::vector& input_tensors, const std::vector>& optional_input_tensors) const; - const std::vector compute_output_shapes( + const std::vector compute_output_shapes( const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.cpp index 679c379410a..2360725dd38 100644 --- a/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.cpp @@ -64,7 +64,7 @@ void FastReduceNCDeviceOperation::validate_with_output_tensors( TT_FATAL((this->dim < input_rank), "dim must be smaller than input tensor rank {}.", input_rank); } -std::vector FastReduceNCDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector FastReduceNCDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { const auto& input = input_tensors.at(0); const auto& input_shape = input.get_legacy_shape(); const auto input_rank = input_shape.rank(); @@ -76,7 +76,7 @@ std::vector FastReduceNCDeviceOperation::compute_output_sha // last 2-dim output_shape[this->dim] = 1; - output_shape = tt::tt_metal::Shape(output_shape, padding); + output_shape = tt::tt_metal::LegacyShape(output_shape, padding); return {output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.hpp index ba01bc5cb11..ec18e782fb7 100644 --- a/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_device_operation.hpp @@ -19,7 +19,7 @@ struct FastReduceNCDeviceOperation { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate_with_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors, const std::vector> &output_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_program_factory.cpp b/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_program_factory.cpp index f70b252e99c..e3ce2dfbc6a 100644 --- a/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/reduction/fast_reduce_nc/device/fast_reduce_nc_program_factory.cpp @@ -19,7 +19,7 @@ using namespace tt::tt_metal; namespace { -std::tuple extract_and_scale_spatial_dims(const tt::tt_metal::Shape& shape, uint32_t dim) { +std::tuple extract_and_scale_spatial_dims(const tt::tt_metal::LegacyShape& shape, uint32_t dim) { const auto rank = shape.rank(); TT_FATAL(rank >= 2, "Shape must have at least two dims."); diff --git a/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.cpp b/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.cpp index 1fcfcb4d053..34a9811bcc7 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.cpp @@ -42,7 +42,7 @@ void HCSumReduce::validate(const std::vector& input_tensors) const { TT_FATAL(((ashape[3] / TILE_WIDTH) % latent == 0), "Final dim/TILE_SIZE must be a multiple of latent size!"); } -std::vector HCSumReduce::compute_output_shapes(const std::vector& input_tensors) const { +std::vector HCSumReduce::compute_output_shapes(const std::vector& input_tensors) const { constexpr uint32_t latent = 32; const auto& input_tensor_a = input_tensors.at(0); const auto shape_a = input_tensor_a.get_legacy_shape(); diff --git a/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.hpp b/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.hpp index 8962e5f0c96..5a4d24cac9b 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/ssm/hc_sum_reduce/device/hc_sum_reduce_op.hpp @@ -15,7 +15,7 @@ struct HCSumReduce { MathFidelity math_fidelity; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.cpp b/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.cpp index 300dd6901d6..118e6a6fcc0 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.cpp @@ -42,7 +42,7 @@ void PrefixScan::validate(const std::vector& input_tensors) const { "Expected h tensor to be row major orientation"); } -std::vector PrefixScan::compute_output_shapes(const std::vector& input_tensors) const { +std::vector PrefixScan::compute_output_shapes(const std::vector& input_tensors) const { const auto& a = input_tensors.at(0); return {a.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.hpp b/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.hpp index 57d732cdc21..b0fbcbbb991 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/ssm/prefix_scan/device/prefix_scan_op.hpp @@ -15,7 +15,7 @@ struct PrefixScan { MathFidelity math_fidelity; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.cpp b/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.cpp index 32d989f517f..26229a58a0f 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.cpp @@ -64,7 +64,7 @@ void RepeatAndInterleaveEltwiseMul::validate(const std::vector& input_te (bshape[3] == HIDDEN_SIZE || bshape[3] == TILE_WIDTH * HIDDEN_SIZE), "Input b width must be 32 or 32*5120!"); } -std::vector RepeatAndInterleaveEltwiseMul::compute_output_shapes( +std::vector RepeatAndInterleaveEltwiseMul::compute_output_shapes( const std::vector& input_tensors) const { const auto& input_tensor_a = input_tensors.at(0); const auto& input_tensor_b = input_tensors.at(1); diff --git a/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.hpp b/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.hpp index ce64e6bd7a5..7c43dccf02a 100644 --- a/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/ssm/repeat_and_interleave_eltwise_mul/device/repeat_and_interleave_eltwise_mul_op.hpp @@ -17,7 +17,7 @@ struct RepeatAndInterleaveEltwiseMul { const uint32_t HIDDEN_SIZE = 5120; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.cpp index 0b65681c0aa..66765977ee3 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.cpp @@ -22,7 +22,7 @@ void ConcatenateHeadsDeviceOperation::validate_with_output_tensors( "Unsupported data format"); TT_FATAL( - (input_tensor.get_legacy_shape() == tt::tt_metal::Shape({batch_size, 16, 384, 64})), "Unsupported input shape"); + (input_tensor.get_legacy_shape() == tt::tt_metal::LegacyShape({batch_size, 16, 384, 64})), "Unsupported input shape"); TT_FATAL(output_tensors.size() == 1, "Must have 1 output tensors"); const auto& optional_output_tensor = output_tensors.at(0); @@ -32,15 +32,15 @@ void ConcatenateHeadsDeviceOperation::validate_with_output_tensors( "Output dtype must be same as input dtype!"); TT_FATAL( - optional_output_tensor.value().get_legacy_shape() == tt::tt_metal::Shape({batch_size, 1, 384, 1024}), "Output shape must be (batch_size, 1, 384, 1024)!"); + optional_output_tensor.value().get_legacy_shape() == tt::tt_metal::LegacyShape({batch_size, 1, 384, 1024}), "Output shape must be (batch_size, 1, 384, 1024)!"); } } -std::vector ConcatenateHeadsDeviceOperation::compute_output_shapes( +std::vector ConcatenateHeadsDeviceOperation::compute_output_shapes( const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); const auto batch_size = input_tensor.get_legacy_shape()[0]; - return {tt::tt_metal::Shape{batch_size, 1, 384, 1024}}; + return {tt::tt_metal::LegacyShape{batch_size, 1, 384, 1024}}; } std::vector ConcatenateHeadsDeviceOperation::create_output_tensors( diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.hpp index d71ffb2964c..ad5358ad9b6 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/concatenate_heads/device/concatenate_heads_device_operation.hpp @@ -17,7 +17,7 @@ struct ConcatenateHeadsDeviceOperation { MemoryConfig output_mem_config; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.cpp index 3aa86cef38a..88c4ac3cd51 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.cpp @@ -34,15 +34,15 @@ void CreateQKVHeadsDeviceOperation::validate(const std::vector &input_te TT_FATAL(input_shape[0] == num_h_cores, "Batch size {} must be equal to num cores {}", input_shape[0], num_h_cores); } -std::vector CreateQKVHeadsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { - std::vector output_shape_vec; +std::vector CreateQKVHeadsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { + std::vector output_shape_vec; const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); - const auto q_output_shape = tt::tt_metal::Shape{input_shape[0], this->num_q_heads, input_shape[2], this->head_dim}; - const auto v_output_shape = tt::tt_metal::Shape{input_shape[0], this->num_kv_heads, input_shape[2], this->head_dim}; + const auto q_output_shape = tt::tt_metal::LegacyShape{input_shape[0], this->num_q_heads, input_shape[2], this->head_dim}; + const auto v_output_shape = tt::tt_metal::LegacyShape{input_shape[0], this->num_kv_heads, input_shape[2], this->head_dim}; const auto k_output_shape = this->transpose_k_heads - ? tt::tt_metal::Shape{input_shape[0], this->num_kv_heads, head_dim, input_shape[2]} + ? tt::tt_metal::LegacyShape{input_shape[0], this->num_kv_heads, head_dim, input_shape[2]} : v_output_shape; return {q_output_shape, k_output_shape, v_output_shape}; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.hpp index 12eb7b8e902..8c5ba3312ec 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads/device/create_qkv_heads_device_operation.hpp @@ -20,7 +20,7 @@ namespace ttnn::operations::experimental::transformer { bool transpose_k_heads; MemoryConfig output_mem_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.cpp index 041b04de171..2926d9b0317 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.cpp @@ -70,7 +70,7 @@ void CreateQKVHeadsSeparateTensorsDeviceOperation::validate(const std::vector CreateQKVHeadsSeparateTensorsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector CreateQKVHeadsSeparateTensorsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); const auto& input_tensor_kv = input_tensors.at(1); const auto input_shape = input_tensor.get_legacy_shape(); @@ -79,7 +79,7 @@ std::vector CreateQKVHeadsSeparateTensorsDeviceOperation::c const auto q_output_shape = {input_shape[0], this->num_q_heads, input_shape[2], this->head_dim}; const auto v_output_shape = {input_shape_kv[0], this->num_kv_heads, input_shape_kv[2], this->head_dim}; const auto k_output_shape = this->transpose_k_heads - ? tt::tt_metal::Shape{input_shape_kv[0], this->num_kv_heads, head_dim, input_shape_kv[2]} + ? tt::tt_metal::LegacyShape{input_shape_kv[0], this->num_kv_heads, head_dim, input_shape_kv[2]} : v_output_shape; return {q_output_shape, k_output_shape, v_output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.hpp index 32ea24815c9..d824d8eeeb9 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/create_qkv_heads_from_separate_tensors/device/create_qkv_heads_from_separate_tensors_device_operation.hpp @@ -20,7 +20,7 @@ struct CreateQKVHeadsSeparateTensorsDeviceOperation { bool transpose_k_heads; MemoryConfig output_mem_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.cpp index 17d8b9ee702..c3115d93f5a 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.cpp @@ -28,11 +28,11 @@ void NLPConcatHeadsDeviceOperation::validate(const std::vector& input_te } } -std::vector NLPConcatHeadsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { - std::vector output_shape_vec; +std::vector NLPConcatHeadsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { + std::vector output_shape_vec; const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); - output_shape_vec = {(tt::tt_metal::Shape) {input_shape[0], 1, input_shape[2], input_shape[1] * input_shape[3]}}; + output_shape_vec = {(tt::tt_metal::LegacyShape) {input_shape[0], 1, input_shape[2], input_shape[1] * input_shape[3]}}; auto num_heads = input_shape[1]; auto sequence_length = input_shape[2]; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.hpp index 4e0bc4762ab..6bf0e64371e 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads/device/nlp_concat_heads_device_operation.hpp @@ -18,7 +18,7 @@ struct NLPConcatHeadsDeviceOperation { MemoryConfig output_mem_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.cpp index da4030ffd6f..28898767a2d 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.cpp @@ -33,7 +33,7 @@ void NLPConcatHeadsDecodeDeviceOperation::validate(const std::vector& in TT_FATAL(num_cores == input_shape[1], "num_cores must be equal to num users"); } -std::vector NLPConcatHeadsDecodeDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector NLPConcatHeadsDecodeDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.hpp index 5809b9711e5..4ac4bc7d7a1 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_concat_heads_decode/device/nlp_concat_heads_decode_device_operation.hpp @@ -18,7 +18,7 @@ struct NLPConcatHeadsDecodeDeviceOperation { const uint32_t num_heads; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads/device/nlp_create_qkv_heads_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads/device/nlp_create_qkv_heads_device_operation.cpp index 33d00676474..4eb3f96967f 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads/device/nlp_create_qkv_heads_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads/device/nlp_create_qkv_heads_device_operation.cpp @@ -87,10 +87,10 @@ NlpCreateHeadsDeviceOperation::shape_return_value_t NlpCreateHeadsDeviceOperatio head_dim = (head_dim / TILE_WIDTH + 1) * TILE_WIDTH; } - const tt::tt_metal::Shape q_output_shape = {input_shape[0], operation_attributes.num_q_heads, sequence_length, head_dim}; - const tt::tt_metal::Shape v_output_shape = {input_shape[0], operation_attributes.num_kv_heads, sequence_length, head_dim}; - const tt::tt_metal::Shape k_output_shape = operation_attributes.transpose_k_heads - ? (tt::tt_metal::Shape){input_shape[0], operation_attributes.num_kv_heads, head_dim, sequence_length} + const tt::tt_metal::LegacyShape q_output_shape = {input_shape[0], operation_attributes.num_q_heads, sequence_length, head_dim}; + const tt::tt_metal::LegacyShape v_output_shape = {input_shape[0], operation_attributes.num_kv_heads, sequence_length, head_dim}; + const tt::tt_metal::LegacyShape k_output_shape = operation_attributes.transpose_k_heads + ? (tt::tt_metal::LegacyShape){input_shape[0], operation_attributes.num_kv_heads, head_dim, sequence_length} : v_output_shape; return {ttnn::Shape(q_output_shape), ttnn::Shape(k_output_shape), ttnn::Shape(v_output_shape)}; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.cpp index b7004cd5cdb..a43907ffe6d 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.cpp @@ -44,9 +44,9 @@ void NLPCreateHeadsDecodeDeviceOperation::validate(const std::vector& in TT_FATAL(this->num_q_heads >= this->num_kv_heads, "Error"); } -std::vector NLPCreateHeadsDecodeDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector NLPCreateHeadsDecodeDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { using namespace tt::constants; - std::vector output_shape_vec; + std::vector output_shape_vec; const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); @@ -57,9 +57,9 @@ std::vector NLPCreateHeadsDecodeDeviceOperation::compute_ou auto num_q_heads_padded = ((this->num_q_heads - 1) / TILE_HEIGHT + 1) * TILE_HEIGHT; auto num_kv_heads_padded = ((this->num_kv_heads - 1) / TILE_HEIGHT + 1) * TILE_HEIGHT; - const tt::tt_metal::Shape q_output_shape = tt::tt_metal::Shape({input_shape[0], batch, this->num_q_heads, head_dim}, {input_shape[0], batch, num_q_heads_padded, head_dim}); - const tt::tt_metal::Shape v_output_shape = tt::tt_metal::Shape({input_shape[0], batch, this->num_kv_heads, head_dim}, {input_shape[0], batch, num_kv_heads_padded, head_dim}); - const tt::tt_metal::Shape k_output_shape = v_output_shape; + const tt::tt_metal::LegacyShape q_output_shape = tt::tt_metal::LegacyShape({input_shape[0], batch, this->num_q_heads, head_dim}, {input_shape[0], batch, num_q_heads_padded, head_dim}); + const tt::tt_metal::LegacyShape v_output_shape = tt::tt_metal::LegacyShape({input_shape[0], batch, this->num_kv_heads, head_dim}, {input_shape[0], batch, num_kv_heads_padded, head_dim}); + const tt::tt_metal::LegacyShape k_output_shape = v_output_shape; return {q_output_shape, k_output_shape, v_output_shape}; } diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.hpp index 22cec3ea3ab..a97e61fd4bd 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_decode/device/nlp_create_qkv_heads_decode_device_operation.hpp @@ -23,7 +23,7 @@ namespace ttnn::operations::experimental::transformer { MemoryConfig output_mem_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.cpp index 8c357134f09..052e583eb41 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.cpp @@ -19,15 +19,15 @@ void NlpCreateHeadsFalcon7BDeviceOperation::validate(const std::vector& TT_FATAL(input_tensor.get_layout() == Layout::TILE, "Error"); TT_FATAL(input_shape[2] % tt::constants::TILE_HEIGHT == 0, "Error"); - TT_FATAL((input_shape == tt::tt_metal::Shape({input_shape[0], 1, input_shape[2], 4672})), "Unsupported input shape"); + TT_FATAL((input_shape == tt::tt_metal::LegacyShape({input_shape[0], 1, input_shape[2], 4672})), "Unsupported input shape"); TT_FATAL(this->output_mem_config.memory_layout == TensorMemoryLayout::INTERLEAVED, "Error"); } -std::vector NlpCreateHeadsFalcon7BDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { - std::vector output_shape_vec; +std::vector NlpCreateHeadsFalcon7BDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { + std::vector output_shape_vec; const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); - output_shape_vec = {(tt::tt_metal::Shape) {input_shape[0], 71, input_shape[2], 64}, (tt::tt_metal::Shape) {input_shape[0], 1, input_shape[2], 64}, (tt::tt_metal::Shape) {input_shape[0], 1, input_shape[2], 64}}; + output_shape_vec = {(tt::tt_metal::LegacyShape) {input_shape[0], 71, input_shape[2], 64}, (tt::tt_metal::LegacyShape) {input_shape[0], 1, input_shape[2], 64}, (tt::tt_metal::LegacyShape) {input_shape[0], 1, input_shape[2], 64}}; return output_shape_vec; } diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.hpp index d1afa26effa..5847b192145 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_create_qkv_heads_falcon7b/device/nlp_create_qkv_heads_falcon7b_device_operation.hpp @@ -21,7 +21,7 @@ struct NlpCreateHeadsFalcon7BDeviceOperation { MemoryConfig output_mem_config; void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.cpp index e52847705e6..4e4230198fe 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.cpp @@ -23,7 +23,7 @@ void NlpKVCacheLoadSliceDeviceOperation::validate(const std::vector &inp TT_FATAL(this->output_tensor_start[i] <= this->output_tensor_end[i], "Error"); } - tt::tt_metal::Shape output_tensor_shape = this->compute_output_shapes(input_tensors)[0]; + tt::tt_metal::LegacyShape output_tensor_shape = this->compute_output_shapes(input_tensors)[0]; auto num_dims = input_tensor_a.get_legacy_shape().rank(); TT_FATAL(num_dims == 4, "Input tensor must be 4D"); const auto input_shape = input_tensor_a.get_legacy_shape(); @@ -41,14 +41,14 @@ void NlpKVCacheLoadSliceDeviceOperation::validate(const std::vector &inp (this->output_tensor_start[-1] % TILE_WIDTH == 0), "Can only unpad tilized tensor with full tiles"); } -std::vector NlpKVCacheLoadSliceDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector NlpKVCacheLoadSliceDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { std::vector out_shape; auto rank = input_tensors[0].get_legacy_shape().rank(); out_shape.reserve(rank); for (uint32_t i = 0; i < rank; i++) { out_shape.push_back(this->output_tensor_end[i] - this->output_tensor_start[i] + 1); } - tt::tt_metal::Shape output_tensor_shape(out_shape); + tt::tt_metal::LegacyShape output_tensor_shape(out_shape); return {output_tensor_shape}; } std::vector NlpKVCacheLoadSliceDeviceOperation::create_output_tensors(const std::vector &input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.hpp index 0e035795400..4f646c0236c 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_device_operation.hpp @@ -12,16 +12,16 @@ namespace ttnn::operations::experimental::transformer { -operation::ProgramWithCallbacks multi_core_nlp_kv_cache_load_slice(const Tensor &a, Tensor& output, const tt::tt_metal::Shape &output_tensor_start, const tt::tt_metal::Shape &output_tensor_end); +operation::ProgramWithCallbacks multi_core_nlp_kv_cache_load_slice(const Tensor &a, Tensor& output, const tt::tt_metal::LegacyShape &output_tensor_start, const tt::tt_metal::LegacyShape &output_tensor_end); struct NlpKVCacheLoadSliceDeviceOperation { - const tt::tt_metal::Shape output_tensor_start; - const tt::tt_metal::Shape output_tensor_end; - const tt::tt_metal::Shape output_shape; - const tt::tt_metal::Shape input_shape; + const tt::tt_metal::LegacyShape output_tensor_start; + const tt::tt_metal::LegacyShape output_tensor_end; + const tt::tt_metal::LegacyShape output_shape; + const tt::tt_metal::LegacyShape input_shape; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_program_factory.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_program_factory.cpp index 00acd00d44f..7db3b1a9e78 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/device/nlp_kv_cache_load_slice_program_factory.cpp @@ -17,7 +17,7 @@ using namespace tt; std::vector, std::vector>> get_unpad_runtime_args_tile_sharded( const Tensor &input_tensor, Tensor &output_tensor, - const tt::tt_metal::Shape &output_tensor_start, + const tt::tt_metal::LegacyShape &output_tensor_start, uint32_t num_cores_total, uint32_t num_cores_x, uint32_t num_tiles_per_core) { @@ -49,9 +49,9 @@ std::vector, std::vector>> get_unpad_r } operation::ProgramWithCallbacks multi_core_nlp_kv_cache_load_slice( - const Tensor &a, Tensor &output, const tt::tt_metal::Shape &output_tensor_start, const tt::tt_metal::Shape &output_tensor_end) { - const tt::tt_metal::Shape output_shape = output.get_legacy_shape(); - const tt::tt_metal::Shape input_shape = a.get_legacy_shape(); + const Tensor &a, Tensor &output, const tt::tt_metal::LegacyShape &output_tensor_start, const tt::tt_metal::LegacyShape &output_tensor_end) { + const tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); + const tt::tt_metal::LegacyShape input_shape = a.get_legacy_shape(); tt_metal::Program program = tt_metal::CreateProgram(); diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/nlp_kv_cache_load_slice.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/nlp_kv_cache_load_slice.cpp index 6b1bb864685..87751e92c45 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/nlp_kv_cache_load_slice.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/nlp_kv_cache_load_slice/nlp_kv_cache_load_slice.cpp @@ -21,21 +21,21 @@ namespace ttnn::operations::experimental::transformer { auto dim1 = input_tensor_shape[1]; auto head_dim = input_tensor_shape[3]; - const tt::tt_metal::Shape output_tensor_start = { + const tt::tt_metal::LegacyShape output_tensor_start = { 0, 0, seq_len_start, 0, }; - const tt::tt_metal::Shape output_tensor_end = { + const tt::tt_metal::LegacyShape output_tensor_end = { dim0-1, dim1-1, seq_len_end-1, head_dim-1, }; - const tt::tt_metal::Shape output_tensor_shape = { + const tt::tt_metal::LegacyShape output_tensor_shape = { output_tensor_end[0] - output_tensor_start[0] + 1, output_tensor_end[1] - output_tensor_start[1] + 1, output_tensor_end[2] - output_tensor_start[2] + 1, diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.cpp index f756497d6e3..1fa6578efcc 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.cpp @@ -59,7 +59,7 @@ void RotaryEmbedding::validate(const std::vector& input_tensors) const { } } -std::vector RotaryEmbedding::compute_output_shapes(const std::vector& input_tensors) const { +std::vector RotaryEmbedding::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto shape = input_tensor.get_legacy_shape(); if (!this->token_idx.has_value()) { diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.hpp index 119477cf5f8..88aecc6e222 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/device/rotary_embedding_device_operation.hpp @@ -27,7 +27,7 @@ struct RotaryEmbedding { const std::vector &input_tensors) const; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/rotary_embedding.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/rotary_embedding.cpp index a6b4936353b..f4bad301516 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/rotary_embedding.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding/rotary_embedding.cpp @@ -71,17 +71,17 @@ ttnn::Tensor RotaryEmbeddingOperation::invoke( default_memory_config = input_tensor.memory_config(); } - tt::tt_metal::Shape input_pad_shape = + tt::tt_metal::LegacyShape input_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(input_tensor.get_legacy_shape()); ttnn::operations::experimental::auto_format::FormatParams input_format_params = { .pad_shape = input_pad_shape, .pad_value = 0.0, .target_layout = Layout::TILE}; - tt::tt_metal::Shape cos_pad_shape = + tt::tt_metal::LegacyShape cos_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(cos_cache.get_legacy_shape()); ttnn::operations::experimental::auto_format::FormatParams cos_format_params = { .pad_shape = cos_pad_shape, .pad_value = 0.0, .target_layout = Layout::TILE}; - tt::tt_metal::Shape sin_pad_shape = + tt::tt_metal::LegacyShape sin_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(sin_cache.get_legacy_shape()); ttnn::operations::experimental::auto_format::FormatParams sin_format_params = { .pad_shape = sin_pad_shape, .pad_value = 0.0, .target_layout = Layout::TILE}; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.cpp index 722cff6cbc9..4f27a8196a2 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.cpp @@ -56,7 +56,7 @@ void RotaryEmbeddingLlama::validate(const std::vector& input_tensors) co } -std::vector RotaryEmbeddingLlama::compute_output_shapes(const std::vector& input_tensors) const { +std::vector RotaryEmbeddingLlama::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto shape = input_tensor.get_legacy_shape(); return {shape}; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.hpp index 23ec541da3b..f228a10d0e4 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotary_embedding_llama/device/rotary_embedding_llama_device_operation.hpp @@ -20,7 +20,7 @@ struct RotaryEmbeddingLlama { const ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.cpp index 1a8f963d886..d1dcecf3a44 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.cpp @@ -22,7 +22,7 @@ void RotateHalf::validate(const std::vector& input_tensors) const { TT_FATAL(this->output_mem_config.memory_layout == TensorMemoryLayout::INTERLEAVED, "RotateHalf does not currently support sharding"); } -std::vector RotateHalf::compute_output_shapes( +std::vector RotateHalf::compute_output_shapes( const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.hpp index 320bc59399e..ce6f6f122eb 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/device/rotate_half_device_operation.hpp @@ -18,7 +18,7 @@ struct RotateHalf { RotateHalfOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes( + std::vector compute_output_shapes( const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/rotate_half.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/rotate_half.cpp index 46e37695527..d775d210201 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/rotate_half.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/rotate_half/rotate_half.cpp @@ -20,7 +20,7 @@ Tensor RotateHalfOperation::invoke(const Tensor& input_tensor, const std::option input_tensor.get_legacy_shape()[-1], tt::constants::TILE_WIDTH * 2); - tt::tt_metal::Shape pad_shape = + tt::tt_metal::LegacyShape pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(input_tensor.get_legacy_shape()); ttnn::operations::experimental::auto_format::FormatParams input_format_params = { .pad_shape = pad_shape, .pad_value = 0.0, .target_layout = Layout::TILE}; diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.cpp b/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.cpp index 3a1a8eb7c36..dad2e4ce8d0 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.cpp @@ -13,7 +13,7 @@ void SplitFusedQKVAndSplitHeadsDeviceOperation::validate_with_output_tensors(con const auto& input_tensor = input_tensors.at(0); const auto batch_size = input_tensor.get_legacy_shape()[0]; // TODO: See issue #1744 - TT_FATAL((input_tensor.get_legacy_shape() == tt::tt_metal::Shape({batch_size, 1, 384, 3072})), "Unsupported input shape"); + TT_FATAL((input_tensor.get_legacy_shape() == tt::tt_metal::LegacyShape({batch_size, 1, 384, 3072})), "Unsupported input shape"); TT_FATAL(input_tensor.storage_type() == StorageType::DEVICE, "Operands to TM need to be on device!"); TT_FATAL(input_tensor.buffer() != nullptr, "Operands to TM need to be allocated in buffers on device!"); TT_FATAL( @@ -38,7 +38,7 @@ void SplitFusedQKVAndSplitHeadsDeviceOperation::validate_with_output_tensors(con } } -std::vector SplitFusedQKVAndSplitHeadsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector SplitFusedQKVAndSplitHeadsDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); const auto batch_size = input_tensor.get_legacy_shape()[0]; uint32_t num_heads = this->num_heads; @@ -46,9 +46,9 @@ std::vector SplitFusedQKVAndSplitHeadsDeviceOperation::comp uint32_t M = input_tensor.get_legacy_shape()[2]; // 384 uint32_t K = input_tensor.get_legacy_shape()[-1] / num_output_tensors / num_heads; // 64 return { - tt::tt_metal::Shape{batch_size, this->num_heads, M, K}, - tt::tt_metal::Shape{batch_size, this->num_heads, K, M}, - tt::tt_metal::Shape{batch_size, this->num_heads, M, K}}; + tt::tt_metal::LegacyShape{batch_size, this->num_heads, M, K}, + tt::tt_metal::LegacyShape{batch_size, this->num_heads, K, M}, + tt::tt_metal::LegacyShape{batch_size, this->num_heads, M, K}}; } std::vector SplitFusedQKVAndSplitHeadsDeviceOperation::create_output_tensors( @@ -82,15 +82,15 @@ std::vector SplitFusedQKVAndSplitHeadsDeviceOperation::create_output_ten auto mem_config_k = this->output_mem_config; mem_config_k.shard_spec = shard_spec_k; auto out_tensor_q = create_device_tensor( - tt::tt_metal::Shape{batch, num_heads, M, K}, + tt::tt_metal::LegacyShape{batch, num_heads, M, K}, input_tensor.get_dtype(), Layout::TILE, input_tensor.device(), mem_config_qv); auto out_tensor_k = create_device_tensor( - tt::tt_metal::Shape{batch, num_heads, K, M}, input_tensor.get_dtype(), Layout::TILE, input_tensor.device(), mem_config_k); + tt::tt_metal::LegacyShape{batch, num_heads, K, M}, input_tensor.get_dtype(), Layout::TILE, input_tensor.device(), mem_config_k); auto out_tensor_v = create_device_tensor( - tt::tt_metal::Shape{batch, num_heads, M, K}, + tt::tt_metal::LegacyShape{batch, num_heads, M, K}, input_tensor.get_dtype(), Layout::TILE, input_tensor.device(), diff --git a/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.hpp b/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.hpp index 70a5529c29f..0803cc44150 100644 --- a/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/experimental/transformer/split_query_key_value_and_split_heads/device/split_query_key_value_and_split_heads_device_operation.hpp @@ -18,7 +18,7 @@ struct SplitFusedQKVAndSplitHeadsDeviceOperation { uint32_t num_heads; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; }; diff --git a/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.cpp b/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.cpp index 3467ed1cc86..4a5fec9f233 100644 --- a/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.cpp +++ b/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.cpp @@ -65,7 +65,7 @@ void UpdateCache::validate(const std::vector& input_tensors) const { } } -std::vector UpdateCache::compute_output_shapes(const std::vector& input_tensors) const { +std::vector UpdateCache::compute_output_shapes(const std::vector& input_tensors) const { // Do nothing because it's an in-place operation return {}; } diff --git a/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.hpp b/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.hpp index 9874872e8b1..59132ea02a6 100644 --- a/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.hpp +++ b/ttnn/cpp/ttnn/operations/kv_cache/device/update_cache_op.hpp @@ -32,7 +32,7 @@ struct UpdateCache { UpdateCacheOpParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes( + std::vector compute_output_shapes( const std::vector &input_tensors) const; std::vector create_output_tensors( const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.cpp b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.cpp index 12df300ca57..0d3913aca37 100644 --- a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.cpp +++ b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.cpp @@ -19,7 +19,7 @@ using namespace tt; using namespace tt::constants; using namespace tt::tt_metal; -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; using ttnn::operations::unary::UnaryWithParam; namespace { @@ -1259,14 +1259,14 @@ void Matmul::validate( chosen_program_config); } -std::vector Matmul::compute_output_shapes(const std::vector& input_tensors) const { - const Shape& input_shape_a = input_tensors.at(0).get_legacy_shape(); - const Shape& input_shape_b = input_tensors.at(1).get_legacy_shape(); +std::vector Matmul::compute_output_shapes(const std::vector& input_tensors) const { + const tt::tt_metal::LegacyShape& input_shape_a = input_tensors.at(0).get_legacy_shape(); + const tt::tt_metal::LegacyShape& input_shape_b = input_tensors.at(1).get_legacy_shape(); const uint32_t a_rank = input_shape_a.rank(); const uint32_t b_rank = input_shape_b.rank(); const uint32_t out_rank = std::max(a_rank, b_rank); const uint32_t rank_difference = out_rank - a_rank; - Shape output_shape = (b_rank > a_rank) ? input_shape_b : input_shape_a; + tt::tt_metal::LegacyShape output_shape = (b_rank > a_rank) ? input_shape_b : input_shape_a; auto dimensions_pads = std::vector(); for (auto index = 0; index < rank_difference; index++) { @@ -1281,7 +1281,7 @@ std::vector Matmul::compute_output_shapes(const std::vector& inpu output_shape[-1] = input_shape_b[-1]; dimensions_pads.push_back(input_shape_b.padding()[b_rank - 1]); const auto padding = Padding(dimensions_pads, Padding::PadValue::Any); - return {Shape(output_shape, padding)}; + return {tt::tt_metal::LegacyShape(output_shape, padding)}; } std::vector Matmul::create_output_tensors(const std::vector& input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.hpp b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.hpp index 0247bf0d3c8..40fd00a02d5 100644 --- a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.hpp +++ b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op.hpp @@ -21,7 +21,7 @@ namespace operations { namespace matmul { using ttnn::operations::unary::UnaryWithParam; -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; /* * GENERAL MATMUL AND BMM @@ -168,8 +168,8 @@ struct Matmul { void validate( const std::vector &input_tensors, const std::vector> &optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; - std::vector compute_output_shapes_dram_sharded( + std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes_dram_sharded( const std::vector &input_tensors, uint32_t N_unpadded) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( diff --git a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_program_factory.cpp b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_program_factory.cpp index 53cd7f40c6d..e10446dcbdf 100644 --- a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_program_factory.cpp @@ -21,7 +21,7 @@ namespace matmul { operation::ProgramWithCallbacks matmul_multi_core(const Tensor &a, const Tensor &b, Tensor &output, bool bcast_batch) { tt_metal::Program program{}; - const tt::tt_metal::Shape& ashape = a.get_legacy_shape(), bshape = b.get_legacy_shape(); + const tt::tt_metal::LegacyShape& ashape = a.get_legacy_shape(), bshape = b.get_legacy_shape(); tt::DataFormat in0_data_format = tt_metal::datatype_to_dataformat_converter(a.get_dtype()); tt::DataFormat in1_data_format = tt_metal::datatype_to_dataformat_converter(b.get_dtype()); @@ -36,7 +36,7 @@ operation::ProgramWithCallbacks matmul_multi_core(const Tensor &a, const Tensor // This should allocate a DRAM buffer on the device tt::tt_metal::Device *device = a.device(); - const tt::tt_metal::Shape& cshape = output.get_legacy_shape(); // C=A*B, N1MK*11KN->N1MN + const tt::tt_metal::LegacyShape& cshape = output.get_legacy_shape(); // C=A*B, N1MK*11KN->N1MN auto compute_with_storage_grid_size = device->compute_with_storage_grid_size(); uint32_t num_cores_x = compute_with_storage_grid_size.x; diff --git a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_reuse_program_factory.cpp b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_reuse_program_factory.cpp index 42feca35bf9..482e6c8bca9 100644 --- a/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_reuse_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/matmul/device/matmul_op_multi_core_reuse_program_factory.cpp @@ -285,7 +285,7 @@ operation::ProgramWithCallbacks matmul_multi_core_reuse( //////////////////////////////////////////////////////////////////////////// // Grayskull Device Setup //////////////////////////////////////////////////////////////////////////// - tt::tt_metal::Shape cshape = output.get_legacy_shape(); // C=A*B, N1MK*11KN->N1MN + tt::tt_metal::LegacyShape cshape = output.get_legacy_shape(); // C=A*B, N1MK*11KN->N1MN tt_metal::Buffer *out_buffer = output.buffer(); TT_FATAL(out_buffer != nullptr, "Output buffer should be allocated on device!"); diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_arange/device/moreh_arange_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_arange/device/moreh_arange_device_operation.cpp index 837b12ec2a3..e1a72b0d986 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_arange/device/moreh_arange_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_arange/device/moreh_arange_device_operation.cpp @@ -59,7 +59,7 @@ MorehArangeOperation::shape_return_value_t MorehArangeOperation::compute_output_ ceil((operation_attributes.end - operation_attributes.start) / operation_attributes.step)); if (operation_attributes.untilize_out) - return ttnn::Shape(tt::tt_metal::Shape({num_elems})); + return ttnn::Shape(tt::tt_metal::LegacyShape({num_elems})); std::vector output_size_vec = { tt::constants::TILE_HEIGHT, tt::round_up(num_elems, tt::constants::TILE_WIDTH)}; @@ -70,7 +70,7 @@ MorehArangeOperation::shape_return_value_t MorehArangeOperation::compute_output_ Padding::PadDimension{.front = 0, .back = tt::round_up(num_elems, tt::constants::TILE_WIDTH) - num_elems}); const auto padding = Padding(dimensions_pads, Padding::PadValue::Any); - return ttnn::Shape{tt::tt_metal::Shape(output_size_vec, padding)}; + return ttnn::Shape{tt::tt_metal::LegacyShape(output_size_vec, padding)}; }; MorehArangeOperation::tensor_return_value_t MorehArangeOperation::create_output_tensors( diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_dot_op/device/moreh_dot_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_dot_op/device/moreh_dot_device_operation.cpp index fb1f8b20c5f..940d235d80a 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_dot_op/device/moreh_dot_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_dot_op/device/moreh_dot_device_operation.cpp @@ -56,7 +56,7 @@ MorehDotOperation::shape_return_value_t MorehDotOperation::compute_output_shapes auto padding = output_shape.padding(); output_shape[3] = tt::constants::TILE_WIDTH; padding[3] = Padding::PadDimension{0, 31}; - return ttnn::Shape{tt::tt_metal::Shape(output_shape, padding)}; + return ttnn::Shape{tt::tt_metal::LegacyShape(output_shape, padding)}; } diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp index fefa2e9862a..3c9a3694079 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp @@ -137,7 +137,7 @@ MorehGetItemOperation::shape_return_value_t MorehGetItemOperation::compute_outpu } const auto padding = Padding(dimensions_pads, Padding::PadValue::Any); - output_shape = Shape(tt::tt_metal::Shape(output_size_vec, padding)); + output_shape = Shape(tt::tt_metal::LegacyShape(output_size_vec, padding)); } else { // compute output shape diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_rm_factory.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_rm_factory.cpp index 66a55474d24..1ce2971b0fb 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_rm_factory.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_rm_factory.cpp @@ -48,8 +48,8 @@ MorehGetItemOperation::MorehGetItemRmFactory::cached_program_t MorehGetItemOpera for (auto index = 0; index < output_shape.rank(); index++) { new_output_shape[index + output_dim_offset] = output_shape[index]; } - Shape input_5d_shape(new_input_shape); - Shape output_5d_shape(new_output_shape); + ttnn::Shape input_5d_shape(new_input_shape); + ttnn::Shape output_5d_shape(new_output_shape); uint32_t index_start_dim = index_dims.front(); uint32_t index_end_dim = index_dims.back(); diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_tilized_factory.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_tilized_factory.cpp index 92f15b704ec..2c2ca2d35bb 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_tilized_factory.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_tilized_factory.cpp @@ -64,8 +64,8 @@ MorehGetItemOperation::MorehGetItemTilizedFactory::create( new_output_padded_shape[index + output_dim_offset] = output_shape.value[index]; } - Shape input_5d_shape(new_input_shape, new_input_padded_shape); - Shape output_5d_shape(new_output_shape, new_output_padded_shape); + ttnn::Shape input_5d_shape(new_input_shape, new_input_padded_shape); + ttnn::Shape output_5d_shape(new_output_shape, new_output_padded_shape); bool is_w_index_exist = false; for (auto dim : index_dims) { diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.cpp index 852bbe9eed5..ff0e978cd6e 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.cpp @@ -146,12 +146,12 @@ MorehMatmulOperation::shape_return_value_t compute_output_shapes( output_dim[output_rank - 2] = h; output_dim[output_rank - 1] = w; - tt::tt_metal::Shape output_shape{output_dim}; + tt::tt_metal::LegacyShape output_shape{output_dim}; auto padding = output_shape.padding(); // padding for t logmatrix dims padding[output_rank - 2] = Padding::PadDimension{0, h - h_wo_padding}; padding[output_rank - 1] = Padding::PadDimension{0, w - w_wo_padding}; - return Shape({tt::tt_metal::Shape(output_shape, padding)}); + return Shape({tt::tt_metal::LegacyShape(output_shape, padding)}); } MorehMatmulOperation::tensor_return_value_t MorehMatmulOperation::create_output_tensors( const MorehMatmulOperation::operation_attributes_t &operation_attributes, @@ -214,12 +214,12 @@ MorehMatmulOperation::shape_return_value_t MorehMatmulOperation::compute_output_ output_dim[output_rank - 2] = h; output_dim[output_rank - 1] = w; - tt::tt_metal::Shape output_shape{output_dim}; + tt::tt_metal::LegacyShape output_shape{output_dim}; auto padding = output_shape.padding(); // padding for t logmatrix dims padding[output_rank - 2] = Padding::PadDimension{0, h - h_wo_padding}; padding[output_rank - 1] = Padding::PadDimension{0, w - w_wo_padding}; - return Shape({tt::tt_metal::Shape(output_shape, padding)}); + return Shape({tt::tt_metal::LegacyShape(output_shape, padding)}); } std::tuple diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.hpp b/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.hpp index 340befe8379..1ce66393aed 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_device_operation.hpp @@ -72,8 +72,8 @@ struct MorehMatmulOperation { const std::optional& compute_kernel_config); }; -void get_tensor_dim(std::vector& dim, const tt::tt_metal::Shape& shape); -std::vector find_reduce_dim(const tt::tt_metal::Shape& a_shape, const tt::tt_metal::Shape& b_shape); +void get_tensor_dim(std::vector& dim, const tt::tt_metal::LegacyShape& shape); +std::vector find_reduce_dim(const tt::tt_metal::LegacyShape& a_shape, const tt::tt_metal::LegacyShape& b_shape); bool is_same_batch_dim(const Tensor& tensor_a, const Tensor& tensor_b); } // namespace ttnn::operations::moreh::moreh_matmul diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_program_factory.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_program_factory.cpp index 8a17bb43b28..d46466ce5b0 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_matmul/device/moreh_matmul_program_factory.cpp @@ -9,7 +9,7 @@ namespace ttnn::operations::moreh::moreh_matmul { -void get_tensor_dim(std::vector &dim, const tt::tt_metal::Shape &shape) { +void get_tensor_dim(std::vector &dim, const tt::tt_metal::LegacyShape &shape) { const auto rank = shape.rank(); for (auto i = 0; i < rank; ++i) { auto idx = rank - 1 - i; @@ -28,7 +28,7 @@ void get_tensor_dim(std::vector &dim, const tt::tt_metal::Shape &shape } } -std::vector find_reduce_dim(const tt::tt_metal::Shape &a_shape, const tt::tt_metal::Shape &b_shape) { +std::vector find_reduce_dim(const tt::tt_metal::LegacyShape &a_shape, const tt::tt_metal::LegacyShape &b_shape) { std::vector a_dim(tt::tt_metal::MAX_NUM_DIMENSIONS, 1); std::vector b_dim(tt::tt_metal::MAX_NUM_DIMENSIONS, 1); get_tensor_dim(a_dim, a_shape); diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_mean/device/moreh_mean_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_mean/device/moreh_mean_device_operation.cpp index 11448810249..a00568d4c4a 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_mean/device/moreh_mean_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_mean/device/moreh_mean_device_operation.cpp @@ -76,7 +76,7 @@ MorehMeanOperation::shape_return_value_t MorehMeanOperation::compute_output_shap output_shape.value[dim] = 1; } - return Shape(tt::tt_metal::Shape(output_shape.value, padding)); + return Shape(tt::tt_metal::LegacyShape(output_shape.value, padding)); } std::vector shape; @@ -97,7 +97,7 @@ MorehMeanOperation::shape_return_value_t MorehMeanOperation::compute_output_shap } auto padding = Padding(pad_dimensions, input_padding.pad_value()); - return Shape(tt::tt_metal::Shape(shape, padding)); + return Shape(tt::tt_metal::LegacyShape(shape, padding)); } MorehMeanOperation::tensor_return_value_t MorehMeanOperation::create_output_tensors( diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_device_operation.cpp index 52f5670cf92..2aa48a48c6a 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_device_operation.cpp @@ -59,7 +59,7 @@ MorehMeanBackwardOperation::shape_return_value_t MorehMeanBackwardOperation::com } const auto padding = Padding(dimensions_pads, Padding::PadValue::Any); - auto output_shape = Shape(tt::tt_metal::Shape(shape, padding)); + auto output_shape = Shape(tt::tt_metal::LegacyShape(shape, padding)); return output_shape; } diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_program_factory.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_program_factory.cpp index 1faca0427ff..da89d0ec5bc 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_mean_backward/device/moreh_mean_backward_program_factory.cpp @@ -12,7 +12,7 @@ #include "ttnn/operations/reduction/generic/device/common.hpp" #include "ttnn/operations/reduction/generic/device/reduce_op.hpp" -void get_tensor_dim(std::vector &dim, const Shape &shape) { +void get_tensor_dim(std::vector &dim, const tt::tt_metal::LegacyShape &shape) { const auto rank = shape.rank(); for (auto i = 0; i < rank; ++i) { auto idx = rank - 1 - i; @@ -26,7 +26,7 @@ void get_tensor_dim(std::vector &dim, const Shape &shape) { } } -Shape get_output_grad_shape( +tt::tt_metal::LegacyShape get_output_grad_shape( const Tensor &output_grad, const Tensor &input_grad, const std::vector &dims, const bool &keepdim) { if (keepdim) { return output_grad.get_shape().value; @@ -46,7 +46,7 @@ Shape get_output_grad_shape( } } - return Shape(tt::tt_metal::Shape(shape.value, padding)); + return tt::tt_metal::LegacyShape(shape.value, padding); } namespace ttnn::operations::moreh::moreh_mean_backward { diff --git a/ttnn/cpp/ttnn/operations/moreh/moreh_sum/device/moreh_sum_device_operation.cpp b/ttnn/cpp/ttnn/operations/moreh/moreh_sum/device/moreh_sum_device_operation.cpp index ff28565f921..3efef51dc0a 100644 --- a/ttnn/cpp/ttnn/operations/moreh/moreh_sum/device/moreh_sum_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/moreh/moreh_sum/device/moreh_sum_device_operation.cpp @@ -76,7 +76,7 @@ MorehSumOperation::shape_return_value_t MorehSumOperation::compute_output_shapes operation_attributes.dim, operation_attributes.keep_batch_dim); - Shape output_shape = input_shape; + ttnn::Shape output_shape = input_shape; if (operation_attributes.keep_batch_dim) { auto shape = input_shape.value; auto padding = shape.padding(); @@ -90,7 +90,7 @@ MorehSumOperation::shape_return_value_t MorehSumOperation::compute_output_shapes shape[operation_attributes.dim] = 1; } - output_shape = Shape{tt::tt_metal::Shape(shape, padding)}; + output_shape = ttnn::Shape{tt::tt_metal::LegacyShape(shape, padding)}; } else { std::vector shape; std::vector pad_dimensions; @@ -110,7 +110,7 @@ MorehSumOperation::shape_return_value_t MorehSumOperation::compute_output_shapes } auto padding = Padding(pad_dimensions, input_padding.pad_value()); - output_shape = Shape{tt::tt_metal::Shape(shape, padding)}; + output_shape = ttnn::Shape{tt::tt_metal::LegacyShape(shape, padding)}; } log_debug(tt::LogOp, "{}:{} output_shape {}", __func__, __LINE__, output_shape); diff --git a/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.cpp b/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.cpp index f6ee4e99801..d4a5bb0979f 100644 --- a/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.cpp +++ b/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.cpp @@ -68,7 +68,7 @@ void GroupNorm::validate(const std::vector &input_tensors, const std::ve TT_FATAL(input_mask.value().get_legacy_shape()[3] % TILE_WIDTH == 0, "Error"); } } -std::vector GroupNorm::compute_output_shapes(const std::vector &input_tensors) const { +std::vector GroupNorm::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.hpp b/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.hpp index e0431858e4a..31eb0a3904f 100644 --- a/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.hpp +++ b/ttnn/cpp/ttnn/operations/normalization/groupnorm/device/groupnorm_op.hpp @@ -57,7 +57,7 @@ struct GroupNorm { GroupNormShardedMultiCoreProgramConfig program_config; void validate(const std::vector &input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, diff --git a/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.cpp b/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.cpp index 62d72c064da..071c8944c14 100644 --- a/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.cpp +++ b/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.cpp @@ -129,7 +129,7 @@ void LayerNorm::validate(const std::vector &input_tensors, const std::ve } -std::vector LayerNorm::compute_output_shapes(const std::vector &input_tensors) const { +std::vector LayerNorm::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.hpp b/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.hpp index 720ec000ba5..76605080c2e 100644 --- a/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.hpp +++ b/ttnn/cpp/ttnn/operations/normalization/layernorm/device/layernorm_op.hpp @@ -49,7 +49,7 @@ struct LayerNorm { const DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector &input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, diff --git a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.cpp b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.cpp index 33bb60eb4c9..5322de38995 100644 --- a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.cpp +++ b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.cpp @@ -81,7 +81,7 @@ void LayerNormPostAllGather::validate(const std::vector &input_tensors, } } -std::vector LayerNormPostAllGather::compute_output_shapes(const std::vector &input_tensors) const { +std::vector LayerNormPostAllGather::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.hpp b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.hpp index 9c3bab3e545..3d7d1dcd0ef 100644 --- a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.hpp +++ b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_post_all_gather_op.hpp @@ -33,7 +33,7 @@ struct LayerNormPostAllGather { const DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector &input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, diff --git a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.cpp b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.cpp index d31d9365b78..835a699785b 100644 --- a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.cpp +++ b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.cpp @@ -32,7 +32,7 @@ void LayerNormPreAllGather::validate(const std::vector &input_tensors) c TT_FATAL(tensor.buffer() != nullptr, "Operands to layernorm need to be allocated in buffers on device!"); } -std::vector LayerNormPreAllGather::compute_output_shapes(const std::vector &input_tensors) const { +std::vector LayerNormPreAllGather::compute_output_shapes(const std::vector &input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto output_shape = input_tensor.get_legacy_shape(); @@ -44,7 +44,7 @@ std::vector LayerNormPreAllGather::compute_output_shapes(co output_shape[3] = num_tiles_w * TILE_WIDTH; padding[3] = Padding::PadDimension{0, 31}; - return {tt::tt_metal::Shape(output_shape, padding)}; + return {tt::tt_metal::LegacyShape(output_shape, padding)}; } std::vector LayerNormPreAllGather::create_output_tensors(const std::vector &input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.hpp b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.hpp index e9cbfd1d6b3..4445eef953d 100644 --- a/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.hpp +++ b/ttnn/cpp/ttnn/operations/normalization/layernorm_distributed/device/layernorm_pre_all_gather_op.hpp @@ -29,7 +29,7 @@ struct LayerNormPreAllGather { const DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.cpp b/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.cpp index a76027fd3eb..feb75819095 100644 --- a/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.cpp +++ b/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.cpp @@ -40,7 +40,7 @@ void Softmax::validate(const std::vector &input_tensors, const std::vect TT_FATAL(mask.get_legacy_shape() == input_tensor.get_legacy_shape(), "Error"); } else { if (mask.get_layout() == Layout::ROW_MAJOR) { - tt::tt_metal::Shape expected_shape = {mask.get_legacy_shape()[0], 1, input_tensor.get_legacy_shape()[-1] / TILE_WIDTH, TILE_WIDTH}; + tt::tt_metal::LegacyShape expected_shape = {mask.get_legacy_shape()[0], 1, input_tensor.get_legacy_shape()[-1] / TILE_WIDTH, TILE_WIDTH}; TT_FATAL(mask.get_legacy_shape() == expected_shape, "Error"); } for (uint32_t i = 1; i < input_tensor.get_legacy_shape().rank() - 2; i++) { @@ -96,7 +96,7 @@ void Softmax::validate(const std::vector &input_tensors, const std::vect } } -std::vector Softmax::compute_output_shapes(const std::vector& input_tensors) const { +std::vector Softmax::compute_output_shapes(const std::vector& input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } @@ -197,7 +197,7 @@ Tensor scale_mask_softmax(const Tensor& input_tensor, std::optional scale [scale, mask, output_mem_config, is_causal_mask, compute_kernel_config] (const std::vector& input_tensors, const std::vector>& optional_input_tensors, const std::vector>& optional_output_tensors) mutable -> std::vector { auto& input_tensor = input_tensors.at(0); auto& mask = optional_input_tensors.at(0); - tt::tt_metal::Shape input_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(input_tensor.get_legacy_shape()); + tt::tt_metal::LegacyShape input_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(input_tensor.get_legacy_shape()); ttnn::operations::experimental::auto_format::FormatParams input_format_params = {.pad_shape=input_pad_shape, .pad_value=-std::numeric_limits::infinity(), .target_layout=Layout::TILE}; std::optional mask_format_params = std::nullopt; if (mask.has_value()) { @@ -207,7 +207,7 @@ Tensor scale_mask_softmax(const Tensor& input_tensor, std::optional scale for (uint32_t i = 1; i < input_tensor.get_legacy_shape().rank() - 2; i++) { TT_FATAL(mask.value().get_legacy_shape()[i] == 1, "Error"); } - tt::tt_metal::Shape mask_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(mask.value().get_legacy_shape()); + tt::tt_metal::LegacyShape mask_pad_shape = ttnn::operations::experimental::auto_format::AutoFormat::pad_to_tile_shape(mask.value().get_legacy_shape()); mask_format_params = {.pad_shape=mask_pad_shape, .pad_value=-std::numeric_limits::infinity(), .target_layout=Layout::TILE}; } auto kernel_config_val = init_device_compute_kernel_config(input_tensor.device()->arch(), compute_kernel_config, MathFidelity::HiFi4, true, false, false); diff --git a/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.hpp b/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.hpp index 237a4224e91..caccc7837b7 100644 --- a/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.hpp +++ b/ttnn/cpp/ttnn/operations/normalization/softmax/device/softmax_op.hpp @@ -27,7 +27,7 @@ struct Softmax { const bool is_scale_causal_mask_hw_dims_softmax; void validate(const std::vector &input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, diff --git a/ttnn/cpp/ttnn/operations/pool/avgpool/avg_pool.cpp b/ttnn/cpp/ttnn/operations/pool/avgpool/avg_pool.cpp index be0d322d17e..5d2c9d0a00d 100644 --- a/ttnn/cpp/ttnn/operations/pool/avgpool/avg_pool.cpp +++ b/ttnn/cpp/ttnn/operations/pool/avgpool/avg_pool.cpp @@ -26,11 +26,11 @@ Tensor avg_pool2d(const Tensor& input, const MemoryConfig& memory_config, const TT_ASSERT(input.storage_type() == StorageType::DEVICE, "Input tensor needs to be on device"); auto output = input; - Shape in_shape = input.get_legacy_shape(); + tt::tt_metal::LegacyShape in_shape = input.get_legacy_shape(); auto input_padding = in_shape.padding(); TT_ASSERT(input_padding[1].front == 0 and input_padding[1].back == 0); auto output_padding = Padding({input_padding[0], {0, 0}, {0, input_padding[2].back * in_shape[1]}, input_padding[3]}, input_padding.pad_value()); - auto output_shape = Shape({in_shape[0], 1, in_shape[1] * in_shape[2], in_shape[3]}, output_padding); + auto output_shape = tt::tt_metal::LegacyShape({in_shape[0], 1, in_shape[1] * in_shape[2], in_shape[3]}, output_padding); output = output.reshape(output_shape); output = pool_2d(output, memory_config, output_dtype); diff --git a/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.cpp b/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.cpp index f0d410760de..3ffccb59692 100644 --- a/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.cpp +++ b/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.cpp @@ -31,7 +31,7 @@ void Downsample::validate(const std::vector& input_tensors) const { -std::vector Downsample::compute_output_shapes(const std::vector& input_tensors) const { +std::vector Downsample::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor_a = input_tensors.at(0); TT_ASSERT(input_tensor_a.get_legacy_shape()[0] == 1 && input_tensor_a.get_legacy_shape()[1] == 1); uint32_t input_height = input_tensor_a.get_legacy_shape()[2]; @@ -43,7 +43,7 @@ std::vector Downsample::compute_output_shapes(const std::ve uint32_t output_width = input_tensor_a.get_legacy_shape()[3]; auto output_padding = Padding({{0, 0}, {0, 0}, {0, (output_height - output_height_unpadded)}, {0, 0}}, Padding::PadValue::Any); - auto output_tensor_shape = tt::tt_metal::Shape({1, 1, output_height, output_width}, output_padding); + auto output_tensor_shape = tt::tt_metal::LegacyShape({1, 1, output_height, output_width}, output_padding); log_debug(tt::LogOp, "Downsample output shape: {}", output_tensor_shape); return {output_tensor_shape}; } diff --git a/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.hpp b/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.hpp index b20e83c73bb..3b09a8efe4c 100644 --- a/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.hpp +++ b/ttnn/cpp/ttnn/operations/pool/downsample/device/downsample_op.hpp @@ -19,7 +19,7 @@ struct Downsample { std::array downsample_params; DataType dtype; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_device_op.cpp b/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_device_op.cpp index 6ed1d101ec9..050dab5a122 100644 --- a/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_device_op.cpp +++ b/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_device_op.cpp @@ -70,7 +70,7 @@ MaxPool2D::shape_return_value_t MaxPool2D::compute_output_shapes(const operation const auto padding = Padding( {{0, 0}, {0, 0}, {0, out_nhw_padded - out_nhw}, {0, out_c_padded - out_c}}, Padding::PadValue::NegativeInfinity); - auto out_shape = Shape(tt::tt_metal::Shape(out_dims, padding)); + auto out_shape = Shape(tt::tt_metal::LegacyShape(out_dims, padding)); return out_shape; } diff --git a/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_multi_core_program_factory.cpp b/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_multi_core_program_factory.cpp index 1489fe4be44..34c3ee69010 100644 --- a/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_multi_core_program_factory.cpp +++ b/ttnn/cpp/ttnn/operations/pool/maxpool/device/max_pool2d_multi_core_program_factory.cpp @@ -42,8 +42,8 @@ MaxPool2D::MultiCore::cached_program_t max_pool_2d_multi_core_sharded_with_halo_ tt::tt_metal::Buffer* reader_indices_buffer = reader_indices.buffer(); tt::tt_metal::Buffer* dst_dram_buffer = output.buffer(); - const tt::tt_metal::Shape input_shape = input.get_legacy_shape(); - const tt::tt_metal::Shape output_shape = output.get_legacy_shape(); + const tt::tt_metal::LegacyShape input_shape = input.get_legacy_shape(); + const tt::tt_metal::LegacyShape output_shape = output.get_legacy_shape(); tt::DataFormat in_df = datatype_to_dataformat_converter(input.get_dtype()); tt::DataFormat out_df = datatype_to_dataformat_converter(output.get_dtype()); diff --git a/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.cpp b/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.cpp index 71c6291366f..c193b4dce59 100644 --- a/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.cpp +++ b/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.cpp @@ -30,7 +30,7 @@ void UpSample::validate(const std::vector &input_tensors) const { } } -std::vector UpSample::compute_output_shapes(const std::vector &input_tensors) const { +std::vector UpSample::compute_output_shapes(const std::vector &input_tensors) const { // NOTE1: data is packed in { N, H , W, C } // NOTE2: Mapping it into in 2D format should be {N*H*W, C} // NOTE3: Assuming output data type is same as input @@ -42,7 +42,7 @@ std::vector UpSample::compute_output_shapes(const std::vector &in uint32_t out_w = input_shape[2] * scale_factor_w_; uint32_t out_c = input_shape[3]; const auto out_dims = std::vector({ out_n, out_h, out_w, out_c }); //in the NHWC format - auto out_shape = Shape{out_dims}; + auto out_shape = tt::tt_metal::LegacyShape{out_dims}; return {out_shape}; } diff --git a/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.hpp b/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.hpp index b2c6b838a26..39801f82287 100644 --- a/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.hpp +++ b/ttnn/cpp/ttnn/operations/pool/upsample/device/upsample_op.hpp @@ -20,7 +20,7 @@ struct UpSample{ const MemoryConfig output_mem_config_; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; UpSampleParallelizationStrategy get_parallelization_strategy(const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.cpp b/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.cpp index 73387afe798..7b0129e6595 100644 --- a/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.cpp @@ -41,22 +41,22 @@ void ArgMax::validate_with_output_tensors( } } -std::vector ArgMax::compute_output_shapes(const std::vector &input_tensors) const { +std::vector ArgMax::compute_output_shapes(const std::vector &input_tensors) const { auto input_shape = input_tensors[0].get_legacy_shape(); if (this->dim.has_value()) { // TODO: There seems to be an underflow issue with directly modifying last two dims if (this->dim.value() == -1 or this->dim.value() == 3) { - tt::tt_metal::Shape output_shape({input_shape[0], input_shape[1], input_shape[2], 1}); + tt::tt_metal::LegacyShape output_shape({input_shape[0], input_shape[1], input_shape[2], 1}); return {output_shape}; } else if (this->dim.value() == -2 or this->dim.value() == 2) { - tt::tt_metal::Shape output_shape({input_shape[0], input_shape[1], 1, input_shape[3]}); + tt::tt_metal::LegacyShape output_shape({input_shape[0], input_shape[1], 1, input_shape[3]}); return {output_shape}; } else { input_shape[this->dim.value()] = 1; return {input_shape}; } } else { - tt::tt_metal::Shape output_shape({1, 1, 1, 1}); + tt::tt_metal::LegacyShape output_shape({1, 1, 1, 1}); return {output_shape}; } } diff --git a/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.hpp b/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.hpp index 18a6aee9246..7d53e96497f 100644 --- a/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.hpp +++ b/ttnn/cpp/ttnn/operations/reduction/argmax/device/argmax_op.hpp @@ -18,7 +18,7 @@ struct ArgMax { const MemoryConfig output_mem_config; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.cpp b/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.cpp index fba10bd4eb2..7bf551c763b 100644 --- a/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.cpp @@ -56,7 +56,7 @@ void Reduce::validate(const std::vector& input_tensors) const { } } -std::vector Reduce::compute_output_shapes(const std::vector& input_tensors) const { +std::vector Reduce::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); auto output_shape = input_tensor.get_legacy_shape(); @@ -77,7 +77,7 @@ std::vector Reduce::compute_output_shapes(const std::vector& inpu padding[3] = Padding::PadDimension{0, 31}; break; } - return {Shape(output_shape, padding)}; + return {tt::tt_metal::LegacyShape(output_shape, padding)}; } std::vector Reduce::create_output_tensors(const std::vector& input_tensors) const { diff --git a/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.hpp b/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.hpp index dc6b2894273..2f7dfbdabd6 100644 --- a/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.hpp +++ b/ttnn/cpp/ttnn/operations/reduction/generic/device/reduce_op.hpp @@ -30,7 +30,7 @@ struct Reduce { ttnn::DeviceComputeKernelConfig compute_kernel_config; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; ReduceOpParallelizationStrategy get_parallelization_strategy(const std::vector& input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/reduction/generic/generic_reductions.cpp b/ttnn/cpp/ttnn/operations/reduction/generic/generic_reductions.cpp index 81bb9c39d50..b82fdddc49e 100644 --- a/ttnn/cpp/ttnn/operations/reduction/generic/generic_reductions.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/generic/generic_reductions.cpp @@ -173,7 +173,7 @@ static Tensor reduce_impl( } if (reshape) { - output_tensor = ttnn::reshape(output_tensor, ttnn::Shape{tt::tt_metal::Shape{output_shape, padded_output_shape}}); + output_tensor = ttnn::reshape(output_tensor, ttnn::Shape{tt::tt_metal::LegacyShape{output_shape, padded_output_shape}}); } return output_tensor; diff --git a/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.cpp b/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.cpp index 6f9c3409ef7..c407e645e5a 100644 --- a/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.cpp @@ -29,7 +29,7 @@ void MoeDeviceOperation::validate_with_output_tensors( TT_FATAL(expert_shape[-2] == 32, "Expert shape inner dim must be equal to 32, got {}", expert_shape[-2]); } -std::vector MoeDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { +std::vector MoeDeviceOperation::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); return {ttnn::Shape(std::array{input_shape[0], input_shape[1], input_shape[2], 1},std::array{input_shape[0], input_shape[1], input_shape[2], 32}).value }; diff --git a/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.hpp b/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.hpp index b83d9d0ec20..be95e895c7a 100644 --- a/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.hpp +++ b/ttnn/cpp/ttnn/operations/reduction/moe/device/moe_op.hpp @@ -16,7 +16,7 @@ struct MoeDeviceOperation { const MemoryConfig output_mem_config; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.cpp b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.cpp index 69dcd9b015c..927a94f880e 100644 --- a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.cpp @@ -44,7 +44,7 @@ std::vector Prod::create_output_tensors(const std::vector& input return {}; } -std::vector Prod::compute_output_shapes(const std::vector& inputs) const { +std::vector Prod::compute_output_shapes(const std::vector& inputs) const { // Inplace return {}; @@ -58,7 +58,7 @@ operation::ProgramWithCallbacks Prod::create_program( return prod_nc_format(input, output, dim); } -inline Shape compute_output_shape(const Shape& input_shape, const int64_t& dim) { +tt::tt_metal::LegacyShape compute_output_shape(const tt::tt_metal::LegacyShape& input_shape, const int64_t& dim) { auto output_shape = input_shape; auto padding = output_shape.padding(); switch (dim) { @@ -67,11 +67,11 @@ inline Shape compute_output_shape(const Shape& input_shape, const int64_t& dim) break; } - return {Shape(output_shape, padding)}; + return {tt::tt_metal::LegacyShape(output_shape, padding)}; } inline Tensor create_output_tensor( - const Tensor& input_tensor, const Shape& output_shape, const MemoryConfig& mem_config) { + const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_shape, const MemoryConfig& mem_config) { TT_ASSERT(input_tensor.storage_type() == StorageType::DEVICE); return create_device_tensor(output_shape, input_tensor.get_dtype(), Layout::TILE, input_tensor.device(), mem_config); } diff --git a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.hpp b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.hpp index a0c61fa7e23..7d92526127b 100644 --- a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.hpp +++ b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_nc_op.hpp @@ -23,7 +23,7 @@ using namespace tt_metal; struct Prod { int64_t dim; void validate(const std::vector &inputs) const; - std::vector compute_output_shapes(const std::vector &inputs) const; + std::vector compute_output_shapes(const std::vector &inputs) const; std::vector create_output_tensors(const std::vector &inputs) const; operation::ProgramWithCallbacks create_program( const std::vector &inputs, std::vector &outputs) const; diff --git a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.cpp b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.cpp index 14f1b6d43e6..f297bec3cbc 100644 --- a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.cpp @@ -27,7 +27,7 @@ void Prod_op::validate(const std::vector& input_tensors) const { TT_FATAL(input_tensor_a.get_dtype() == DataType::BFLOAT16, "Error"); } -std::vector Prod_op::compute_output_shapes(const std::vector& input_tensors) const { +std::vector Prod_op::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); return {input_tensor.get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.hpp b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.hpp index 48cbd697c30..969a8185686 100644 --- a/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.hpp +++ b/ttnn/cpp/ttnn/operations/reduction/prod/device/prod_op_all.hpp @@ -22,7 +22,7 @@ struct Prod_op { const MemoryConfig output_mem_config; const DataType output_dtype; // TODO: Uplift output_dtype as an option for general dot/bmm void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector &input_tensors, std::vector &output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/reduction/prod/prod.cpp b/ttnn/cpp/ttnn/operations/reduction/prod/prod.cpp index 67eaaf58f3f..1f8255a4c7b 100644 --- a/ttnn/cpp/ttnn/operations/reduction/prod/prod.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/prod/prod.cpp @@ -58,7 +58,7 @@ inline Tensor prod_nc(const Tensor& temp, int64_t dim, const MemoryConfig& outpu } // Apply prod std::vector dimension = {(dim == 1 || dim == -3) ? 1 : 0}; - tt::tt_metal::Shape input_shape = formatted_input_tensor.get_legacy_shape(); + tt::tt_metal::LegacyShape input_shape = formatted_input_tensor.get_legacy_shape(); std::array required = { ((dim == 1 || dim == -3) ? input_shape[0] : 1), ((dim == 1 || dim == -3) ? 1 : input_shape[1]), @@ -103,7 +103,7 @@ Tensor ProdOperation::invoke(const Tensor& input_a, bool all_dimensions, int64_t } else if (dim == 2 || dim == -2) { std::vector after_permute_dims = {1, 2, 0, 3}; Tensor required = ttnn::permute(result, after_permute_dims, output_mem_config); - tt::tt_metal::Shape input_shape = input_a.get_legacy_shape(); + tt::tt_metal::LegacyShape input_shape = input_a.get_legacy_shape(); std::vector start_index = {0, 0, 0, 0}; std::vector end_index = {input_shape[0] - 1, input_shape[1] - 1, 0, input_shape[3] - 1}; return ttnn::slice(0, required, start_index, end_index, std::nullopt, std::nullopt); @@ -112,7 +112,7 @@ Tensor ProdOperation::invoke(const Tensor& input_a, bool all_dimensions, int64_t std::vector after_permute_dims = {1, 2, 0, 3}; Tensor required = ttnn::permute(result, after_permute_dims, output_mem_config); // unpad - tt::tt_metal::Shape input_shape = input_a.get_legacy_shape(); + tt::tt_metal::LegacyShape input_shape = input_a.get_legacy_shape(); std::vector start_index = {0, 0, 0, 0}; std::vector end_index = {input_shape[0] - 1, input_shape[1] - 1, 0, input_shape[2] - 1}; Tensor new_unpad_tensor = ttnn::slice(0, required, start_index, end_index, std::nullopt, std::nullopt); diff --git a/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.cpp b/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.cpp index c6cc0700296..c694ebab60e 100644 --- a/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.cpp +++ b/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.cpp @@ -51,7 +51,7 @@ void TopK::validate_with_output_tensors( } } -std::vector TopK::compute_output_shapes(const std::vector& input_tensors) const { +std::vector TopK::compute_output_shapes(const std::vector& input_tensors) const { const auto& input_tensor = input_tensors.at(0); const auto input_shape = input_tensor.get_legacy_shape(); return {{input_shape[0], input_shape[1], input_shape[2], this->k}, {input_shape[0], input_shape[1], input_shape[2], this->k}}; diff --git a/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.hpp b/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.hpp index 4ecd2dfc352..5223b9004a1 100644 --- a/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.hpp +++ b/ttnn/cpp/ttnn/operations/reduction/topk/device/topk_op.hpp @@ -19,7 +19,7 @@ struct TopK { const MemoryConfig output_mem_config; void validate_with_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors, const std::vector>& output_tensors) const; operation::ProgramWithCallbacks create_program( const std::vector& input_tensors, std::vector& output_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.cpp b/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.cpp index 25acde8c8e2..f16b0976dcc 100644 --- a/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.cpp +++ b/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.cpp @@ -25,10 +25,10 @@ void HaloDeviceOperation::validate(const std::vector &input_tensors) con TT_FATAL(input_tensor.shard_spec().has_value(), "Shard spec should not be empty"); } -std::vector HaloDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { +std::vector HaloDeviceOperation::compute_output_shapes(const std::vector &input_tensors) const { const auto& input = input_tensors.at(0); const auto& input_shape = input.get_legacy_shape(); - tt::tt_metal::Shape output_shape = input_shape; + tt::tt_metal::LegacyShape output_shape = input_shape; uint32_t nbatch = input_shape[0]; uint32_t total_nsticks = config_.num_cores_nhw * max_out_nsticks_per_core_; diff --git a/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.hpp b/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.hpp index 26a21d61dbe..b51623eba89 100644 --- a/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.hpp +++ b/ttnn/cpp/ttnn/operations/sliding_window/halo/device/halo_device_operation.hpp @@ -28,7 +28,7 @@ struct HaloDeviceOperation { bool is_out_tiled_; void validate(const std::vector &input_tensors) const; - std::vector compute_output_shapes(const std::vector &input_tensors) const; + std::vector compute_output_shapes(const std::vector &input_tensors) const; std::vector create_output_tensors(const std::vector &input_tensors) const; operation::ProgramWithCallbacks create_program(const std::vector& input_tensors, std::vector &output_tensors) const; // const operation::Hash compute_program_hash(const std::vector &input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/sliding_window/reference_sliding_window.hpp b/ttnn/cpp/ttnn/operations/sliding_window/reference_sliding_window.hpp index 2bf70141a40..90a899ccb86 100644 --- a/ttnn/cpp/ttnn/operations/sliding_window/reference_sliding_window.hpp +++ b/ttnn/cpp/ttnn/operations/sliding_window/reference_sliding_window.hpp @@ -14,7 +14,7 @@ #include "ttnn/operations/sliding_window/sliding_window.hpp" #include "ttnn/tensor/tensor.hpp" -using tt::tt_metal::Shape; +using tt::tt_metal::LegacyShape; using tt::tt_metal::Tensor; namespace ttnn::operations::sliding_window { diff --git a/ttnn/cpp/ttnn/operations/transformer/concatenate_heads/concatenate_heads.cpp b/ttnn/cpp/ttnn/operations/transformer/concatenate_heads/concatenate_heads.cpp index c82036ec0c1..13848e2800f 100644 --- a/ttnn/cpp/ttnn/operations/transformer/concatenate_heads/concatenate_heads.cpp +++ b/ttnn/cpp/ttnn/operations/transformer/concatenate_heads/concatenate_heads.cpp @@ -30,8 +30,8 @@ struct ConcatenateHeads : public ttnn::operations::experimental::transformer::NL NLPConcatHeadsDeviceOperation::validate(input_tensors); } - std::vector compute_output_shapes(const std::vector& input_tensors) const { - std::vector output_shape_vec; + std::vector compute_output_shapes(const std::vector& input_tensors) const { + std::vector output_shape_vec; const auto& input_tensor = input_tensors.at(0); const ttnn::types::Shape input_shape = input_tensor.get_shape(); const ttnn::types::Shape padded_input_shape = input_shape.with_tile_padding(); diff --git a/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.cpp b/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.cpp index 4570dfd6feb..e2905290d0e 100644 --- a/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.cpp +++ b/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.cpp @@ -135,7 +135,7 @@ void ScaledDotProductAttention::validate( } } -std::vector ScaledDotProductAttention::compute_output_shapes( +std::vector ScaledDotProductAttention::compute_output_shapes( const std::vector& input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.hpp b/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.hpp index 4999cee540b..501a2306751 100644 --- a/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.hpp +++ b/ttnn/cpp/ttnn/operations/transformer/sdpa/device/sdpa_op.hpp @@ -25,7 +25,7 @@ struct ScaledDotProductAttention { const std::vector& input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.cpp b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.cpp index 2c931bc5fca..c59d0ae2b0e 100644 --- a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.cpp +++ b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.cpp @@ -118,7 +118,7 @@ void ScaledDotProductAttentionDecode::validate(const std::vector& input_ this->compute_kernel_config); } -std::vector ScaledDotProductAttentionDecode::compute_output_shapes( +std::vector ScaledDotProductAttentionDecode::compute_output_shapes( const std::vector& input_tensors) const { return {input_tensors.at(0).get_legacy_shape()}; } diff --git a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.hpp b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.hpp index 473908fbca6..19ff511ed5d 100644 --- a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.hpp +++ b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode/device/sdpa_decode_op.hpp @@ -25,7 +25,7 @@ struct ScaledDotProductAttentionDecode { void validate(const std::vector& input_tensors, const std::vector>& optional_input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.cpp b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.cpp index 17df4a20026..a9db108b4ea 100644 --- a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.cpp +++ b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.cpp @@ -66,7 +66,7 @@ void ScaledDotProductAttentionGQADecode::validate(const std::vector& inp this->compute_kernel_config); } -std::vector ScaledDotProductAttentionGQADecode::compute_output_shapes( +std::vector ScaledDotProductAttentionGQADecode::compute_output_shapes( const std::vector& input_tensors) const { auto tt_q_shape = input_tensors.at(0).get_legacy_shape(); auto tt_k_shape = input_tensors.at(1).get_legacy_shape(); diff --git a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.hpp b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.hpp index d68f5fae9b2..7f3791104d3 100644 --- a/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.hpp +++ b/ttnn/cpp/ttnn/operations/transformer/sdpa_decode_gqa/device/sdpa_decode_gqa_op.hpp @@ -23,7 +23,7 @@ struct ScaledDotProductAttentionGQADecode { void validate(const std::vector& input_tensors) const; - std::vector compute_output_shapes(const std::vector& input_tensors) const; + std::vector compute_output_shapes(const std::vector& input_tensors) const; std::vector create_output_tensors(const std::vector& input_tensors) const; diff --git a/ttnn/cpp/ttnn/operations/transformer/split_query_key_value_and_split_heads/split_query_key_value_and_split_heads.cpp b/ttnn/cpp/ttnn/operations/transformer/split_query_key_value_and_split_heads/split_query_key_value_and_split_heads.cpp index 935f8d42241..533c8eeae23 100644 --- a/ttnn/cpp/ttnn/operations/transformer/split_query_key_value_and_split_heads/split_query_key_value_and_split_heads.cpp +++ b/ttnn/cpp/ttnn/operations/transformer/split_query_key_value_and_split_heads/split_query_key_value_and_split_heads.cpp @@ -29,27 +29,27 @@ std::tuple reshape_outputs_of_split_query_key_value_and_ query = ttnn::reshape( query, - ttnn::Shape(tt::tt_metal::Shape( + ttnn::Shape(tt::tt_metal::LegacyShape( std::array{batch_size, num_heads, sequence_size, head_size}, std::array{batch_size, num_heads, sequence_size_padded, head_size_padded}))); if (transpose_key) { key = ttnn::reshape( key, - ttnn::Shape(tt::tt_metal::Shape( + ttnn::Shape(tt::tt_metal::LegacyShape( std::array{batch_size, num_kv_heads, head_size, sequence_size}, std::array{batch_size, num_kv_heads, head_size_padded, sequence_size_padded}))); } else { key = ttnn::reshape( key, - ttnn::Shape(tt::tt_metal::Shape( + ttnn::Shape(tt::tt_metal::LegacyShape( std::array{batch_size, num_kv_heads, sequence_size, head_size}, std::array{batch_size, num_kv_heads, sequence_size_padded, head_size_padded}))); } value = ttnn::reshape( value, - ttnn::Shape(tt::tt_metal::Shape( + ttnn::Shape(tt::tt_metal::LegacyShape( std::array{batch_size, num_kv_heads, sequence_size, head_size}, std::array{batch_size, num_kv_heads, sequence_size_padded, head_size_padded}))); return {query, key, value}; diff --git a/ttnn/cpp/ttnn/run_operation.cpp b/ttnn/cpp/ttnn/run_operation.cpp index 896dbdbed31..cfa2be30c4e 100644 --- a/ttnn/cpp/ttnn/run_operation.cpp +++ b/ttnn/cpp/ttnn/run_operation.cpp @@ -100,7 +100,7 @@ struct OldInfraDeviceOperation { const operation::OptionalTensors optional_output_tensors; }; - using shape_return_value_t = std::vector; + using shape_return_value_t = std::vector; using tensor_return_value_t = OutputTensors; diff --git a/ttnn/cpp/ttnn/tensor/serialization.cpp b/ttnn/cpp/ttnn/tensor/serialization.cpp index 7b594735749..68cc4eb8717 100644 --- a/ttnn/cpp/ttnn/tensor/serialization.cpp +++ b/ttnn/cpp/ttnn/tensor/serialization.cpp @@ -62,7 +62,7 @@ void dump_multi_device_host_storage(std::ofstream& output_stream, const MultiDev output_stream.write(reinterpret_cast(buffer.begin()), sizeof(T) * size); }, storage.get_buffer(0) ); - output_stream.write(reinterpret_cast(&storage.shapes.at(0)), sizeof(Shape)); + output_stream.write(reinterpret_cast(&storage.shapes.at(0)), sizeof(tt::tt_metal::LegacyShape)); } else { for (int i = 0; i < num_buffers; i++) { @@ -76,7 +76,7 @@ void dump_multi_device_host_storage(std::ofstream& output_stream, const MultiDev ); } for (const auto& shape : storage.shapes) { - output_stream.write(reinterpret_cast(&shape), sizeof(Shape)); + output_stream.write(reinterpret_cast(&shape), sizeof(tt::tt_metal::LegacyShape)); } } } @@ -99,14 +99,14 @@ MultiDeviceHostStorage load_multi_device_host_storage(std::ifstream& input_strea input_stream.read(reinterpret_cast(&strategy), sizeof(DistributedTensorConfig)); std::vector buffers; - std::vector shapes; + std::vector shapes; if (std::holds_alternative(strategy)) { std::size_t size = 0; input_stream.read(reinterpret_cast(&size), sizeof(std::size_t)); auto buffer = owned_buffer::create(size); - auto shape = Shape{}; + auto shape = tt::tt_metal::LegacyShape{}; input_stream.read(reinterpret_cast(buffer.begin()), sizeof(T) * size); - input_stream.read(reinterpret_cast(&shape), sizeof(Shape)); + input_stream.read(reinterpret_cast(&shape), sizeof(tt::tt_metal::LegacyShape)); buffers.push_back(buffer); shapes.push_back(shape); @@ -126,8 +126,8 @@ MultiDeviceHostStorage load_multi_device_host_storage(std::ifstream& input_strea buffers.push_back(std::move(buffer)); } for (std::size_t i = 0; i < num_buffers; ++i) { - auto shape = Shape{}; - input_stream.read(reinterpret_cast(&shape), sizeof(Shape)); + auto shape = tt::tt_metal::LegacyShape{}; + input_stream.read(reinterpret_cast(&shape), sizeof(tt::tt_metal::LegacyShape)); shapes.push_back(shape); } } @@ -207,7 +207,7 @@ void dump_tensor(const std::string& file_name, const Tensor& tensor, const std:: output_stream.write(reinterpret_cast(&detail::SENTINEL_VALUE), sizeof(std::size_t)); output_stream.write(reinterpret_cast(&VERSION_ID), sizeof(std::uint8_t)); - output_stream.write(reinterpret_cast(&shape), sizeof(Shape)); + output_stream.write(reinterpret_cast(&shape), sizeof(tt::tt_metal::LegacyShape)); output_stream.write(reinterpret_cast(&data_type), sizeof(DataType)); output_stream.write(reinterpret_cast(&layout), sizeof(Layout)); output_stream.write(reinterpret_cast(&storage_type), sizeof(StorageType)); @@ -270,11 +270,11 @@ Tensor load_tensor(const std::string& file_name, T device) { if (version_id > VERSION_ID) { throw std::runtime_error(fmt::format("Serialized tensor with version_id: {}. Loader version: {}", version_id, VERSION_ID)); } - auto shape = Shape{}; + auto shape = tt::tt_metal::LegacyShape{}; DataType data_type; Layout layout; StorageType storage_type; - input_stream.read(reinterpret_cast(&shape), sizeof(Shape)); + input_stream.read(reinterpret_cast(&shape), sizeof(tt::tt_metal::LegacyShape)); input_stream.read(reinterpret_cast(&data_type), sizeof(DataType)); input_stream.read(reinterpret_cast(&layout), sizeof(Layout)); input_stream.read(reinterpret_cast(&storage_type), sizeof(StorageType)); @@ -303,10 +303,10 @@ Tensor load_tensor(const std::string& file_name, T device) { } else { input_stream.seekg(0, std::ios::beg); // No sentinel found, assume it's an older format and rewind - auto shape = Shape{}; + auto shape = tt::tt_metal::LegacyShape{}; DataType data_type; Layout layout; - input_stream.read(reinterpret_cast(&shape), sizeof(Shape)); + input_stream.read(reinterpret_cast(&shape), sizeof(tt::tt_metal::LegacyShape)); input_stream.read(reinterpret_cast(&data_type), sizeof(DataType)); input_stream.read(reinterpret_cast(&layout), sizeof(Layout)); diff --git a/ttnn/cpp/ttnn/tensor/tensor.cpp b/ttnn/cpp/ttnn/tensor/tensor.cpp index d286c56aa9e..2634ca5f295 100644 --- a/ttnn/cpp/ttnn/tensor/tensor.cpp +++ b/ttnn/cpp/ttnn/tensor/tensor.cpp @@ -81,7 +81,7 @@ Tensor::Tensor(const Storage storage, const ttnn::Shape shape, DataType dtype, L this->tensor_attributes->metadata_populated = true; } -Tensor::Tensor(const Storage storage, const Shape shape, DataType dtype, Layout layout) : +Tensor::Tensor(const Storage storage, const tt::tt_metal::LegacyShape shape, DataType dtype, Layout layout) : Tensor(storage, ttnn::Shape{shape}, dtype, layout) {} Tensor::~Tensor() { @@ -344,7 +344,7 @@ std::vector Tensor::get_workers(bool blocking) const { } // Getters - Spin until tensor is populated before querying tensor metadata -const Shape& Tensor::get_legacy_shape() const { +const tt::tt_metal::LegacyShape& Tensor::get_legacy_shape() const { this->wait_for_tensor_metadata_populated(); return this->tensor_attributes->shape.value; } @@ -417,11 +417,11 @@ void Tensor::print() const { tensor_ops::tensor_print(*this); } -Tensor Tensor::pad(const Shape& output_tensor_shape, const Shape& input_tensor_start, float pad_value) const { +Tensor Tensor::pad(const tt::tt_metal::LegacyShape& output_tensor_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) const { return tensor_ops::tensor_pad(*this, output_tensor_shape, input_tensor_start, pad_value); } -Tensor Tensor::unpad(const Shape& output_tensor_start, const Shape& output_tensor_end) const { +Tensor Tensor::unpad(const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) const { return tensor_ops::tensor_unpad(*this, output_tensor_start, output_tensor_end); } @@ -429,7 +429,7 @@ Tensor Tensor::pad_to_tile(float pad_value) const { return tensor_ops::tensor_pad_to_tile(*this, pad_value); } -Tensor Tensor::unpad_from_tile(const Shape& output_tensor_shape) const { +Tensor Tensor::unpad_from_tile(const tt::tt_metal::LegacyShape& output_tensor_shape) const { return tensor_ops::tensor_unpad_from_tile(*this, output_tensor_shape); } @@ -443,7 +443,7 @@ Tensor Tensor::reshape(int N, int C, int H, int W) const { return tensor_ops::tensor_reshape(*this, N, C, H, W); } -Tensor Tensor::reshape(const Shape& new_shape) const { +Tensor Tensor::reshape(const tt::tt_metal::LegacyShape& new_shape) const { return tensor_ops::tensor_reshape(*this, new_shape); } @@ -494,14 +494,14 @@ StorageType Tensor::storage_type() const { this->get_storage()); } -const Shape Tensor::strides() const { return Shape(tt::tt_metal::compute_strides(this->get_legacy_shape())); } +const tt::tt_metal::LegacyShape Tensor::strides() const { return tt::tt_metal::LegacyShape(tt::tt_metal::compute_strides(this->get_legacy_shape())); } uint32_t Tensor::volume() const { return tt::tt_metal::compute_volume(this->get_legacy_shape()); } uint32_t Tensor::intended_volume() const { return tt::tt_metal::compute_volume(this->get_shape()); } Tensor create_device_tensor( - const Shape& shape, DataType data_type, Layout layout, Device* device, const MemoryConfig& memory_config) { + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, Device* device, const MemoryConfig& memory_config) { ZoneScoped; GraphTracker::instance().track_function_start("tt::tt_metal::create_device_tensor", shape, data_type, layout, device, memory_config); if (memory_config.is_sharded()) { diff --git a/ttnn/cpp/ttnn/tensor/tensor.hpp b/ttnn/cpp/ttnn/tensor/tensor.hpp index 701c70b012d..d053a98b51f 100644 --- a/ttnn/cpp/ttnn/tensor/tensor.hpp +++ b/ttnn/cpp/ttnn/tensor/tensor.hpp @@ -119,7 +119,7 @@ struct Tensor { deallocate_through_destructor(false) {} Tensor(const Storage storage, const ttnn::Shape shape, DataType dtype, Layout layout); - Tensor(const Storage storage, const Shape shape, DataType dtype, Layout layout); + Tensor(const Storage storage, const tt::tt_metal::LegacyShape shape, DataType dtype, Layout layout); // Constructor to initialize unpopulated tensor with workers and storage specified. Use this when creating tensor // handles in async mode. @@ -175,7 +175,7 @@ struct Tensor { std::get(this->tensor_attributes->storage).buffers = std::vector(num_buffers, OwnedBuffer()); std::get(this->tensor_attributes->storage).shapes = - std::vector(num_buffers, this->tensor_attributes->shape.value); + std::vector(num_buffers, this->tensor_attributes->shape.value); } this->tensor_attributes->num_shards_to_be_populated = num_buffers; } @@ -260,17 +260,17 @@ struct Tensor { Tensor to(Layout target_layout, MeshDevice *mesh_device) const; - Tensor pad(const Shape &output_tensor_shape, const Shape &input_tensor_start, float pad_value) const; + Tensor pad(const tt::tt_metal::LegacyShape &output_tensor_shape, const tt::tt_metal::LegacyShape &input_tensor_start, float pad_value) const; Tensor cpu(bool blocking = true, uint8_t cq_id = ttnn::DefaultQueueId) const; Tensor cpu_sharded() const; - Tensor unpad(const Shape &output_tensor_start, const Shape &output_tensor_end) const; + Tensor unpad(const tt::tt_metal::LegacyShape &output_tensor_start, const tt::tt_metal::LegacyShape &output_tensor_end) const; Tensor pad_to_tile(float pad_value) const; - Tensor unpad_from_tile(const Shape &output_tensor_shape) const; + Tensor unpad_from_tile(const tt::tt_metal::LegacyShape &output_tensor_shape) const; const std::string write_to_string() const; void print() const; @@ -282,14 +282,14 @@ struct Tensor { // Low Level APIs // ====================================================================================== Tensor reshape(int N, int C, int H, int W) const; - Tensor reshape(const tt::tt_metal::Shape &new_shape) const; + Tensor reshape(const tt::tt_metal::LegacyShape &new_shape) const; // ====================================================================================== // Getters // ====================================================================================== const Storage &get_storage() const; // [[deprecated("Use get_shape() instead.")]] - const Shape &get_legacy_shape() const; + const tt::tt_metal::LegacyShape &get_legacy_shape() const; const ttnn::Shape &get_shape() const; const DataType &get_dtype() const; const Layout &get_layout() const; @@ -298,7 +298,7 @@ struct Tensor { // Non-Blocking Getters. Query attributes directly, without waiting for worker completion // ====================================================================================== inline const Storage &storage() const { return this->tensor_attributes->storage; }; - inline const Shape &legacy_shape() const { return this->tensor_attributes->shape.value; }; + inline const tt::tt_metal::LegacyShape &legacy_shape() const { return this->tensor_attributes->shape.value; }; inline const ttnn::Shape &shape() const { return this->tensor_attributes->shape; }; inline const DataType &dtype() const { return this->tensor_attributes->dtype; }; inline const Layout &layout() const { return this->tensor_attributes->layout; }; @@ -314,7 +314,7 @@ struct Tensor { // Extra Helper Functions // ====================================================================================== StorageType storage_type() const; - const Shape strides() const; + const tt::tt_metal::LegacyShape strides() const; uint32_t volume() const; uint32_t intended_volume() const; @@ -392,7 +392,7 @@ struct Tensor { }; Tensor create_device_tensor( - const Shape &shape, + const tt::tt_metal::LegacyShape &shape, DataType dtype, Layout layout, Device *device, diff --git a/ttnn/cpp/ttnn/tensor/tensor_impl.cpp b/ttnn/cpp/ttnn/tensor/tensor_impl.cpp index 3e5b0aca4ee..d55ad1b2596 100644 --- a/ttnn/cpp/ttnn/tensor/tensor_impl.cpp +++ b/ttnn/cpp/ttnn/tensor/tensor_impl.cpp @@ -43,7 +43,7 @@ uint32_t element_size_bytes(DataType dtype) { } } -uint32_t get_page_size(DataType dtype, Layout layout, uint32_t total_size_bytes, const Shape& shape) { +uint32_t get_page_size(DataType dtype, Layout layout, uint32_t total_size_bytes, const tt::tt_metal::LegacyShape& shape) { uint32_t W = shape[-1]; uint32_t page_size = 0; switch (layout) { @@ -98,7 +98,7 @@ std::array get_sharded_page_shape(Layout layout, DataType dtype, st } void validate_sharded_buffer_allocation( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, Layout layout, DataType data_type, const ShardSpecBuffer& shard_params, @@ -176,7 +176,7 @@ namespace detail { DeviceBuffer allocate_interleaved_buffer_on_device( size_t buffer_size_bytes, Device* device, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, const MemoryConfig& memory_config) { @@ -192,7 +192,7 @@ DeviceBuffer allocate_contiguous_buffer_on_device( DeviceBuffer allocate_sharded_buffer_on_device( size_t buffer_size_bytes, Device* device, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, const ShardSpecBuffer& shard_params, @@ -210,7 +210,7 @@ DeviceBuffer allocate_sharded_buffer_on_device( DeviceBuffer allocate_buffer_on_device( size_t buffer_size_bytes, Device* device, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, const MemoryConfig& memory_config, @@ -227,7 +227,7 @@ DeviceBuffer allocate_buffer_on_device( } } -void validate_on_device_dtype_and_layout(Device* device, const Shape& shape, DataType dtype, Layout layout) { +void validate_on_device_dtype_and_layout(Device* device, const tt::tt_metal::LegacyShape& shape, DataType dtype, Layout layout) { // TODO: Get supported layout and dtypes from device auto supported_dtype = [&dtype]() { TT_ASSERT( @@ -275,7 +275,7 @@ void validate_on_device_dtype_and_layout(Device* device, const Shape& shape, Dat } Tensor pad_bfloat8_b( - const Tensor& tensor, const Shape& output_tensor_shape, const Shape& input_tensor_start, float pad_value) { + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) { // TODO(arakhmati): do not convert to FLOAT32 // Convert to FLOAT32 tensor and pad @@ -299,7 +299,7 @@ Tensor pad_bfloat8_b( tensor.get_layout()); } -Tensor unpad_bfloat8_b(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end) { +Tensor unpad_bfloat8_b(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { // TODO(arakhmati): do not convert to FLOAT32 // Convert to FLOAT32 tensor and unpad @@ -324,7 +324,7 @@ Tensor unpad_bfloat8_b(const Tensor& tensor, const Shape& output_tensor_start, c } Tensor pad_bfloat4_b( - const Tensor& tensor, const Shape& output_tensor_shape, const Shape& input_tensor_start, float pad_value) { + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) { // TODO(arakhmati): do not convert to FLOAT32 // Convert to FLOAT32 tensor and pad @@ -348,7 +348,7 @@ Tensor pad_bfloat4_b( tensor.get_layout()); } -Tensor unpad_bfloat4_b(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end) { +Tensor unpad_bfloat4_b(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { // TODO(arakhmati): do not convert to FLOAT32 // Convert to FLOAT32 tensor and unpad @@ -438,7 +438,7 @@ template void to_string_row_major( std::stringstream& ss, const BufferType& buffer, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, std::size_t outer_index, const std::size_t buffer_offset) { auto stride = 1; @@ -493,7 +493,7 @@ template void to_string_tile( std::stringstream& ss, const BufferType& buffer, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, std::size_t outer_index, const std::size_t buffer_offset) { // For now, print it the same way as row-major @@ -501,7 +501,7 @@ void to_string_tile( } template -std::string to_string(const BufferType& buffer, const Shape& shape, DataType dtype, Layout layout) { +std::string to_string(const BufferType& buffer, const tt::tt_metal::LegacyShape& shape, DataType dtype, Layout layout) { std::stringstream ss; ss << TENSOR_TYPE_STRING << "("; @@ -781,7 +781,7 @@ template typename BufferType> DeviceBuffer initialize_data_on_device( BufferType& data_to_write, Device* device, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, const MemoryConfig& memory_config, @@ -807,7 +807,7 @@ template DeviceBuffer to_device_buffer( const Storage& storage, Device* device, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, const MemoryConfig& memory_config, @@ -980,7 +980,7 @@ Tensor to_layout(const Tensor& tensor, Layout target_layout) { return OwnedStorage{output_buffer}; } else if constexpr (std::is_same_v) { std::vector output_buffers; - std::vector output_shapes; + std::vector output_shapes; for (int i = 0; i < storage.num_buffers(); i++) { const auto input_data = owned_buffer::get_as(storage.get_buffer(i)); auto output_buffer = owned_buffer::create(std::move(convert(input_data))); @@ -1136,7 +1136,7 @@ Tensor to_layout(const Tensor& tensor, Layout target_layout) { // ====================================================================================== template -Tensor pad(const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value) { +Tensor pad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) { if (is_multi_device_tensor(tensor)) { return transform(tensor, [&](const Tensor& device_tensor) { return pad(device_tensor, output_shape, input_tensor_start, pad_value); @@ -1150,7 +1150,7 @@ Tensor pad(const Tensor& tensor, const Shape& output_shape, const Shape& input_t auto pad = [&input_shape, &input_strides, &input_data_type, &output_shape, &input_tensor_start, &pad_value_]( const auto& input_buffer) { - auto compute_stride = [](const Shape& shape, uint32_t index) { + auto compute_stride = [](const tt::tt_metal::LegacyShape& shape, uint32_t index) { uint32_t stride = 1; for (auto i = index + 1; i < shape.rank(); i++) { stride *= shape[i]; @@ -1226,32 +1226,32 @@ Tensor pad(const Tensor& tensor, const Shape& output_shape, const Shape& input_t } template Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template <> Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value) { + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) { return pad_bfloat8_b(tensor, output_shape, input_tensor_start, pad_value); } template <> Tensor pad( - const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value) { + const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) { return pad_bfloat4_b(tensor, output_shape, input_tensor_start, pad_value); } template -Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end) { +Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { const auto input_shape = tensor.get_legacy_shape(); const auto input_strides = tensor.strides(); @@ -1313,20 +1313,20 @@ Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape return Tensor(OwnedStorage{output_buffer}, output_shape, tensor.get_dtype(), tensor.get_layout()); } -template Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); -template Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); -template Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); -template Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); -template Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); -template Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); +template Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); +template Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); +template Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); +template Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); +template Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); +template Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); template <> -Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end) { +Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { return unpad_bfloat8_b(tensor, output_tensor_start, output_tensor_end); } template <> -Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end) { +Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { return unpad_bfloat4_b(tensor, output_tensor_start, output_tensor_end); } @@ -1339,7 +1339,7 @@ Tensor extract_shard(const Tensor& tensor, const uint32_t& core_id) { auto buffer = tensor.buffer(); auto buffer_shard_shape = buffer->shard_spec().shape(); std::array shard_shape_array = {1, 1, buffer_shard_shape[0], buffer_shard_shape[1]}; - Shape shard_shape(shard_shape_array); + tt::tt_metal::LegacyShape shard_shape(shard_shape_array); std::vector device_data; ::detail::ReadShard(*buffer, device_data, core_id); diff --git a/ttnn/cpp/ttnn/tensor/tensor_impl.hpp b/ttnn/cpp/ttnn/tensor/tensor_impl.hpp index d3e01c13862..422d4308377 100644 --- a/ttnn/cpp/ttnn/tensor/tensor_impl.hpp +++ b/ttnn/cpp/ttnn/tensor/tensor_impl.hpp @@ -187,7 +187,7 @@ constexpr inline size_t packed_buffer_size_bytes(size_t volume_unpack // Layout converters // ====================================================================================== namespace detail { -static std::vector to_4D_shape(const Shape& shape) { +static std::vector to_4D_shape(const tt::tt_metal::LegacyShape& shape) { if (shape.rank() == 1) { return {1, 1, 1, shape[-1]}; } else if (shape.rank() == 2) { @@ -201,7 +201,7 @@ static std::vector to_4D_shape(const Shape& shape) { } } -static std::vector to_vector(const Shape& shape) { +static std::vector to_vector(const tt::tt_metal::LegacyShape& shape) { std::vector shape_vec; for (int i = 0; i < shape.rank(); i++) { shape_vec.push_back(shape[i]); @@ -212,7 +212,7 @@ static std::vector to_vector(const Shape& shape) { } // namespace detail template typename BufferType> -inline std::vector convert_layout_row_major_to_tile(const Shape& shape, const BufferType& data_to_convert) { +inline std::vector convert_layout_row_major_to_tile(const tt::tt_metal::LegacyShape& shape, const BufferType& data_to_convert) { TT_FATAL( (shape[-2] % tt::constants::TILE_HEIGHT == 0 && shape[-1] % tt::constants::TILE_WIDTH == 0), "Unsupported shape for tensor conversion"); @@ -221,7 +221,7 @@ inline std::vector convert_layout_row_major_to_tile(const Shape& shape, const } template typename BufferType> -inline std::vector convert_layout_tile_to_row_major(const Shape& shape, const BufferType& data_to_convert) { +inline std::vector convert_layout_tile_to_row_major(const tt::tt_metal::LegacyShape& shape, const BufferType& data_to_convert) { return convert_layout( data_to_convert, detail::to_vector(shape), TensorLayout::TILED32_4FACES, TensorLayout::LIN_ROW_MAJOR); } @@ -229,9 +229,9 @@ inline std::vector convert_layout_tile_to_row_major(const Shape& shape, const // ====================================================================================== // Validators // ====================================================================================== -void validate_on_device_dtype_and_layout(Device* device, const Shape& shape, DataType dtype, Layout layout); +void validate_on_device_dtype_and_layout(Device* device, const tt::tt_metal::LegacyShape& shape, DataType dtype, Layout layout); void validate_sharded_buffer_allocation( - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, Layout layout, DataType data_type, const ShardSpecBuffer& shard_params, @@ -246,12 +246,12 @@ void validate_sharded_buffer_allocation( // Data reader, writer, and initializers // ====================================================================================== -uint32_t get_page_size(DataType dtype, Layout layout, uint32_t total_size_bytes, const Shape& shape); +uint32_t get_page_size(DataType dtype, Layout layout, uint32_t total_size_bytes, const tt::tt_metal::LegacyShape& shape); DeviceBuffer allocate_buffer_on_device( size_t buffer_size_bytes, Device* device, - const Shape& shape, + const tt::tt_metal::LegacyShape& shape, DataType data_type, Layout layout, const MemoryConfig& memory_config, @@ -297,10 +297,10 @@ Tensor to_layout_bfloat(const Tensor& tensor, Layout target_layout); // .pad() and .unpad() // ====================================================================================== template -Tensor pad(const Tensor& tensor, const Shape& output_shape, const Shape& input_tensor_start, float pad_value); +Tensor pad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); template -Tensor unpad(const Tensor& tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); +Tensor unpad(const Tensor& tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); // ====================================================================================== // Print diff --git a/ttnn/cpp/ttnn/tensor/tensor_ops.cpp b/ttnn/cpp/ttnn/tensor/tensor_ops.cpp index a4c178d954f..ef39c5d9aca 100644 --- a/ttnn/cpp/ttnn/tensor/tensor_ops.cpp +++ b/ttnn/cpp/ttnn/tensor/tensor_ops.cpp @@ -250,7 +250,7 @@ void tensor_print(const Tensor& input_tensor) { GraphTracker::instance().track_function_end(); } -Tensor tensor_pad(const Tensor& input_tensor, const Shape& output_tensor_shape, const Shape& input_tensor_start, float pad_value) { +Tensor tensor_pad(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_tensor_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value) { ZoneScoped; GraphTracker::instance().track_function_start("Tensor::pad", input_tensor, output_tensor_shape, input_tensor_start, pad_value); TT_ASSERT( @@ -266,7 +266,7 @@ Tensor tensor_pad(const Tensor& input_tensor, const Shape& output_tensor_shape, dimensions_pads.push_back(Padding::PadDimension{.front = front, .back = back}); } const auto padding = Padding(dimensions_pads, Padding::PadValue::Any); - auto output_shape_with_padding = Shape(output_tensor_shape, padding); + auto output_shape_with_padding = tt::tt_metal::LegacyShape(output_tensor_shape, padding); auto output = tensor_impl::pad_wrapper(input_tensor, output_shape_with_padding, input_tensor_start, pad_value); output = tt::tt_metal::set_tensor_id(output); @@ -274,7 +274,7 @@ Tensor tensor_pad(const Tensor& input_tensor, const Shape& output_tensor_shape, return output; } -Tensor tensor_unpad(const Tensor& input_tensor, const Shape& output_tensor_start, const Shape& output_tensor_end) { +Tensor tensor_unpad(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end) { ZoneScoped; GraphTracker::instance().track_function_start("Tensor::unpad", input_tensor, output_tensor_start, output_tensor_end); TT_ASSERT(input_tensor.get_layout() == Layout::ROW_MAJOR && "Tensor layout must be ROW_MAJOR for unpadding"); @@ -309,13 +309,13 @@ Tensor tensor_pad_to_tile(const Tensor& input_tensor, float pad_value) { input_tensor_start.push_back(0); input_tensor_start.push_back(0); - auto output = input_tensor.pad(Shape(shape, padded_shape), Shape{input_tensor_start}, pad_value); + auto output = input_tensor.pad(tt::tt_metal::LegacyShape(shape, padded_shape), tt::tt_metal::LegacyShape{input_tensor_start}, pad_value); output = tt::tt_metal::set_tensor_id(output); GraphTracker::instance().track_function_end(output); return output; } -Tensor tensor_unpad_from_tile(const Tensor& input_tensor, const Shape& output_tensor_shape) { +Tensor tensor_unpad_from_tile(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_tensor_shape) { ZoneScoped; GraphTracker::instance().track_function_start("Tensor::unpad_from_tile", input_tensor, output_tensor_shape); @@ -353,7 +353,7 @@ Tensor tensor_reshape(const Tensor& input_tensor, int N, int C, int H, int W) { return output; } -Tensor tensor_reshape(const Tensor& input_tensor, const Shape& new_shape) { +Tensor tensor_reshape(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& new_shape) { ZoneScoped; GraphTracker::instance().track_function_start("Tensor::reshape", input_tensor, new_shape); TT_ASSERT( @@ -379,7 +379,7 @@ Tensor tensor_reshape(const Tensor& input_tensor, const Shape& new_shape) { } if constexpr (std::is_same_v) { MultiDeviceStorage updated_storage = std::get(tensor.get_storage()); - std::unordered_map new_shapes; + std::unordered_map new_shapes; for (auto device_id : updated_storage.ordered_device_ids) { new_shapes.insert({device_id, new_shape}); diff --git a/ttnn/cpp/ttnn/tensor/tensor_ops.hpp b/ttnn/cpp/ttnn/tensor/tensor_ops.hpp index c1945d64487..6de950409e5 100644 --- a/ttnn/cpp/ttnn/tensor/tensor_ops.hpp +++ b/ttnn/cpp/ttnn/tensor/tensor_ops.hpp @@ -29,16 +29,16 @@ Tensor tensor_cpu_sharded(const Tensor& input_tensor); void tensor_print(const Tensor& input_tensor); -Tensor tensor_pad(const Tensor& input_tensor, const Shape& output_tensor_shape, const Shape& input_tensor_start, float pad_value); +Tensor tensor_pad(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_tensor_shape, const tt::tt_metal::LegacyShape& input_tensor_start, float pad_value); -Tensor tensor_unpad(const Tensor& input_tensor, const Shape& output_tensor_start, const Shape& output_tensor_end); +Tensor tensor_unpad(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_tensor_start, const tt::tt_metal::LegacyShape& output_tensor_end); Tensor tensor_pad_to_tile(const Tensor& input_tensor, float pad_value); -Tensor tensor_unpad_from_tile(const Tensor& input_tensor, const Shape& output_tensor_shape); +Tensor tensor_unpad_from_tile(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& output_tensor_shape); Tensor tensor_reshape(const Tensor& input_tensor, int N, int C, int H, int W); -Tensor tensor_reshape(const Tensor& input_tensor, const Shape& new_shape); +Tensor tensor_reshape(const Tensor& input_tensor, const tt::tt_metal::LegacyShape& new_shape); } diff --git a/ttnn/cpp/ttnn/tensor/tensor_utils.cpp b/ttnn/cpp/ttnn/tensor/tensor_utils.cpp index 25cd2bf7b9d..1f8750f9ba8 100644 --- a/ttnn/cpp/ttnn/tensor/tensor_utils.cpp +++ b/ttnn/cpp/ttnn/tensor/tensor_utils.cpp @@ -28,7 +28,7 @@ Tensor to_weight_special_padding_tile_layout( assert(in1_block_h_datums >= w_shape[1] * w_shape[3]); uint32_t block_height_padding = in1_block_h_datums - (w_shape[1] * w_shape[3]); auto weight_matrix_rows = ((w_shape[1] * w_shape[3]) + block_height_padding) * w_shape[2]; - Shape output_shape = {1, 1, weight_matrix_rows, weight_matrix_cols}; + tt::tt_metal::LegacyShape output_shape = {1, 1, weight_matrix_rows, weight_matrix_cols}; auto output_buffer = owned_buffer::create(compute_volume(output_shape)); for (auto r = 0; r < w_shape[2]; r++) { for (auto s = 0; s < w_shape[3]; s++) { @@ -112,7 +112,7 @@ Tensor to_weight_tile_layout( weight_matrix_rows = (uint32_t)std::ceil((double)weight_matrix_rows / (double)in1_block_h_datums) * in1_block_h_datums; } - Shape output_shape = {1, 1, weight_matrix_rows, weight_matrix_cols}; + tt::tt_metal::LegacyShape output_shape = {1, 1, weight_matrix_rows, weight_matrix_cols}; auto output_buffer = owned_buffer::create(compute_volume(output_shape)); for (auto r = 0; r < w_shape[2]; r++) { for (auto s = 0; s < w_shape[3]; s++) { @@ -243,8 +243,8 @@ Helper function to aid in converting grouped weight tensor to ungrouped weight t template static Tensor conv_group_weight_zero_pad_helper( Tensor& conv_weight_tensor, - Shape& original_weight_shape, - Shape& output_weight_shape, + tt::tt_metal::LegacyShape& original_weight_shape, + tt::tt_metal::LegacyShape& output_weight_shape, uint32_t num_groups, DataType output_dtype) { owned_buffer::Buffer output_buffer = owned_buffer::create(compute_volume(output_weight_shape)); @@ -289,8 +289,8 @@ Helper function to aid in converting depthwise weight tensor to broadcasted weig template static Tensor conv_depthwise_weight_bcast_helper( Tensor& conv_weight_tensor, - Shape& original_weight_shape, - Shape& output_weight_shape, + tt::tt_metal::LegacyShape& original_weight_shape, + tt::tt_metal::LegacyShape& output_weight_shape, DataType output_dtype) { owned_buffer::Buffer output_buffer = owned_buffer::create(compute_volume(output_weight_shape)); auto conv_weight_tensor_buffer = borrowed_buffer::get_as(conv_weight_tensor); @@ -330,12 +330,12 @@ Tensor convert_conv_weight_tensor_to_grouped_layout( // Define output tensor shape. This is going to be channel dimension of weight tensor * num_groups - this value // should match number of input channels being convolved with the weight tensor auto original_conv_weight_tensor_shape_test = conv_weight_tensor.get_shape(); - Shape original_conv_weight_tensor_shape = { + tt::tt_metal::LegacyShape original_conv_weight_tensor_shape = { original_conv_weight_tensor_shape_test[0], original_conv_weight_tensor_shape_test[1], original_conv_weight_tensor_shape_test[2], original_conv_weight_tensor_shape_test[3]}; - Shape output_conv_weight_tensor_shape = { + tt::tt_metal::LegacyShape output_conv_weight_tensor_shape = { original_conv_weight_tensor_shape[0], original_conv_weight_tensor_shape[1] * num_groups, original_conv_weight_tensor_shape[2], @@ -402,12 +402,12 @@ Tensor convert_conv_weight_tensor_to_depthwise_layout( "Convolution weights should be in row major layout for repeating the required dimensions"); auto original_conv_weight_tensor_shape_test = conv_weight_tensor.get_shape(); uint32_t num_input_channels_to_repeat = act_block_h_ntiles * constants::TILE_HEIGHT; - Shape original_conv_weight_tensor_shape = { + tt::tt_metal::LegacyShape original_conv_weight_tensor_shape = { original_conv_weight_tensor_shape_test[0], original_conv_weight_tensor_shape_test[1], original_conv_weight_tensor_shape_test[2], original_conv_weight_tensor_shape_test[3]}; - Shape output_conv_weight_tensor_shape = { + tt::tt_metal::LegacyShape output_conv_weight_tensor_shape = { original_conv_weight_tensor_shape[0], num_input_channels_to_repeat, original_conv_weight_tensor_shape[2], @@ -455,7 +455,7 @@ Tensor convert_conv_weight_tensor_to_depthwise_layout( TT_THROW("Unsupported weight data type given when trying to add zero padding to weight tensor"); } -const Shape infer_dims_for_reshape(int N, int C, int H, int W, uint32_t old_volume) { +const tt::tt_metal::LegacyShape infer_dims_for_reshape(int N, int C, int H, int W, uint32_t old_volume) { vector ns{N, C, H, W}; int neg_idx = -1; for (int i = 0; i < ns.size(); i++) { @@ -581,7 +581,7 @@ Tensor create_multi_device_tensor( if (storage_type == StorageType::MULTI_DEVICE) { std::vector ordered_device_ids; - std::unordered_map shapes; + std::unordered_map shapes; std::unordered_map device_buffers; for (const auto& tensor : tensors) { TT_ASSERT(std::holds_alternative(tensor.get_storage()), "Unexpected type {}", tt::stl::get_active_type_name_in_variant(tensor.get_storage())); @@ -598,7 +598,7 @@ Tensor create_multi_device_tensor( tensors.at(0).get_layout()}; } else if (storage_type == StorageType::MULTI_DEVICE_HOST) { std::vector owned_buffers; - std::vector shapes; + std::vector shapes; for (const auto& tensor : tensors) { TT_ASSERT(std::holds_alternative(tensor.get_storage()), "Unexpected type {}", tt::stl::get_active_type_name_in_variant(tensor.get_storage())); owned_buffers.push_back(std::get(tensor.get_storage()).buffer); diff --git a/ttnn/cpp/ttnn/tensor/tensor_utils.hpp b/ttnn/cpp/ttnn/tensor/tensor_utils.hpp index 58eb2490792..234adbb4e98 100644 --- a/ttnn/cpp/ttnn/tensor/tensor_utils.hpp +++ b/ttnn/cpp/ttnn/tensor/tensor_utils.hpp @@ -33,9 +33,9 @@ Tensor convert_conv_weight_tensor_to_grouped_layout(Tensor conv_weight_tensor, u // Converts convolution weights to depthwise layout with broadcasted weights Tensor convert_conv_weight_tensor_to_depthwise_layout(Tensor conv_weight_tensor, uint32_t act_block_h_ntiles, DataType output_dtype); -const Shape infer_dims_for_reshape(int N, int C, int H, int W, uint32_t old_volume); +const tt::tt_metal::LegacyShape infer_dims_for_reshape(int N, int C, int H, int W, uint32_t old_volume); -const Shape infer_dims_for_reshape_RM(int N, int C, int H, int W, uint32_t old_volume); +const tt::tt_metal::LegacyShape infer_dims_for_reshape_RM(int N, int C, int H, int W, uint32_t old_volume); template static std::size_t compute_volume(const T& shape) { @@ -46,7 +46,7 @@ static std::size_t compute_volume(const T& shape) { return volume; } -static std::vector compute_strides(const Shape& shape) { +static std::vector compute_strides(const tt::tt_metal::LegacyShape& shape) { if (shape.rank() == 0) return {}; diff --git a/ttnn/cpp/ttnn/tensor/types.cpp b/ttnn/cpp/ttnn/tensor/types.cpp index e735cfc49a9..9cdd76b9417 100644 --- a/ttnn/cpp/ttnn/tensor/types.cpp +++ b/ttnn/cpp/ttnn/tensor/types.cpp @@ -104,51 +104,51 @@ bool operator==(const Padding& padding_a, const Padding& padding_b) { bool operator!=(const Padding& padding_a, const Padding& padding_b) { return not(padding_a == padding_b); } -Shape::Shape(const std::initializer_list dimensions) : +LegacyShape::LegacyShape(const std::initializer_list dimensions) : rank_(dimensions.size()), dimensions_{}, padding_(dimensions.size()) { std::copy(std::begin(dimensions), std::end(dimensions), std::begin(this->dimensions_)); } -Shape::Shape(const std::vector& dimensions) : +LegacyShape::LegacyShape(const std::vector& dimensions) : rank_(dimensions.size()), dimensions_{}, padding_(dimensions.size()) { std::copy(std::begin(dimensions), std::end(dimensions), std::begin(this->dimensions_)); } -Shape::Shape(const std::initializer_list dimensions, const Padding& padding) : +LegacyShape::LegacyShape(const std::initializer_list dimensions, const Padding& padding) : rank_(dimensions.size()), dimensions_{}, padding_(padding) { TT_ASSERT(this->padding_.rank_ == this->rank_); std::copy(std::begin(dimensions), std::end(dimensions), std::begin(this->dimensions_)); } -Shape::Shape(const std::vector& dimensions, const Padding& padding) : +LegacyShape::LegacyShape(const std::vector& dimensions, const Padding& padding) : rank_(dimensions.size()), dimensions_{}, padding_(padding) { TT_ASSERT(this->padding_.rank_ == this->rank_); std::copy(std::begin(dimensions), std::end(dimensions), std::begin(this->dimensions_)); } -Shape::Shape(const Shape& other, const Padding& padding) : +LegacyShape::LegacyShape(const LegacyShape& other, const Padding& padding) : dimensions_(other.dimensions_), rank_(other.rank_), padding_(padding) { TT_ASSERT(this->padding_.rank_ == this->rank_); } -std::size_t Shape::rank() const { return this->rank_; } -std::size_t Shape::size() const { return this->rank_; } +std::size_t LegacyShape::rank() const { return this->rank_; } +std::size_t LegacyShape::size() const { return this->rank_; } -uint32_t& Shape::operator[](const std::int64_t index) { +uint32_t& LegacyShape::operator[](const std::int64_t index) { auto normalized_index = this->get_normalized_index(index); return this->dimensions_[normalized_index]; } -const uint32_t Shape::operator[](const std::int64_t index) const { +const uint32_t LegacyShape::operator[](const std::int64_t index) const { auto normalized_index = this->get_normalized_index(index); return this->dimensions_[normalized_index]; } -const uint32_t* Shape::begin() const { return this->dimensions_.data(); } -const uint32_t* Shape::end() const { return this->dimensions_.data() + this->rank_; } +const uint32_t* LegacyShape::begin() const { return this->dimensions_.data(); } +const uint32_t* LegacyShape::end() const { return this->dimensions_.data() + this->rank_; } -const Padding& Shape::padding() const { +const Padding& LegacyShape::padding() const { return this->padding_; } -const Shape Shape::without_padding() const { +const LegacyShape LegacyShape::without_padding() const { auto padding = this->padding_; std::vector shape_without_padding; for (auto index = 0; index < this->rank(); index++) { @@ -157,10 +157,10 @@ const Shape Shape::without_padding() const { const auto new_dimension = dimension - (front_pad + back_pad); shape_without_padding.push_back(new_dimension); } - return Shape(shape_without_padding); + return LegacyShape(shape_without_padding); } -const uint32_t Shape::get_normalized_index(std::int64_t index) const { +const uint32_t LegacyShape::get_normalized_index(std::int64_t index) const { std::int64_t rank = static_cast(this->rank_); std::uint64_t normalized_index = index >= 0 ? index : rank + index; TT_FATAL( @@ -184,7 +184,7 @@ bool operator==(const ShardTensor2D& lhs, const ShardTensor2D& rhs) { return lhs.shard_mesh == rhs.shard_mesh; // Equal if they have the same shard_mesh. } -bool operator==(const Shape& shape_a, const Shape& shape_b) { +bool operator==(const tt::tt_metal::LegacyShape& shape_a, const tt::tt_metal::LegacyShape& shape_b) { if (shape_a.rank() != shape_b.rank()) { return false; } @@ -197,7 +197,7 @@ bool operator==(const Shape& shape_a, const Shape& shape_b) { return true; // Ignore the padding when comparing shapes } -bool operator!=(const Shape& shape_a, const Shape& shape_b) { return not(shape_a == shape_b); } +bool operator!=(const tt::tt_metal::LegacyShape& shape_a, const tt::tt_metal::LegacyShape& shape_b) { return not(shape_a == shape_b); } bool MemoryConfig::is_sharded() const { switch (this->memory_layout) { diff --git a/ttnn/cpp/ttnn/tensor/types.hpp b/ttnn/cpp/ttnn/tensor/types.hpp index f846a81d241..45544510e5a 100644 --- a/ttnn/cpp/ttnn/tensor/types.hpp +++ b/ttnn/cpp/ttnn/tensor/types.hpp @@ -162,40 +162,40 @@ typedef std::array Array6D; typedef std::array Array7D; typedef std::array Array8D; -class Shape { +class LegacyShape { std::size_t rank_; std::array dimensions_; Padding padding_; public: - Shape(const Shape &) = default; - Shape &operator=(const Shape &) = default; - Shape(Shape &&) = default; - Shape &operator=(Shape &&) = default; - ~Shape() = default; + LegacyShape(const LegacyShape &) = default; + LegacyShape &operator=(const LegacyShape &) = default; + LegacyShape(LegacyShape &&) = default; + LegacyShape &operator=(LegacyShape &&) = default; + ~LegacyShape() = default; - Shape(const std::initializer_list); - Shape(const std::vector &); - Shape(const std::initializer_list, const Padding &); - Shape(const std::vector &, const Padding &); + LegacyShape(const std::initializer_list); + LegacyShape(const std::vector &); + LegacyShape(const std::initializer_list, const Padding &); + LegacyShape(const std::vector &, const Padding &); - explicit Shape(const Shape &, const Padding &); + explicit LegacyShape(const LegacyShape &, const Padding &); template - Shape(const std::array &shape) : rank_(Rank), dimensions_{}, padding_{Rank} { + LegacyShape(const std::array &shape) : rank_(Rank), dimensions_{}, padding_{Rank} { for (auto index = 0; index < Rank; index++) { this->dimensions_[index] = shape[index]; } } - Shape(const Array4D &shape) : rank_(4), dimensions_{}, padding_{4} { + LegacyShape(const Array4D &shape) : rank_(4), dimensions_{}, padding_{4} { for (auto index = 0; index < 4; index++) { this->dimensions_[index] = shape[index]; } } template - explicit Shape(const std::array &shape, const std::array &shape_with_tile_padding) : + explicit LegacyShape(const std::array &shape, const std::array &shape_with_tile_padding) : rank_(Rank), dimensions_{}, padding_{Rank} { for (auto index = 0; index < Rank; index++) { auto padded_dimension = shape_with_tile_padding[index]; @@ -203,7 +203,7 @@ class Shape { this->padding_[index] = {.front = 0, .back = padded_dimension - shape[index]}; } } - explicit Shape(const std::vector &shape, const std::vector &shape_with_tile_padding) : + explicit LegacyShape(const std::vector &shape, const std::vector &shape_with_tile_padding) : rank_(shape.size()), dimensions_{}, padding_{shape.size()} { TT_ASSERT( shape.size() == shape_with_tile_padding.size(), @@ -225,7 +225,7 @@ class Shape { const uint32_t *end() const; const Padding &padding() const; - const Shape without_padding() const; + const LegacyShape without_padding() const; const uint32_t get_normalized_index(std::int64_t index) const; @@ -233,7 +233,7 @@ class Shape { const auto attribute_values() const { return std::forward_as_tuple(this->rank_, this->dimensions_, this->padding_); } - friend std::ostream &operator<<(std::ostream &os, const Shape &shape); + friend std::ostream &operator<<(std::ostream &os, const LegacyShape &shape); Array4D to_array_4D() const { Array4D ret_array; @@ -244,7 +244,7 @@ class Shape { } }; -inline std::ostream &operator<<(std::ostream &os, const Shape &shape) { +inline std::ostream &operator<<(std::ostream &os, const tt::tt_metal::LegacyShape &shape) { const auto shape_without_padding = shape.without_padding(); const auto &padding = shape.padding(); os << "Shape(["; @@ -261,8 +261,8 @@ inline std::ostream &operator<<(std::ostream &os, const Shape &shape) { return os; } -bool operator==(const Shape &, const Shape &); -bool operator!=(const Shape &, const Shape &); +bool operator==(const tt::tt_metal::LegacyShape &, const tt::tt_metal::LegacyShape &); +bool operator!=(const tt::tt_metal::LegacyShape &, const tt::tt_metal::LegacyShape &); struct MemoryConfig { TensorMemoryLayout memory_layout = TensorMemoryLayout::INTERLEAVED; // Interleave the data across multiple banks @@ -406,7 +406,7 @@ struct BorrowedStorage { struct MultiDeviceHostStorage { DistributedTensorConfig strategy; std::vector buffers; - std::vector shapes; + std::vector shapes; mutable std::mutex mtx; friend void swap(MultiDeviceHostStorage &first, MultiDeviceHostStorage &second) { @@ -421,7 +421,7 @@ struct MultiDeviceHostStorage { MultiDeviceHostStorage() = default; MultiDeviceHostStorage( - DistributedTensorConfig strategy_, std::vector buffers_, std::vector shapes_) : + DistributedTensorConfig strategy_, std::vector buffers_, std::vector shapes_) : strategy(strategy_), buffers(buffers_), shapes(shapes_) {} MultiDeviceHostStorage(MultiDeviceHostStorage &&other) { swap(*this, other); } // unfotunately we need to have this code written manually. @@ -452,7 +452,7 @@ struct MultiDeviceHostStorage { // Helper Functions - Getters and setters to get/modify storage attributes. These are needed to // preinitialize empty tensor handles and use/populate them in the worker threads. - void insert_buffer_and_shape_for_device(int buffer_index, const OwnedBuffer &buffer, const Shape shape) { + void insert_buffer_and_shape_for_device(int buffer_index, const OwnedBuffer &buffer, const LegacyShape shape) { std::lock_guard lock(mtx); buffers[buffer_index] = buffer; shapes[buffer_index] = shape; @@ -470,7 +470,7 @@ struct MultiDeviceHostStorage { return buffers[buffer_index]; } - Shape get_tensor_shape(int shape_index) const { + LegacyShape get_tensor_shape(int shape_index) const { std::lock_guard lock(mtx); TT_ASSERT(shape_index < shapes.size(), "Buffer not found for device {}", shape_index); return shapes[shape_index]; @@ -496,7 +496,7 @@ struct MultiDeviceStorage { DistributedTensorConfig strategy; std::vector ordered_device_ids; std::unordered_map buffers; - std::unordered_map shapes; + std::unordered_map shapes; mutable std::mutex buffer_mtx; mutable std::mutex shape_mtx; MultiDeviceStorage() = default; @@ -514,7 +514,7 @@ struct MultiDeviceStorage { DistributedTensorConfig strategy_, std::vector ordered_device_ids_, std::unordered_map buffers_, - std::unordered_map shapes_) : + std::unordered_map shapes_) : strategy(std::move(strategy_)), ordered_device_ids(std::move(ordered_device_ids_)), buffers(std::move(buffers_)), @@ -569,7 +569,7 @@ struct MultiDeviceStorage { // Helper Functions - Getters and setters to get/modify storage attributes. These are needed to // preinitialize empty tensor handles and use/populate them in the worker threads. - inline void insert_buffer_and_shape_for_device(Device *device, const DeviceBuffer buffer, const Shape shape) { + inline void insert_buffer_and_shape_for_device(Device *device, const DeviceBuffer buffer, const LegacyShape shape) { std::scoped_lock lock(buffer_mtx, shape_mtx); TT_ASSERT( device == buffer->device(), @@ -603,7 +603,7 @@ struct MultiDeviceStorage { return buffers.at(device_id); } - inline Shape get_tensor_shape_for_device(Device *device) const { + inline LegacyShape get_tensor_shape_for_device(Device *device) const { std::lock_guard lock(shape_mtx); TT_ASSERT( shapes.find(device->id()) != shapes.end(), "Shape not found for device {}", device->id()); @@ -652,48 +652,47 @@ namespace types { namespace detail { template -static tt::tt_metal::Shape compute_ttl_shape( +static tt::tt_metal::LegacyShape compute_ttl_shape( const std::array &shape, const std::array, Rank> &padding) { auto ttl_shape = std::array{}; for (auto index = 0; index < Rank; index++) { ttl_shape[index] = shape[index] + padding[index][0] + padding[index][1]; } - return tt::tt_metal::Shape{ - tt::tt_metal::Shape{ttl_shape}, tt::tt_metal::Padding{padding, tt::tt_metal::Padding::PadValue::Any}}; + return tt::tt_metal::LegacyShape{ttl_shape, tt::tt_metal::Padding{padding, tt::tt_metal::Padding::PadValue::Any}}; } } // namespace detail struct Shape { - // ttnn::Shape is a wrapper around tt::tt_metal::Shape + // ttnn::Shape is a wrapper around tt::tt_metal::LegacyShape // It is used to flip the default value of operator[] to return the shape without padding - tt::tt_metal::Shape value; + tt::tt_metal::LegacyShape value; - explicit Shape(const tt::tt_metal::Shape &shape) : value{shape} {} + explicit Shape(const tt::tt_metal::LegacyShape &shape) : value{shape} {} template explicit Shape(const std::array &shape) : value{shape} {} template explicit Shape(const std::array &shape, const std::array &shape_with_tile_padding) : - value{tt::tt_metal::Shape{shape, shape_with_tile_padding}} {} + value{tt::tt_metal::LegacyShape{shape, shape_with_tile_padding}} {} template explicit Shape( const std::array &shape, const std::array, Rank> &tile_padding) : value{detail::compute_ttl_shape(shape, tile_padding)} {} - explicit Shape(const std::vector &shape) : value{tt::tt_metal::Shape{shape}} {} + explicit Shape(const std::vector &shape) : value{tt::tt_metal::LegacyShape{shape}} {} explicit Shape(const std::vector &shape, const std::vector &shape_with_tile_padding) : - value{tt::tt_metal::Shape{shape, shape_with_tile_padding}} {} + value{tt::tt_metal::LegacyShape{shape, shape_with_tile_padding}} {} const auto rank() const { return this->value.rank(); } const auto size() const { return this->rank(); } Shape with_tile_padding() const { - return Shape{tt::tt_metal::Shape{this->value, tt::tt_metal::Padding{this->value.rank()}}}; + return Shape{tt::tt_metal::LegacyShape{this->value, tt::tt_metal::Padding{this->value.rank()}}}; } bool has_tile_padding() const { @@ -713,7 +712,7 @@ struct Shape { bool operator==(const Shape &other) const { const auto &shape_a = this->value; const auto &shape_b = other.value; - // tt::tt_metal::Shape comparison doesn't take padding into account + // tt::tt_metal::LegacyShape comparison doesn't take padding into account return (shape_a == shape_b and shape_a.without_padding() == shape_b.without_padding()); }