torch-rb 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/torch/utils.h CHANGED
@@ -8,7 +8,7 @@
8
8
  #include <rice/stl.hpp>
9
9
 
10
10
  static_assert(
11
- TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR == 13,
11
+ TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR == 15,
12
12
  "Incompatible LibTorch version"
13
13
  );
14
14
 
@@ -337,7 +337,7 @@ module Torch
337
337
  if vars.any?
338
338
  vars.map(&:inspect)
339
339
  else
340
- options.map { |k, v| [k, v.inspect] }.to_h
340
+ options.to_h { |k, v| [k, v.inspect] }
341
341
  end
342
342
  str % vars
343
343
  end
@@ -346,7 +346,7 @@ module Torch
346
346
  # remove tensors for performance
347
347
  # so we can skip call to inspect
348
348
  def dict
349
- instance_variables.reject { |k| instance_variable_get(k).is_a?(Tensor) }.map { |k| [k[1..-1].to_sym, instance_variable_get(k)] }.to_h
349
+ instance_variables.reject { |k| instance_variable_get(k).is_a?(Tensor) }.to_h { |k| [k[1..-1].to_sym, instance_variable_get(k)] }
350
350
  end
351
351
 
352
352
  def load_from_state_dict(state_dict, prefix, local_metadata, strict, missing_keys, unexpected_keys, error_msgs)
@@ -3,7 +3,7 @@ module Torch
3
3
  module LRScheduler
4
4
  class MultiStepLR < LRScheduler
5
5
  def initialize(optimizer, milestones, gamma: 0.1, last_epoch: -1)
6
- @milestones = milestones.map.with_index.map { |v, i| [v, i + 1] }.to_h
6
+ @milestones = milestones.map.with_index.to_h { |v, i| [v, i + 1] }
7
7
  @gamma = gamma
8
8
  super(optimizer, last_epoch)
9
9
  end
@@ -35,13 +35,13 @@ module Torch
35
35
  raise NotImplementedYet
36
36
 
37
37
  pack_group = lambda do |group|
38
- packed = group.select { |k, _| k != :params }.map { |k, v| [k.to_s, v] }.to_h
38
+ packed = group.select { |k, _| k != :params }.to_h { |k, v| [k.to_s, v] }
39
39
  packed["params"] = group[:params].map { |p| p.object_id }
40
40
  packed
41
41
  end
42
42
 
43
43
  param_groups = @param_groups.map { |g| pack_group.call(g) }
44
- packed_state = @state.map { |k, v| [k.is_a?(Tensor) ? k.object_id : k, v] }.to_h
44
+ packed_state = @state.to_h { |k, v| [k.is_a?(Tensor) ? k.object_id : k, v] }
45
45
 
46
46
  {
47
47
  "state" => packed_state,
data/lib/torch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Torch
2
- VERSION = "0.25.0"
2
+ VERSION = "0.27.0"
3
3
  end
data/lib/torch.rb CHANGED
@@ -272,7 +272,7 @@ module Torch
272
272
  qint32: 14,
273
273
  bfloat16: 15
274
274
  }
275
- ENUM_TO_DTYPE = DTYPE_TO_ENUM.map(&:reverse).to_h
275
+ ENUM_TO_DTYPE = DTYPE_TO_ENUM.invert
276
276
 
277
277
  TENSOR_TYPE_CLASSES = []
278
278
 
@@ -408,7 +408,7 @@ module Torch
408
408
 
409
409
  def tensor(data, **options)
410
410
  if options[:dtype].nil? && defined?(Numo::NArray) && data.is_a?(Numo::NArray)
411
- numo_to_dtype = _dtype_to_numo.map(&:reverse).to_h
411
+ numo_to_dtype = _dtype_to_numo.invert
412
412
  options[:dtype] = numo_to_dtype[data.class]
413
413
  end
414
414
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torch-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  - !ruby/object:Gem::Version
242
242
  version: '0'
243
243
  requirements: []
244
- rubygems_version: 4.0.14
244
+ rubygems_version: 4.0.20
245
245
  specification_version: 4
246
246
  summary: Deep learning for Ruby, powered by LibTorch
247
247
  test_files: []