torch-rb 0.21.0 → 0.22.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 +5 -0
- data/README.md +2 -3
- data/codegen/generate_functions.rb +5 -1
- data/codegen/native_functions.yaml +239 -152
- data/ext/torch/ext.cpp +4 -0
- data/ext/torch/templates.h +1 -1
- data/ext/torch/utils.h +4 -2
- data/lib/torch/version.rb +1 -1
- data/lib/torch.rb +0 -1
- metadata +1 -1
data/ext/torch/ext.cpp
CHANGED
@@ -16,10 +16,14 @@ void init_generator(Rice::Module& m, Rice::Class& rb_cGenerator);
|
|
16
16
|
void init_ivalue(Rice::Module& m, Rice::Class& rb_cIValue);
|
17
17
|
void init_random(Rice::Module& m);
|
18
18
|
|
19
|
+
VALUE rb_eTorchError = Qnil;
|
20
|
+
|
19
21
|
extern "C"
|
20
22
|
void Init_ext() {
|
21
23
|
auto m = Rice::define_module("Torch");
|
22
24
|
|
25
|
+
rb_eTorchError = Rice::define_class_under(m, "Error", rb_eStandardError);
|
26
|
+
|
23
27
|
// need to define certain classes up front to keep Rice happy
|
24
28
|
auto rb_cIValue = Rice::define_class_under<torch::IValue>(m, "IValue")
|
25
29
|
.define_constructor(Rice::Constructor<torch::IValue>());
|
data/ext/torch/templates.h
CHANGED
@@ -31,7 +31,7 @@ using torch::nn::init::NonlinearityType;
|
|
31
31
|
|
32
32
|
#define END_HANDLE_TH_ERRORS \
|
33
33
|
} catch (const torch::Error& ex) { \
|
34
|
-
rb_raise(
|
34
|
+
rb_raise(rb_eTorchError, "%s", ex.what_without_backtrace()); \
|
35
35
|
} catch (const Rice::Exception& ex) { \
|
36
36
|
rb_raise(ex.class_of(), "%s", ex.what()); \
|
37
37
|
} catch (const std::exception& ex) { \
|
data/ext/torch/utils.h
CHANGED
@@ -8,12 +8,14 @@
|
|
8
8
|
#include <rice/stl.hpp>
|
9
9
|
|
10
10
|
static_assert(
|
11
|
-
TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR ==
|
11
|
+
TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR == 9,
|
12
12
|
"Incompatible LibTorch version"
|
13
13
|
);
|
14
14
|
|
15
|
+
extern VALUE rb_eTorchError;
|
16
|
+
|
15
17
|
inline void handle_global_error(const torch::Error& ex) {
|
16
|
-
throw Rice::Exception(
|
18
|
+
throw Rice::Exception(rb_eTorchError, ex.what_without_backtrace());
|
17
19
|
}
|
18
20
|
|
19
21
|
// keep THP prefix for now to make it easier to compare code
|
data/lib/torch/version.rb
CHANGED
data/lib/torch.rb
CHANGED
@@ -210,7 +210,6 @@ require_relative "torch/utils/data/tensor_dataset"
|
|
210
210
|
require_relative "torch/hub"
|
211
211
|
|
212
212
|
module Torch
|
213
|
-
class Error < StandardError; end
|
214
213
|
class NotImplementedYet < StandardError
|
215
214
|
def message
|
216
215
|
"This feature has not been implemented yet. Consider submitting a PR."
|