-
Notifications
You must be signed in to change notification settings - Fork 97
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
Replacing get_shape() #16786
base: main
Are you sure you want to change the base?
Replacing get_shape() #16786
Conversation
ttnn/cpp/ttnn/operations/moreh/moreh_cumsum/device/moreh_cumsum_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_cumsum/device/moreh_cumsum_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_cumsum/device/moreh_cumsum_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_dot_backward/device/moreh_dot_backward_program_factory.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_dot_backward/device/moreh_dot_backward_program_factory.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp
Outdated
Show resolved
Hide resolved
ttnn/cpp/ttnn/operations/moreh/moreh_getitem/device/moreh_getitem_device_operation.cpp
Outdated
Show resolved
Hide resolved
for (int i = 0; i < input_shape.rank(); ++i) { | ||
TT_FATAL( | ||
input_shape[i] == output_shape[i], | ||
"Input shape must match output shape. Received input_shape = {} and output_shape = {}.", | ||
input_shape[i], | ||
output_shape[i]); | ||
TT_FATAL( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@razorback3 can someone from the team please check?
// Unnecessary? -> | ||
//const auto input_shape_wo_padding = input.get_logical_shape(); | ||
//const auto output_shape_wo_padding = input.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My recommendation is to remove things you believe are not needed, instead of commenting them
You can then ping related parties in the PR to clarify with them.
uint32_t index_size = index.get_logical_shape()[-1]; | ||
uint32_t index_size_without_padding = index.get_logical_shape()[-1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@razorback3 , both values are without a padding here. I think someone from Moreh team will have to take a look
} | ||
|
||
uint32_t index_size = index_tensors.front().get_shape().value[-1]; | ||
const uint32_t& index_size = index_tensors.front().get_logical_shape()[-1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_shape().value is returns a LegacyShape. its operator[] will give padded value.
So the proper replacement here is get_padded_shape()
const auto& input_shape = input.get_padded_shape(); | ||
const auto& input_shape_without_padding = input.get_logical_shape() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@razorback3 , another place where there seem to be an issue. get_shape and input_shape.value.without_padding() are basically returning the same thing. One can probably be removed.
auto input_shape_without_padding = input_shape.value.without_padding(); | ||
auto output_shape = output.get_shape(); | ||
auto output_shape_without_padding = output_shape.value.without_padding(); | ||
const auto& input_shape = input.get_padded_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbedichekTT input_shape
variable here seem to have had a semantics of get_logical_shape()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto input_shape = input.get_shape();
@@ -31,34 +31,37 @@ void MorehGroupNormOperation::validate_tensors( | |||
check_tensor(beta, "moreh_group_norm", "beta"); | |||
|
|||
// input (N, C, H, W) | |||
auto C = input.get_shape().value[1]; | |||
auto C = input.get_logical_shape()[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_padded_shape()
TT_FATAL(C % num_groups == 0, "input_shape[1] must be divisible by num_groups."); | ||
// output (N, C, H, W) | ||
if (output.has_value()) { | ||
C = output.value().get_shape().value[1]; | ||
C = output.value().get_logical_shape()[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_padded_shape()
TT_FATAL(C % num_groups == 0, "beta_shape[-1] must be divisible by num_groups."); | ||
} | ||
|
||
// mean (1, 1, N, num_groups) | ||
if (mean.has_value()) { | ||
TT_FATAL( | ||
mean.value().get_shape().value.without_padding()[-1] == num_groups, | ||
//"mean_shape[-1] must match num_groups."); | ||
mean.value().get_logical_shape()[-1] == num_groups, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mean->get_logical_shape()[-1]
TT_FATAL(C % num_groups == 0, "beta_shape[-1] must be divisible by num_groups."); | ||
} | ||
|
||
// mean (1, 1, N, num_groups) | ||
if (mean.has_value()) { | ||
TT_FATAL( | ||
mean.value().get_shape().value.without_padding()[-1] == num_groups, | ||
//"mean_shape[-1] must match num_groups."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
TT_FATAL(C % num_groups == 0, "input_shape[1] must be divisible by num_groups."); | ||
// input_grad (N, C, H, W) | ||
if (input_grad.has_value()) { | ||
C = input_grad.value().get_shape().value[1]; | ||
C = input_grad.value().get_logical_shape()[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_padded_value
const auto& input_shape = input.get_padded_shape(); | ||
const auto& input_shape_without_padding = input.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is flipped. I recommend to rename/refactor variable names.
input_shape --> input_shape_padded
input_shape_without_padding --> input_shape
const auto& mean_rstd_shape = mean.get_padded_shape(); | ||
const auto mean_rstd_shape_without_padding = mean.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name mismatch
const auto mean_rstd_shape = mean.get_shape().value; | ||
const auto mean_rstd_shape_without_padding = mean_rstd_shape.without_padding(); | ||
|
||
const auto& mean_rstd_shape_without_padding = mean.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name mismatch
const auto& input_wo_shape = input.get_logical_shape(); | ||
const auto& other_wo_shape = other.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should just be input_shape and other_shape
const auto& input_shape = tensor_args.input.get_padded_shape(); | ||
const auto& other_shape = tensor_args.other.get_padded_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be input_shape_padded and other_shape_padded
const auto& input_shape_wo_padding = tensor_args.input.get_logical_shape(); | ||
const auto& other_shape_wo_padding = tensor_args.other.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto& input_shape_wo_padding = tensor_args.input.get_logical_shape(); | |
const auto& other_shape_wo_padding = tensor_args.other.get_logical_shape(); | |
const auto& input_shape = tensor_args.input.get_logical_shape(); | |
const auto& other_shape = tensor_args.other.get_logical_shape(); |
const auto& a_shape = tensor_a.get_logical_shape(); | ||
const auto& b_shape = tensor_b.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_padded_shape()
const auto& input_shape = input.get_padded_shape(); | ||
const auto& input_shape_wo_padding = input.get_logical_shape(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name mismatch
auto rank = shape.rank(); | ||
// Replace? -> | ||
auto padding = shape.value.padding(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this likely does not compile.
Please revert this change. Someone will later make a pass here.
CC @sminakov-tt
const auto& input_grad_shape = input_grad.get_shape(); | ||
const auto& input_grad_shape_wo_padding = input_grad_shape.value.without_padding(); | ||
const auto& input_grad_shape = input_grad.get_logical_shape(); | ||
//const auto& input_grad_shape_wo_padding = input_grad_shape.value.without_padding(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this file changed?
Ticket
None
Problem description
Replacing the legacy Tensor::get_shape() with new Tensor::get_padded_shape and Tensor::get_logical_shape from Moreh folder.
What's changed
Checklist