Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions thunder/tests/opinfos.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,20 @@ def _is_cuda_torch(x: torch.Tensor) -> bool:
tensor_properties.append(is_cuda_opinfo)


def _is_cpu_torch(x: torch.Tensor) -> bool:
return x.is_cpu


is_cpu_opinfo = OpInfo(
ltorch.is_cpu,
sample_input_generator=elementwise_unary_generator,
torch_reference=_is_cpu_torch,
dtypes=(datatypes.all_dtypes),
)

tensor_properties.append(is_cpu_opinfo)


def _is_nested_torch(x: torch.Tensor) -> bool:
return x.is_nested

Expand Down
8 changes: 8 additions & 0 deletions thunder/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ def is_cuda(a: TensorLike, /) -> bool:
return a.device.devicetype is devices.DeviceType.CUDA


@torchsymbol(torch.Tensor.is_cpu, is_property=True, id="torch.Tensor.is_cpu")
def is_cpu(a: TensorLike, /) -> bool:
return a.device.devicetype is devices.DeviceType.CPU


register_method("is_cpu", is_cpu)


@torchsymbol(torch.polar, id="torch.polar")
def polar(abs_: TensorLike, angle: TensorLike):
# Decompose polar into real/imag using Thunder ops and construct complex via mapped torch.complex
Expand Down
Loading