diff --git a/lib/torch/tensor.rb b/lib/torch/tensor.rb index 1473ee8..cdec05e 100644 --- a/lib/torch/tensor.rb +++ b/lib/torch/tensor.rb @@ -24,6 +24,7 @@ class Tensor alias_method :^, :logical_xor alias_method :<<, :__lshift__ alias_method :>>, :__rshift__ + alias_method :~, :bitwise_not def self.new(*args) FloatTensor.new(*args) diff --git a/test/tensor_methods_test.rb b/test/tensor_methods_test.rb index 8476e4b..8639323 100644 --- a/test/tensor_methods_test.rb +++ b/test/tensor_methods_test.rb @@ -132,4 +132,9 @@ def test_dup def test_cumsum_dtype assert_equal :int64, Torch.tensor([1, 2, 3]).cumsum(dim: 0).dtype end + + def test_bitwise_not + x = Torch.tensor([1, 2, 3]) + assert_tensor [-2, -3, -4], ~x + end end