[FRONTEND] fixed pinned memory exception behavior (#1197)

no longer raise exception when the pointer is on "cpu" but also
accessible from within kernels (e.g., pinned memory)
This commit is contained in:
Philippe Tillet
2023-02-15 17:40:45 -08:00
committed by GitHub
parent 48c4efa23b
commit 9c330a411c
2 changed files with 14 additions and 14 deletions

View File

@@ -1463,18 +1463,18 @@ def test_noop(device='cuda'):
kernel[(1, )](x)
@pytest.mark.parametrize("device", ['cuda', 'cpu'])
@pytest.mark.parametrize("device", ['cuda', 'cpu', 'cpu_pinned'])
def test_pointer_arguments(device):
@triton.jit
def kernel(x):
pass
x = torch.empty(1024, device=device)
result = True
try:
kernel[(1,)](x)
except ValueError:
result = True if device == 'cpu' else False
assert result
pin_memory = 'pinned' in device
x = torch.empty(1024, device=device.split('_')[0], pin_memory=pin_memory)
if device == "cpu":
with pytest.raises(ValueError):
kernel[(1,)](x)
else:
kernel[(1, )](x)
@pytest.mark.parametrize("value, value_type", [