Skip to content

Commit

Permalink
Add C++ multi-device tensor creation test, fix Python test
Browse files Browse the repository at this point in the history
  • Loading branch information
omilyutin-tt committed Nov 19, 2024
1 parent ba41a0b commit 7f564aa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/ttnn/unit_tests/gtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(TTNN_TENSOR_UNIT_TESTS_SRC
${CMAKE_CURRENT_SOURCE_DIR}/tensor/common_tensor_test_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tensor/test_create_tensor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tensor/test_tensor_layout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tensor/test_create_tensor_multi_device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tensor/test_create_tensor_with_layout.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tensor/test_shape_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tensor/test_sharding_with_alignment.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
//
// SPDX-License-Identifier: Apache-2.0

#include <variant>

#include "buffers/buffer_constants.hpp"
#include "gtest/gtest.h"
#include "ttnn/cpp/ttnn/operations/creation.hpp"
#include "ttnn/cpp/ttnn/tensor/types.hpp"
#include "ttnn/distributed/api.hpp"
#include "ttnn/tensor/enum_types.hpp"
#include "ttnn_test_fixtures.hpp"

namespace ttnn::distributed::test {
namespace {

using ::tt::tt_metal::BufferType;
using ::tt::tt_metal::Layout;
using ::tt::tt_metal::MemoryConfig;
using ::tt::tt_metal::StorageType;
using ::tt::tt_metal::TensorMemoryLayout;

TEST_F(T3kMultiDeviceFixture, CreateEmpty) {
MeshDevice* mesh_device = this->mesh_device_.get();

const auto mesh_replicated_tensor = ttnn::empty(
ttnn::Shape(std::array<uint32_t, 2>{32, 32}),
DataType::BFLOAT16,
Layout::ROW_MAJOR,
mesh_device,
MemoryConfig{TensorMemoryLayout::INTERLEAVED, BufferType::DRAM, std::nullopt});

EXPECT_EQ(mesh_replicated_tensor.storage_type(), StorageType::MULTI_DEVICE);
EXPECT_EQ(mesh_replicated_tensor.get_workers().size(), mesh_device->num_devices());

const auto distributed_tensor_config = get_distributed_tensor_config_from_tensor(mesh_replicated_tensor);

EXPECT_TRUE(std::holds_alternative<ReplicateTensor>(distributed_tensor_config));
}

} // namespace
} // namespace ttnn::distributed::test
2 changes: 2 additions & 0 deletions tests/ttnn/unit_tests/operations/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ def test_arange(device, start, end, step):
[1, 1, 32, 32],
[1, 1, 320, 384],
[1, 3, 320, 384],
[1, 3, 180, 64],
[2, 640, 64, 64],
[2, 1280, 64, 64],
],
Expand All @@ -368,6 +369,7 @@ def test_empty(device, input_shapes):
[1, 1, 32, 32],
[1, 1, 320, 384],
[1, 3, 320, 384],
[1, 3, 180, 64],
[2, 640, 64, 64],
[2, 1280, 64, 64],
],
Expand Down

0 comments on commit 7f564aa

Please sign in to comment.