#pragma once #include #include inline VALUE wrap(bool x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(int64_t x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(double x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(torch::Tensor x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(torch::Scalar x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(torch::ScalarType x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(torch::QScheme x) { return Rice::detail::To_Ruby().convert(x); } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 2, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)) ); } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 3, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)), Rice::detail::To_Ruby().convert(std::get<2>(x)) ); } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 4, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)), Rice::detail::To_Ruby().convert(std::get<2>(x)), Rice::detail::To_Ruby().convert(std::get<3>(x)) ); } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 5, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)), Rice::detail::To_Ruby().convert(std::get<2>(x)), Rice::detail::To_Ruby().convert(std::get<3>(x)), Rice::detail::To_Ruby().convert(std::get<4>(x)) ); } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 4, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)), Rice::detail::To_Ruby().convert(std::get<2>(x)), Rice::detail::To_Ruby().convert(std::get<3>(x)) ); } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 4, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)), Rice::detail::To_Ruby().convert(std::get<2>(x)), Rice::detail::To_Ruby().convert(std::get<3>(x)) ); } inline VALUE wrap(torch::TensorList x) { auto a = rb_ary_new2(x.size()); for (auto t : x) { rb_ary_push(a, Rice::detail::To_Ruby().convert(t)); } return a; } inline VALUE wrap(std::tuple x) { return rb_ary_new3( 2, Rice::detail::To_Ruby().convert(std::get<0>(x)), Rice::detail::To_Ruby().convert(std::get<1>(x)) ); }