torch-rb 0.9.0 → 0.10.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 +17 -0
- data/README.md +6 -4
- data/codegen/function.rb +2 -2
- data/codegen/generate_functions.rb +5 -1
- data/codegen/native_functions.yaml +951 -362
- data/ext/torch/backends.cpp +2 -2
- data/ext/torch/nn.cpp +4 -1
- data/ext/torch/ruby_arg_parser.cpp +2 -2
- data/ext/torch/ruby_arg_parser.h +6 -6
- data/ext/torch/sparse_functions.h +6 -0
- data/ext/torch/templates.h +34 -0
- data/ext/torch/tensor.cpp +25 -25
- data/ext/torch/torch.cpp +38 -28
- data/ext/torch/utils.h +0 -6
- data/lib/torch/inspector.rb +1 -1
- data/lib/torch/nn/functional.rb +1 -1
- data/lib/torch/nn/functional_attention.rb +1 -1
- data/lib/torch/nn/parameter.rb +3 -0
- data/lib/torch/nn/parameter_list.rb +48 -0
- data/lib/torch/tensor.rb +4 -8
- data/lib/torch/utils/data/data_loader.rb +1 -1
- data/lib/torch/version.rb +1 -1
- data/lib/torch.rb +15 -48
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7884d0bd8ffd23e775b3a1ca59e536bc18cd79c6bbe2736a9802a2b1693d40de
|
4
|
+
data.tar.gz: 10849c8a248a70eca7178ca3529fa7428fc3d8e5cfe2ca774b0be6cb5e75eb9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d81587eae00527e9d1e4a65b62a686dbdab27eed9401539faddf553d3a0730ad7394b01bac615bdd0474d1a6602cd0a3117e1d7cb3a3f1d5fbf8bd989fa39e59
|
7
|
+
data.tar.gz: d581d07821f103ee69267bc8e6b15d5094d8b8ef004917af947e2570649e7fbe750c9893d40600b62ee970646654fc545a270e7a59adb764be2ba73f1fa18b62
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## 0.10.0 (2022-03-13)
|
2
|
+
|
3
|
+
- Updated LibTorch to 1.11.0
|
4
|
+
- Added `ParameterList`
|
5
|
+
|
6
|
+
## 0.9.2 (2022-02-03)
|
7
|
+
|
8
|
+
- Added support for setting `nil` gradient
|
9
|
+
- Added checks when setting gradient
|
10
|
+
- Fixed precision with `Torch.tensor` method
|
11
|
+
- Fixed memory issue when creating tensor for `ByteStorage`
|
12
|
+
|
13
|
+
## 0.9.1 (2022-02-02)
|
14
|
+
|
15
|
+
- Moved `like` methods to C++
|
16
|
+
- Fixed memory issue
|
17
|
+
|
1
18
|
## 0.9.0 (2021-10-23)
|
2
19
|
|
3
20
|
- Updated LibTorch to 1.10.0
|
data/README.md
CHANGED
@@ -7,6 +7,7 @@ Check out:
|
|
7
7
|
- [TorchVision](https://github.com/ankane/torchvision) for computer vision tasks
|
8
8
|
- [TorchText](https://github.com/ankane/torchtext) for text and NLP tasks
|
9
9
|
- [TorchAudio](https://github.com/ankane/torchaudio) for audio tasks
|
10
|
+
- [TorchRec](https://github.com/ankane/torchrec-ruby) for recommendation systems
|
10
11
|
|
11
12
|
[](https://github.com/ankane/torch.rb/actions)
|
12
13
|
|
@@ -21,10 +22,10 @@ brew install libtorch
|
|
21
22
|
Add this line to your application’s Gemfile:
|
22
23
|
|
23
24
|
```ruby
|
24
|
-
gem
|
25
|
+
gem "torch-rb"
|
25
26
|
```
|
26
27
|
|
27
|
-
It can take
|
28
|
+
It can take 5-10 minutes to compile the extension.
|
28
29
|
|
29
30
|
## Getting Started
|
30
31
|
|
@@ -79,7 +80,7 @@ b = Torch.zeros(2, 3)
|
|
79
80
|
|
80
81
|
Each tensor has four properties
|
81
82
|
|
82
|
-
- `dtype` - the data type - `:uint8`, `:int8`, `:int16`, `:int32`, `:int64`, `:float32`,
|
83
|
+
- `dtype` - the data type - `:uint8`, `:int8`, `:int16`, `:int32`, `:int64`, `:float32`, `:float64`, or `:bool`
|
83
84
|
- `layout` - `:strided` (dense) or `:sparse`
|
84
85
|
- `device` - the compute device, like CPU or GPU
|
85
86
|
- `requires_grad` - whether or not to record gradients
|
@@ -408,7 +409,8 @@ Here’s the list of compatible versions.
|
|
408
409
|
|
409
410
|
Torch.rb | LibTorch
|
410
411
|
--- | ---
|
411
|
-
0.
|
412
|
+
0.10.0+ | 1.11.0+
|
413
|
+
0.9.0-0.9.2 | 1.10.0-1.10.2
|
412
414
|
0.8.0-0.8.3 | 1.9.0-1.9.1
|
413
415
|
0.6.0-0.7.0 | 1.8.0-1.8.1
|
414
416
|
0.5.0-0.5.3 | 1.7.0-1.7.1
|
data/codegen/function.rb
CHANGED
@@ -37,7 +37,7 @@ class Function
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def parse_func
|
40
|
-
input, output = func.
|
40
|
+
input, _, output = func.rpartition(/\s+->\s+/)
|
41
41
|
[generate_params(input), generate_retvals(output)]
|
42
42
|
end
|
43
43
|
|
@@ -52,7 +52,7 @@ class Function
|
|
52
52
|
next
|
53
53
|
end
|
54
54
|
|
55
|
-
type, name = i.
|
55
|
+
type, _, name = i.rpartition(/\s+/)
|
56
56
|
|
57
57
|
if name.include?("=")
|
58
58
|
name, default = name.split("=", 2)
|
@@ -14,6 +14,7 @@ def generate_functions
|
|
14
14
|
generate_files("fft", :define_singleton_method, functions[:fft])
|
15
15
|
generate_files("linalg", :define_singleton_method, functions[:linalg])
|
16
16
|
generate_files("special", :define_singleton_method, functions[:special])
|
17
|
+
generate_files("sparse", :define_singleton_method, functions[:sparse])
|
17
18
|
end
|
18
19
|
|
19
20
|
def load_functions
|
@@ -47,6 +48,7 @@ def group_functions(functions)
|
|
47
48
|
linalg_functions, other_functions = other_functions.partition { |f| f.python_module == "linalg" }
|
48
49
|
fft_functions, other_functions = other_functions.partition { |f| f.python_module == "fft" }
|
49
50
|
special_functions, other_functions = other_functions.partition { |f| f.python_module == "special" }
|
51
|
+
sparse_functions, other_functions = other_functions.partition { |f| f.python_module == "sparse" }
|
50
52
|
unexpected_functions, other_functions = other_functions.partition { |f| f.python_module }
|
51
53
|
torch_functions = other_functions.select { |f| f.variants.include?("function") }
|
52
54
|
tensor_functions = other_functions.select { |f| f.variants.include?("method") }
|
@@ -62,7 +64,8 @@ def group_functions(functions)
|
|
62
64
|
nn: nn_functions,
|
63
65
|
linalg: linalg_functions,
|
64
66
|
fft: fft_functions,
|
65
|
-
special: special_functions
|
67
|
+
special: special_functions,
|
68
|
+
sparse: sparse_functions
|
66
69
|
}
|
67
70
|
end
|
68
71
|
|
@@ -136,6 +139,7 @@ def generate_attach_def(name, type, def_method)
|
|
136
139
|
ruby_name = ruby_name.sub(/\Afft_/, "") if type == "fft"
|
137
140
|
ruby_name = ruby_name.sub(/\Alinalg_/, "") if type == "linalg"
|
138
141
|
ruby_name = ruby_name.sub(/\Aspecial_/, "") if type == "special"
|
142
|
+
ruby_name = ruby_name.sub(/\Asparse_/, "") if type == "sparse"
|
139
143
|
ruby_name = name if name.start_with?("__")
|
140
144
|
|
141
145
|
# cast for Ruby < 2.7 https://github.com/thisMagpie/fftw/issues/22#issuecomment-49508900
|