Skip to content

Commit f2bdecf

Browse files
authored
Correct type conversions in OpBuilder and add corresponding test. (#8873)
1 parent 3808df0 commit f2bdecf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/test_operations.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,11 @@ def aten_fn(b, A, lower, unit_diagonal, transpose_a):
26322632
'transpose_a': False
26332633
})
26342634

2635+
def test_type_conversion(self):
2636+
for xla_type in xb._XLA_PT_TYPE_MAP:
2637+
pt_type = xb.Op.to_torch_type(xla_type)
2638+
self.assertEqual(xla_type, xb.Op.from_torch_type(pt_type))
2639+
26352640

26362641
class MpDecoratorTest(test_utils.XlaTestCase):
26372642

torch_xla/core/xla_builder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class Type:
2929
Type.F16: torch.float16,
3030
Type.U8: torch.uint8,
3131
Type.S8: torch.int8,
32-
Type.U16: torch.int16,
32+
Type.U16: torch.uint16,
3333
Type.S16: torch.int16,
34-
Type.U32: torch.int32,
34+
Type.U32: torch.uint32,
3535
Type.S32: torch.int32,
36-
Type.U64: torch.int64,
36+
Type.U64: torch.uint64,
3737
Type.S64: torch.int64,
3838
Type.C64: torch.complex64,
3939
Type.C128: torch.complex128,

0 commit comments

Comments
 (0)