Accept more numpy scalars as doubles (#9659)

Summary:
Allows mulitplication of e.g. numpy.float32 with tensors.

This came up with #9468

If you want this and after the other patch is done, I'll add tests (but that would be conflicting, so I prefer to wait).
Pull Request resolved: https://github.com/pytorch/pytorch/pull/9659

Differential Revision: D8948078

Pulled By: weiyangfb

fbshipit-source-id: c7dcc57b63e2f100df837f70e1299395692f1a1b
This commit is contained in:
Thomas Viehmann
2018-09-05 10:17:08 -07:00
committed by Facebook Github Bot
parent 8bd80a6b74
commit 267e1ec112
5 changed files with 32 additions and 14 deletions

View File

@ -104,9 +104,6 @@ bool FunctionParameter::check(PyObject* obj) {
}
case ParameterType::SCALAR:
case ParameterType::DOUBLE: {
// NOTE: we don't currently accept most NumPy types as Scalars. np.float64
// is okay because it's a subclass of PyFloat. We may want to change this
// in the future.
if (THPUtils_checkDouble(obj)) {
return true;
}