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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +3 -2
- data/codegen/native_functions.yaml +1261 -791
- data/ext/torch/utils.h +1 -1
- data/lib/torch/nn/module.rb +2 -2
- data/lib/torch/optim/lr_scheduler/multi_step_lr.rb +1 -1
- data/lib/torch/optim/optimizer.rb +2 -2
- data/lib/torch/version.rb +1 -1
- data/lib/torch.rb +2 -2
- metadata +2 -2
data/ext/torch/utils.h
CHANGED
data/lib/torch/nn/module.rb
CHANGED
|
@@ -337,7 +337,7 @@ module Torch
|
|
|
337
337
|
if vars.any?
|
|
338
338
|
vars.map(&:inspect)
|
|
339
339
|
else
|
|
340
|
-
options.
|
|
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) }.
|
|
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.
|
|
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 }.
|
|
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.
|
|
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
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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: []
|