pytorch/test/cpp_extensions
Pavel Belevich 11a40410e7 pybind11 type_caster for at::Generator and custom RNG python test (#34774)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34774

This PR provides pybind11's `type_caster<at::Generator>` that allows mapping `at::Generator` instance returned from user-defined method to python `torch::Generator`, defined as `THPGenerator ` c++ class.

This allows 1) defining custom RNG in c++ extension 2) using custom RNG in python code.

`TestRNGExtension.test_rng` shows how to use custom RNG defined in `rng_extension.cpp`

Test Plan: Imported from OSS

Differential Revision: D20549451

Pulled By: pbelevich

fbshipit-source-id: 312a6deccf8228f7f60695bbf95834620d52f5eb
2020-03-22 10:57:35 -07:00
..
no_python_abi_suffix_test Allow building libraries with setuptools that dont have abi suffix (#14130) 2018-11-27 17:35:53 -08:00
torch_test_cpp_extension Add support for dotted names in CPP Extensions (#6986) 2018-04-29 18:10:03 +02:00
complex_registration_extension.cpp Delete unnecessary aliasAnalysis specification from operator registrations. (#33093) 2020-02-21 14:24:44 -08:00
cpp_frontend_extension.cpp Better tests/support for Python/C++ inter-op (#15193) 2018-12-14 08:42:10 -08:00
cuda_extension_kernel.cu Improve CUDA extension support (#5324) 2018-02-23 10:15:30 -05:00
cuda_extension_kernel2.cu Improve CUDA extension support (#5324) 2018-02-23 10:15:30 -05:00
cuda_extension.cpp Deprecate tensor.type() (#30281) 2019-12-05 10:55:34 -08:00
cuda_extension.cu Improve CUDA extension support (#5324) 2018-02-23 10:15:30 -05:00
cudnn_extension.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
doubler.h Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
extension.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
jit_extension.cpp Unify C++ API with C++ extensions (#11510) 2018-09-24 14:44:21 -07:00
jit_extension2.cpp Unify C++ API with C++ extensions (#11510) 2018-09-24 14:44:21 -07:00
msnpu_extension.cpp Delete unnecessary aliasAnalysis specification from operator registrations. (#33093) 2020-02-21 14:24:44 -08:00
rng_extension.cpp pybind11 type_caster for at::Generator and custom RNG python test (#34774) 2020-03-22 10:57:35 -07:00
setup.py pybind11 type_caster for at::Generator and custom RNG python test (#34774) 2020-03-22 10:57:35 -07:00