lib/torch.rb in torch-rb-0.1.6 vs lib/torch.rb in torch-rb-0.1.7
- old
+ new
@@ -298,10 +298,19 @@
def device(str)
Device.new(str)
end
+ def save(obj, f)
+ raise NotImplementedYet unless obj.is_a?(Tensor)
+ File.binwrite(f, _save(obj))
+ end
+
+ def load(f)
+ raise NotImplementedYet
+ end
+
# --- begin tensor creation: https://pytorch.org/cppdocs/notes/tensor_creation.html ---
def arange(start, finish = nil, step = 1, **options)
# ruby doesn't support start = 0, finish, step = 1, ...
if finish.nil?
@@ -381,39 +390,39 @@
end
# --- begin like ---
def ones_like(input, **options)
- ones(input.size, like_options(input, options))
+ ones(input.size, **like_options(input, options))
end
def empty_like(input, **options)
- empty(input.size, like_options(input, options))
+ empty(input.size, **like_options(input, options))
end
def full_like(input, fill_value, **options)
- full(input.size, fill_value, like_options(input, options))
+ full(input.size, fill_value, **like_options(input, options))
end
def rand_like(input, **options)
- rand(input.size, like_options(input, options))
+ rand(input.size, **like_options(input, options))
end
def randint_like(input, low, high = nil, **options)
# ruby doesn't support input, low = 0, high, ...
if high.nil?
high = low
low = 0
end
- randint(low, high, input.size, like_options(input, options))
+ randint(low, high, input.size, **like_options(input, options))
end
def randn_like(input, **options)
- randn(input.size, like_options(input, options))
+ randn(input.size, **like_options(input, options))
end
def zeros_like(input, **options)
- zeros(input.size, like_options(input, options))
+ zeros(input.size, **like_options(input, options))
end
private
def tensor_size(size)