Skip to content

Commit

Permalink
#0: minor renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
kpaigwar committed Dec 10, 2024
1 parent c4ac298 commit e395f08
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@


@pytest.mark.parametrize(
"start_core, num_cores, subcoregrids, row_wise, expected_core_range_set",
"start_core, num_cores, sub_core_grids, row_wise, expected_core_range_set",
[
# Test Case 1: Basic row-wise scenario with enough cores in subcoregrids
# Test Case 1: Basic row-wise scenario with enough cores in sub_core_grids
(
ttnn.CoreCoord(1, 0),
32,
Expand Down Expand Up @@ -84,8 +84,10 @@
),
],
)
def test_numcores_to_corerangeset(start_core, num_cores, subcoregrids, row_wise, expected_core_range_set):
def test_numcores_to_corerangeset_in_subcoregrids(
start_core, num_cores, sub_core_grids, row_wise, expected_core_range_set
):
output_corerangeset = ttnn.num_cores_to_corerangeset_in_subcoregrids(
start_core, num_cores, subcoregrids, row_wise=row_wise
start_core, num_cores, sub_core_grids, row_wise=row_wise
)
assert output_corerangeset.to_json() == expected_core_range_set.to_json()
10 changes: 5 additions & 5 deletions tt_metal/common/work_split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,18 @@ CoreRangeSet num_cores_to_corerangeset(
CoreRangeSet num_cores_to_corerangeset_in_subcoregrids(
const CoreCoord start_core,
const uint32_t target_num_cores,
const CoreRangeSet subcoregrids,
const CoreRangeSet& sub_core_grids,
const bool row_wise = false) {
// If target_num_cores is 0 or input_corerangeset is empty, return empty CoreRangeSet
TT_FATAL(target_num_cores > 0, "Target number of cores must be greater than 0");
TT_FATAL(
target_num_cores <= subcoregrids.num_cores(),
target_num_cores <= sub_core_grids.num_cores(),
"Target number of cores {} is greater than total number of available cores {}",
target_num_cores,
subcoregrids.num_cores());
sub_core_grids.num_cores());

// Validate that the start core is contained within the entire CoreRangeSet
TT_FATAL(subcoregrids.contains(start_core), "Start core must be contained within the input CoreRangeSet");
TT_FATAL(sub_core_grids.contains(start_core), "Start core must be contained within the input CoreRangeSet");

std::vector<CoreRange> result_coreranges;
bool start_core_found = false;
Expand Down Expand Up @@ -241,7 +241,7 @@ CoreRangeSet num_cores_to_corerangeset_in_subcoregrids(
};

// Iterate over subcoregrids and process based on row_wise
for (const auto& subcoregrid : subcoregrids.ranges()) {
for (const auto& subcoregrid : sub_core_grids.ranges()) {
if (subcoregrid.contains(start_core)) {
start_core_found = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion tt_metal/common/work_split.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CoreRangeSet num_cores_to_corerangeset(
CoreRangeSet num_cores_to_corerangeset_in_subcoregrids(
const CoreCoord start_core,
const uint32_t target_num_cores,
const CoreRangeSet subcoregrids,
const CoreRangeSet& sub_core_grids,
const bool row_wise = false);
// This function takes in the core grid size, as well as the number of units of work to divide between the cores
// This function returns the number of cores, the CoreRangeSet of all cores, and then the CoreRangeSet that does
Expand Down
2 changes: 1 addition & 1 deletion ttnn/cpp/pybind11/operations/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void py_module(py::module& module) {

module.def(
"num_cores_to_corerangeset_in_subcoregrids",
py::overload_cast<const CoreCoord, const uint32_t, const CoreRangeSet, const bool>(
py::overload_cast<const CoreCoord, const uint32_t, const CoreRangeSet&, const bool>(
&tt::tt_metal::num_cores_to_corerangeset_in_subcoregrids),
R"doc(Create a CoreRangeSet containing the specified number of cores starting from start_core in given subcoregrids)doc");
}
Expand Down
4 changes: 2 additions & 2 deletions ttnn/ttnn/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def num_cores_to_corerangeset(
def num_cores_to_corerangeset_in_subcoregrids(
start_core: ttnn.CoreCoord,
target_num_cores: int,
subcoregrids: ttnn.CoreRangeSet,
sub_core_grids: ttnn.CoreRangeSet,
row_wise: bool = False,
):
"""
Expand All @@ -71,7 +71,7 @@ def num_cores_to_corerangeset_in_subcoregrids(
return ttnn._ttnn.operations.core.num_cores_to_corerangeset_in_subcoregrids(
start_core,
target_num_cores,
subcoregrids,
sub_core_grids,
row_wise,
)

Expand Down

0 comments on commit e395f08

Please sign in to comment.