Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#0: added api for generating corerangeset from given subcoregrid #15841

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

kpaigwar
Copy link
Contributor

@kpaigwar kpaigwar commented Dec 9, 2024

Problem description

To address the need for generating a CoreRangeSet from non-rectangular subcoregrids (e.g., grids of sizes [3x10, 2x10]), I added a new API ttnn.numcores_to_corerangeset_in_subcoregrids that can handle multiple disjoint or irregular core regions, unlike the existing ttnn.numcores_to_corerangeset function, which assumes a single rectangular core grid.

Input Parameters
start_core: The starting coordinate (CoreCoord) for selecting cores.
target_num_cores: The desired number of cores to include in the resulting CoreRangeSet.
subcoregrids: A CoreRangeSet representing disjoint or irregular sub-core grids within which cores can be selected.
row_wise: A boolean indicating whether to prioritize selecting cores row by row (True) or column by column (False).
Output
A CoreRangeSet that contains a compact selection of cores starting from start_core and spanning up to target_num_cores cores within the given subcoregrids.

Checklist

  • Post commit CI passes
  • New/Existing tests provide coverage for changes

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

CoreRangeSet num_cores_to_corerangeset_in_subcoregrids(
const CoreCoord start_core,
const uint32_t target_num_cores,
const CoreRangeSet subcoregrids,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ performance-unnecessary-value-param ⚠️
the const qualified parameter subcoregrids is copied for each invocation; consider making it a reference

Suggested change
const CoreRangeSet subcoregrids,
const CoreRangeSet& subcoregrids,

uint32_t subcoregrid_height = subcoregrid.grid_size().y;

if (row_wise) {
for (uint32_t y = current_start_core.y; y <= subcoregrid.end_coord.y; ++y) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you split this function into two subfunctions? row_wise and col_wise. this for loop is very large.
YOu simple can create two lambdas at least and call on of them in the cycle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmakoviichuk-tt converted them to lambdas now.

Copy link
Contributor

@dmakoviichuk-tt dmakoviichuk-tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one comment.

@kpaigwar kpaigwar force-pushed the kpaigwar/numcores_in_subcoregrids branch from 48716a0 to c4ac298 Compare December 9, 2024 20:52
CoreRangeSet num_cores_to_corerangeset_in_subcoregrids(
const CoreCoord start_core,
const uint32_t target_num_cores,
const CoreRangeSet subcoregrids,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Can we name as sub_core_grids to make it similar to naming of other args? Should also be const ref

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 1 to 2
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. Can you rename the file to match the function name. ex num_cores instead of numcores

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@kpaigwar kpaigwar force-pushed the kpaigwar/numcores_in_subcoregrids branch from e395f08 to ea9f9cb Compare December 10, 2024 02:06
@kpaigwar kpaigwar merged commit c2d7b09 into main Dec 10, 2024
9 checks passed
@kpaigwar kpaigwar deleted the kpaigwar/numcores_in_subcoregrids branch December 10, 2024 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants