Skip to content

Commit 0ea9802

Browse files
committed
Fixed error with Rice 4.5
1 parent 7cf171b commit 0ea9802

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.19.1 (unreleased)
2+
3+
- Fixed error with Rice 4.5
4+
15
## 0.19.0 (2025-01-29)
26

37
- Updated LibTorch to 2.6.0

ext/torch/templates.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ namespace Rice::detail
6666
class From_Ruby<c10::complex<T>>
6767
{
6868
public:
69+
Convertible is_convertible(VALUE value)
70+
{
71+
return Convertible::Cast;
72+
}
73+
6974
c10::complex<T> convert(VALUE x)
7075
{
7176
VALUE real = rb_funcall(x, rb_intern("real"), 0);
@@ -90,6 +95,11 @@ namespace Rice::detail
9095
class From_Ruby<FanModeType>
9196
{
9297
public:
98+
Convertible is_convertible(VALUE value)
99+
{
100+
return Convertible::Cast;
101+
}
102+
93103
FanModeType convert(VALUE x)
94104
{
95105
auto s = String(x).str();
@@ -116,6 +126,11 @@ namespace Rice::detail
116126
class From_Ruby<NonlinearityType>
117127
{
118128
public:
129+
Convertible is_convertible(VALUE value)
130+
{
131+
return Convertible::Cast;
132+
}
133+
119134
NonlinearityType convert(VALUE x)
120135
{
121136
auto s = String(x).str();
@@ -160,6 +175,11 @@ namespace Rice::detail
160175
class From_Ruby<Scalar>
161176
{
162177
public:
178+
Convertible is_convertible(VALUE value)
179+
{
180+
return Convertible::Cast;
181+
}
182+
163183
Scalar convert(VALUE x)
164184
{
165185
if (FIXNUM_P(x)) {

ext/torch/torch.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ torch::Tensor make_tensor(Rice::Array a, const std::vector<int64_t> &size, const
2121
}
2222

2323
void init_torch(Rice::Module& m) {
24-
register_handler<torch::Error>(handle_global_error);
24+
Rice::detail::Registries::instance.handlers.set([]() {
25+
try {
26+
throw;
27+
} catch (const torch::Error& ex) {
28+
handle_global_error(ex);
29+
}
30+
});
2531
add_torch_functions(m);
2632
m.define_singleton_function(
2733
"grad_enabled?",

torch-rb.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ Gem::Specification.new do |spec|
1616

1717
spec.required_ruby_version = ">= 3.1"
1818

19-
spec.add_dependency "rice", ">= 4.3.3"
19+
spec.add_dependency "rice", ">= 4.5"
2020
end

0 commit comments

Comments
 (0)