ext/torch/ext.cpp in torch-rb-0.2.7 vs ext/torch/ext.cpp in torch-rb-0.3.0

- old
+ new

@@ -46,17 +46,18 @@ Module rb_mRandom = define_module_under(rb_mTorch, "Random") .add_handler<torch::Error>(handle_error) .define_singleton_method( "initial_seed", *[]() { - return at::detail::getDefaultCPUGenerator()->current_seed(); + return at::detail::getDefaultCPUGenerator().current_seed(); }) .define_singleton_method( "seed", *[]() { // TODO set for CUDA when available - return at::detail::getDefaultCPUGenerator()->seed(); + auto generator = at::detail::getDefaultCPUGenerator(); + return generator.seed(); }); // https://pytorch.org/cppdocs/api/structc10_1_1_i_value.html Class rb_cIValue = define_class_under<torch::IValue>(rb_mTorch, "IValue") .add_handler<torch::Error>(handle_error) @@ -458,10 +459,10 @@ return self.to(device, (torch::ScalarType) dtype, non_blocking, copy); }) .define_singleton_method( "_make_subclass", *[](Tensor& rd, bool requires_grad) { - auto data = torch::autograd::as_variable_ref(rd).detach(); + auto data = rd.detach(); data.unsafeGetTensorImpl()->set_allow_tensor_metadata_change(true); auto var = data.set_requires_grad(requires_grad); return Parameter(std::move(var)); });