lib/torch/tensor.rb in torch-rb-0.1.8 vs lib/torch/tensor.rb in torch-rb-0.2.0
- old
+ new
@@ -31,10 +31,14 @@
def to(device, non_blocking: false, copy: false)
device = Device.new(device) if device.is_a?(String)
_to(device, _dtype, non_blocking, copy)
end
+ def cpu
+ to("cpu")
+ end
+
def size(dim = nil)
if dim
_size_int(dim)
else
shape
@@ -178,9 +182,13 @@
finish += 1 unless index.exclude_end?
copy_to(_slice_tensor(0, index.begin, finish, 1), value)
else
raise Error, "Unsupported index type: #{index.class.name}"
end
+ end
+
+ def random!(from = 0, to)
+ _random__from_to(from, to)
end
private
def copy_to(dst, src)