Torch._check failing with torch compile

This is an example

def f(x):
    torch._check(x > 0)
    return torch.log(x)

torch.compile(f)(torch.rand(1))

Returns the following error:

TorchRuntimeError: Failed running call_function <function _check at 0x7f7cf0322fc0>(*(FakeTensor(..., size=(1,), dtype=torch.bool),), **{}):
cond must be a bool, but got <class 'torch._subclasses.fake_tensor.FakeTensor'>

from user code:
   File "/tmp/ipykernel_1454634/3269954531.py", line 2, in f
    torch._check(x > 0)

Set TORCH_LOGS="+dynamo" and TORCHDYNAMO_VERBOSE=1 for more information
1 Like