Remove methods that start with an underscore from at::Tensor (#11152)

Summary:
This PR cleans up the `at::Tensor` class by removing all methods that start with an underscore in favor of functions in the `at::` namespace. This greatly cleans up the `Tensor` class and makes it clearer what is the public and non-public API.

For this I changed `native_functions.yaml` and `Declarations.cwrap` to make all underscore methods `variant: function` (or add such a statement to begin with), and then fixed all code locations using the underscore methods.

ezyang colesbury gchanan
Pull Request resolved: https://github.com/pytorch/pytorch/pull/11152

Differential Revision: D9683607

Pulled By: goldsborough

fbshipit-source-id: 97f869f788fa56639c05a439e2a33be49f10f543
This commit is contained in:
Peter Goldsborough
2018-09-07 11:41:38 -07:00
committed by Facebook Github Bot
parent e80f7e1f64
commit fb4e8088f3
36 changed files with 190 additions and 259 deletions
+2 -2
View File
@@ -10,12 +10,12 @@
template <typename T>
bool exactly_equal(at::Tensor left, T right) {
return left._local_scalar().to<T>() == right;
return at::_local_scalar(left).to<T>() == right;
}
template <typename T>
bool almost_equal(at::Tensor left, T right, T tolerance = 1e-4) {
return std::abs(left._local_scalar().to<T>() - right) < tolerance;
return std::abs(at::_local_scalar(left).to<T>() - right) < tolerance;
}
#define REQUIRE_TENSOR_OPTIONS(device_, index_, type_, layout_) \