Skip to content

Conversation

@miladm
Copy link
Collaborator

@miladm miladm commented Jun 17, 2021

The PR draft for std_mean.
The PR is to be tested.

Issue link

@miladm miladm requested a review from JackCaoG June 17, 2021 16:58
@miladm miladm added the lowering ATen Operation lowering label Jun 18, 2021
@miladm miladm self-assigned this Jun 18, 2021
Copy link
Collaborator

@JackCaoG JackCaoG left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, minor nits. Please fix the format too.

Comment on lines 14 to 25
xla::XlaOp LowerStd(xla::XlaOp input,
const std::vector<xla::int64>& dimensions,
bool keep_reduced_dimensions,
xla::int64 correction) {
return BuildStdDeviation(input, dimensions, keep_reduced_dimensions, correction);
}

xla::XlaOp LowerMean(xla::XlaOp input,
const std::vector<xla::int64>& dimensions,
bool keep_reduced_dimensions) {
return BuildMean(input, dimensions, keep_reduced_dimensions);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't really need these two helper function if they are just forwarding argument to BuildStdDeviation and BuildMean. You only replace the use of these two function with Buildxxx directly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed

bool keep_reduced_dimensions,
xla::int64 correction) {
auto lower_for_shape_fn_std_mean = [&](absl::Span<const xla::XlaOp> operands) -> xla::XlaOp {
auto std = LowerStd(operands[0], dimensions, keep_reduced_dimensions, correction);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's try not to use auto when we can 😄 , I think in general we only use it when the type name is super long and complicated. In this case we can just use xla::XlaOp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

xla::int64 correction) {
auto lower_for_shape_fn_std_mean = [&](absl::Span<const xla::XlaOp> operands) -> xla::XlaOp {
auto std = LowerStd(operands[0], dimensions, keep_reduced_dimensions, correction);
auto mean = LowerMean(operands[0], dimensions, keep_reduced_dimensions);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@miladm miladm requested a review from JackCaoG June 28, 2021 16:38
Copy link
Collaborator

@JackCaoG JackCaoG left a comment

Choose a reason for hiding this comment

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

Thanks @miladm, minor nits. You can merge it once you fix the comment and verify all test passed.

Comment on lines +1313 to +1314
ExpectCounterNotChanged("aten::.*", cpp_test::GetIgnoredCounters());
ExpectCounterChanged("xla::std_mean", cpp_test::GetIgnoredCounters());
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT, move this two check our of the for loop. We only need to check once at the end of the test, instead of for every execution.

@miladm miladm merged commit 7416878 into master Jun 28, 2021
@miladm miladm deleted the std_mean branch June 28, 2021 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lowering ATen Operation lowering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants