Skip to content

Implement missing XLASymNodeImpl::Sub - #4551

Merged
vanbasten23 merged 9 commits into
masterfrom
XLASymNodeImplSub
Feb 2, 2023
Merged

vanbasten23 merged 9 commits into
masterfrom
XLASymNodeImplSub

Conversation

@vanbasten23

Copy link
Copy Markdown
Collaborator

This is to unblock the failing dynamic shape tests when functionalization is enabled.

@alanwaketan alanwaketan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM.

Comment thread torch_xla/csrc/tensor.cpp Resolved
@vanbasten23
vanbasten23 marked this pull request as ready for review February 1, 2023 23:35
Comment thread torch_xla/csrc/ops/dynamic_ir.cpp Outdated

SizeSub::SizeSub(torch::lazy::Value a, torch::lazy::Value b)
: XlaNode(torch::lazy::OpKind{c10::Symbol::fromQualString(
"aten::sub")}, // TODO: should it be something like

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I feel the OpKind here can be more specific such as "aten::size_sub", as opposed to the general ones such as "aten::sub". wdyt? @miladm @JackCaoG @alanwaketan

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

c10::Symbol is something defined in upstream. If you can find the corresponding enum in upstream, I guess it's better. Yea, we don't store "aten::sub" as a string. It's an enum.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I guess the enums are defined in pytorch/aten/src/ATen/core/interned_strings.h? size_sub is not one of the enums but I could still compile locally and run the test.


SizeSub::SizeSub(torch::lazy::Value a, torch::lazy::Value b)
: XlaNode(
torch::lazy::OpKind{c10::Symbol::fromQualString("aten::size_sub")},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Well, I am ok with either way as long as it runs, but if you want to update this for SizeSub, you need to update this for all nodes including SizeAdd above.

@alanwaketan alanwaketan Feb 2, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From the code, it looks like c10::Symbol would just assign any unseen string an incremental ID. I guess the problem I'm having is that there is no straightforward way you can do a comparison later on. For any aten ops, you can simply do:

op == at::aten::sub

For any custom op, I guess you have to do:

op == c10::Symbol::fromQualString("aten::size_sub")

Unless you could define an enum like structure in our end. So what benefits do you think we get from aten::size_sub?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It seems semantically cleaner to me: at::aten::sub feels like we are doing subtraction between 2 tensors, but here it's between 2 shape dimension (eg tensor.shape[0]). wdyt?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From the code perspective, yes. But I wonder if this helps anything practical for instance, LazyIR dump or HLO dump.

@vanbasten23
vanbasten23 merged commit 0830b58 into master Feb 2, 2023
mateuszlewko pushed a commit that referenced this pull request Mar 15, 2023
* implementing xlasymnodeimpl::sub

* the code buillds fine and the test passed.

* fix lnter

* change opkind to be more specific

* check counter in the test.

* fix linter

* unify the op kind

* fix linter

* fix a failing test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants