-
Notifications
You must be signed in to change notification settings - Fork 559
Refactor cpp tests #804
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
Refactor cpp tests #804
Conversation
| EXPECT_TRUE(CloseValues(tensor, xla_tensor.ToTensor(), rtol, atol)); | ||
| } | ||
|
|
||
| void ForEachDevice(const std::function<void(const Device&)>& devfn); |
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.
Do we still need this method? I'd try to remove it.
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.
Please don't, test_tensor.cpp still uses it.
|
@ailzhang Please, the next time send the document first, let's discuss it, and the you do the code ;) |
| EXPECT_TRUE(CloseValues(tensor, xla_tensor.ToTensor(), rtol, atol)); | ||
| } | ||
|
|
||
| void ForEachDevice(const std::function<void(const Device&)>& devfn); |
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.
Please don't, test_tensor.cpp still uses it.
test/cpp/cpp_test_util.h
Outdated
|
|
||
| void ForEachDevice(const std::function<void(const Device&)>& devfn); | ||
|
|
||
| void ForEachTorchXLADevice(const std::function<void(const torch::Device&)>& devfn); |
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.
No need to have different name, ForEachDevice() should be fine.
|
FYI I've run this PR manually against the bert model and it stabilizes at 3 graphs. |
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.
Approval on the basis CPU and TPU tests are green with this.
at::withtorch::APIs in test_aten_xla_tensor.cpp, basically this file shouldn’t touch anyat::andtorch_xla::/bridgeinternals, instead onlytorch::APIs are allowed there. Other files are used to test internals specifically, soat::/torch_xla/bridgeare fine there.torch_xla::ToTensor(at::Tensor)which was used to extract Tensor out of a Variable. Upstream was fixed by Use at::AutoNonVariableTypeMode before calling ATen tensor factory functions pytorch#22364 so that we make sure all tensors passed to xla has tensor.is_variable()=false. We can safely remove this hack now.Note that this PR is not clang-formatted yet, we need to find a open-source based clang-format config :P (otherwise it's not convenient to ask every OSS contributor to have clang-format-9 installed from source).
Detailed context: https://docs.google.com/document/d/1nkiPPhcQy6RpBQ13Y-HGkuefnY-B-3kgFveQ0h85Jjo/edit#