Enable numel tracing

clang-format

resolve onnx test failure

update expect file

Pull Request resolved: https://github.com/pytorch/pytorch/pull/74081

Approved by: https://github.com/garymm, https://github.com/eellison, https://github.com/malfet
This commit is contained in:
BowenBao
2022-04-07 11:06:33 -07:00
committed by PyTorch MergeBot
parent db20a3b014
commit aa51ee2345
6 changed files with 161 additions and 19 deletions

View File

@ -231,7 +231,11 @@ static PyObject * THPVariable_numel(PyObject* self, PyObject* args)
return handle_torch_function(self, "numel", args);
}
auto& self_ = THPVariable_Unpack(self);
return THPUtils_packInt64(self_.numel());
if (jit::tracer::isTracing()) {
return wrap(jit::tracer::getNumelOf(self_));
} else {
return THPUtils_packInt64(self_.numel());
}
END_HANDLE_TH_ERRORS
}