def fn(x):
print(torch.isfinite(x))
s = torch.jit.script(fn)
fn(torch.randn(2, 2))
s(torch.randn(2, 2))
results in
tensor([[True, True],
[True, True]])
graph(%x.1 : Tensor):
%4 : None = prim::Constant() # ../test.py:14:0
%2 : float = prim::ImplicitTensorToNum(%x.1) # ../test.py:15:10
%3 : bool = aten::isfinite(%2) # ../test.py:15:10
= prim::Print(%3) # ../test.py:15:4
return (%4)
Traceback (most recent call last):
File "../test.py", line 21, in <module>
s(torch.randn(2, 2))
RuntimeError: Cannot input a tensor of dimension other than 0 as a scalar argument
The above operation failed in interpreter, with the following stack trace:
at ../test.py:15:10
def fn(x):
print(torch.isfinite(x))
~~~~~~~~~~~~~~ <--- HERE
It crashes at runtime and the signature is wrong since the actual op is not bound in, it's instead done here
|
DEFINE_UNARY_FLOAT_OP(aten::isfinite, std::isfinite(a), bool), |
results in
It crashes at runtime and the signature is wrong since the actual op is not bound in, it's instead done here
pytorch/torch/csrc/jit/register_prim_ops.cpp
Line 2941 in 0d9dc46