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.
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>());
@@ -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(rb_eRuntimeError, "%s", ex.what_without_backtrace()); \
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 == 8,
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(rb_eRuntimeError, ex.what_without_backtrace());
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
@@ -1,3 +1,3 @@
1
1
  module Torch
2
- VERSION = "0.21.0"
2
+ VERSION = "0.22.0"
3
3
  end
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."
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.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane