ext/torch/ext.cpp in torch-rb-0.2.2 vs ext/torch/ext.cpp in torch-rb-0.2.3
- old
+ new
@@ -38,10 +38,23 @@
add_tensor_functions(rb_cTensor);
Module rb_mNN = define_module_under(rb_mTorch, "NN");
add_nn_functions(rb_mNN);
+ Module rb_mRandom = define_module_under(rb_mTorch, "Random")
+ .define_singleton_method(
+ "initial_seed",
+ *[]() {
+ return at::detail::getDefaultCPUGenerator()->current_seed();
+ })
+ .define_singleton_method(
+ "seed",
+ *[]() {
+ // TODO set for CUDA when available
+ return at::detail::getDefaultCPUGenerator()->seed();
+ });
+
// https://pytorch.org/cppdocs/api/structc10_1_1_i_value.html
Class rb_cIValue = define_class_under<torch::IValue>(rb_mTorch, "IValue")
.define_constructor(Constructor<torch::IValue>())
.define_method("bool?", &torch::IValue::isBool)
.define_method("bool_list?", &torch::IValue::isBoolList)
@@ -174,9 +187,20 @@
})
.define_singleton_method(
"manual_seed",
*[](uint64_t seed) {
return torch::manual_seed(seed);
+ })
+ // config
+ .define_singleton_method(
+ "show_config",
+ *[] {
+ return torch::show_config();
+ })
+ .define_singleton_method(
+ "parallel_info",
+ *[] {
+ return torch::get_parallel_info();
})
// begin tensor creation
.define_singleton_method(
"_arange",
*[](Scalar start, Scalar end, Scalar step, const torch::TensorOptions &options) {