lib/torch.rb in torch-rb-0.9.0 vs lib/torch.rb in torch-rb-0.9.1

- old
+ new

@@ -375,12 +375,10 @@ def load(f) to_ruby(_load(File.binread(f))) end - # --- begin tensor creation: https://pytorch.org/cppdocs/notes/tensor_creation.html --- - def tensor(data, **options) if options[:dtype].nil? && defined?(Numo::NArray) && data.is_a?(Numo::NArray) numo_to_dtype = _dtype_to_numo.map(&:reverse).to_h options[:dtype] = numo_to_dtype[data.class] end @@ -409,45 +407,10 @@ end _tensor(data, size, tensor_options(**options)) end - # --- begin like --- - - def ones_like(input, **options) - ones(input.size, **like_options(input, options)) - end - - def empty_like(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)) - end - - def rand_like(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)) - end - - def randn_like(input, **options) - randn(input.size, **like_options(input, options)) - end - - def zeros_like(input, **options) - zeros(input.size, **like_options(input, options)) - end - # center option def stft(input, n_fft, hop_length: nil, win_length: nil, window: nil, center: true, pad_mode: "reflect", normalized: false, onesided: true, return_complex: nil) if center signal_dim = input.dim extended_shape = [1] * (3 - signal_dim) + input.size @@ -568,17 +531,9 @@ options = options.layout(layout.to_s) end unless requires_grad.nil? options = options.requires_grad(requires_grad) end - options - end - - def like_options(input, options) - options = options.dup - options[:dtype] ||= input.dtype - options[:layout] ||= input.layout - options[:device] ||= input.device options end end end