mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Make Variable.is_sparse an attribute (#4308)
This matches Tensor.is_sparse, which makes it easier to replace Tensor with Variable.
This commit is contained in:
@ -437,6 +437,14 @@ PyObject *THPVariable_is_cuda(THPVariable *self)
|
||||
END_HANDLE_TH_ERRORS
|
||||
}
|
||||
|
||||
PyObject *THPVariable_is_sparse(THPVariable *self)
|
||||
{
|
||||
HANDLE_TH_ERRORS
|
||||
auto& self_ = self->cdata;
|
||||
return torch::autograd::utils::wrap(self_.is_sparse());
|
||||
END_HANDLE_TH_ERRORS
|
||||
}
|
||||
|
||||
static struct PyGetSetDef THPVariable_properties[] = {
|
||||
{"_cdata", (getter)THPVariable_get_cdata, NULL, NULL, NULL},
|
||||
{"_version", (getter)THPVariable_get_version, NULL, NULL, NULL},
|
||||
@ -454,6 +462,7 @@ static struct PyGetSetDef THPVariable_properties[] = {
|
||||
{"name", (getter)THPVariable_get_name, NULL, NULL, NULL},
|
||||
{"shape", (getter)THPVariable_get_shape, NULL, NULL, NULL},
|
||||
{"is_cuda", (getter)THPVariable_is_cuda, NULL, NULL, NULL},
|
||||
{"is_sparse", (getter)THPVariable_is_sparse, NULL, NULL, NULL},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user