Skip to content

Commit

Permalink
CharTensor should be signed (pytorch#5512)
Browse files Browse the repository at this point in the history
CharTensor is actually int8_t which is signed
  • Loading branch information
colesbury authored Mar 2, 2018
1 parent 0877558 commit 8f627fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aten/src/ATen/Dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
const at::Type& the_type = TYPE; \
switch (the_type.scalarType()) { \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Byte, uint8_t, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Char, uint8_t, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Char, int8_t, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Double, double, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Float, float, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Int, int32_t, __VA_ARGS__) \
Expand All @@ -57,7 +57,7 @@
const at::Type& the_type = TYPE; \
switch (the_type.scalarType()) { \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Byte, uint8_t, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Char, uint8_t, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Char, int8_t, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Double, double, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Float, float, __VA_ARGS__) \
AT_PRIVATE_CASE_TYPE(at::ScalarType::Int, int32_t, __VA_ARGS__) \
Expand Down
2 changes: 2 additions & 0 deletions test/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2165,13 +2165,15 @@ def test_slice(self):
def test_is_signed(self):
self.assertEqual(torch.IntTensor(5).is_signed(), True)
self.assertEqual(torch.ByteTensor(5).is_signed(), False)
self.assertEqual(torch.CharTensor(5).is_signed(), True)
self.assertEqual(torch.FloatTensor(5).is_signed(), True)
self.assertEqual(torch.HalfTensor(10).is_signed(), True)

@unittest.skipIf(not torch.cuda.is_available(), 'no CUDA')
def test_is_signed_cuda(self):
self.assertEqual(torch.cuda.IntTensor(5).is_signed(), True)
self.assertEqual(torch.cuda.ByteTensor(5).is_signed(), False)
self.assertEqual(torch.cuda.CharTensor(5).is_signed(), True)
self.assertEqual(torch.cuda.FloatTensor(5).is_signed(), True)
self.assertEqual(torch.cuda.HalfTensor(10).is_signed(), True)

Expand Down

0 comments on commit 8f627fc

Please sign in to comment.