Directly access has_symbolic_sizes_strides, avoid expensive test (#85754)

Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85754
Approved by: https://github.com/albanD
This commit is contained in:
Edward Z. Yang
2022-09-27 15:11:20 -07:00
committed by PyTorch MergeBot
parent 8c7c7ed322
commit 24a268143d
4 changed files with 18 additions and 12 deletions

View File

@ -1458,6 +1458,16 @@ PyObject* THPVariable_is_nested(THPVariable* self, void* unused) {
END_HANDLE_TH_ERRORS
}
PyObject* THPVariable_has_symbolic_sizes_strides(
THPVariable* self,
void* unused) {
HANDLE_TH_ERRORS
auto& self_ = THPVariable_Unpack(self);
return torch::autograd::utils::wrap(
self_.unsafeGetTensorImpl()->has_symbolic_sizes_strides());
END_HANDLE_TH_ERRORS
}
static PyObject* THPVariable_dtype(THPVariable* self, void* unused) {
HANDLE_TH_ERRORS
if (check_has_torch_function((PyObject*)self)) {
@ -1596,6 +1606,11 @@ static struct PyGetSetDef THPVariable_properties[] = {
nullptr},
{"is_meta", (getter)THPVariable_is_meta, nullptr, nullptr, nullptr},
{"is_nested", (getter)THPVariable_is_nested, nullptr, nullptr, nullptr},
{"_has_symbolic_sizes_strides",
(getter)THPVariable_has_symbolic_sizes_strides,
nullptr,
nullptr,
nullptr},
{"dtype", (getter)THPVariable_dtype, nullptr, nullptr, nullptr},
{"layout", (getter)THPVariable_layout, nullptr, nullptr, nullptr},
{"device", (getter)THPVariable_device, nullptr, nullptr, nullptr},