Revert "Re-land sym_numel (#82374) (#82726) (#82731)"

This reverts commit c90e00cf85a4ac11e6fd96963e5e95944aefc5b4.

Reverted https://github.com/pytorch/pytorch/pull/82731 on behalf of https://github.com/zengk95 due to This is breaking XLA  tests on trunk. It seems to have passed on PR and was able to checkout that commit c90e00cf85.
This commit is contained in:
PyTorch MergeBot
2022-08-04 22:45:26 +00:00
parent ae399d009f
commit 78bd95b13a
16 changed files with 51 additions and 161 deletions

View File

@ -263,10 +263,6 @@ c10::Layout concrete_layout_fn(
const c10::impl::PyInterpreter*,
const c10::TensorImpl* self);
c10::SymInt concrete_sym_numel_fn(
const c10::impl::PyInterpreter*,
const c10::TensorImpl* self);
class PyInterpreterHolder {
public:
PyInterpreterHolder()
@ -281,8 +277,7 @@ class PyInterpreterHolder {
&concrete_strides_fn,
&concrete_sizes_fn,
&concrete_sym_sizes_fn,
&concrete_layout_fn,
&concrete_sym_numel_fn)) {}
&concrete_layout_fn)) {}
// NB: intentionally leaks the memory
~PyInterpreterHolder() {
impl_->disarm();
@ -2466,31 +2461,4 @@ c10::Layout concrete_layout_fn(
return toLayout(out.ptr());
}
c10::SymInt concrete_sym_numel_fn(
const c10::impl::PyInterpreter*,
const c10::TensorImpl* self) {
pybind11::gil_scoped_acquire gil;
at::impl::MaybeSetTLSOnEntryGuard guard;
auto out = torchDispatchFromTensorImpl(
self,
"sym_numel",
py::module::import("torch")
.attr("ops")
.attr("aten")
.attr("sym_numel")
.attr("default")
.ptr(),
"torch.ops.aten");
if (out == Py_None) {
TORCH_CHECK(
!self->has_symbolic_sizes_strides(),
"Cannot call numel on a tensor with symbolic shapes/strides");
return self->sym_numel_default();
}
return torch::is_symint_node(out)
? out.cast<c10::SymIntNodeImpl*>()->toSymInt()
: c10::SymInt{py::cast<int64_t>(out)};
}
} // anonymous namespace