Open dselivanov opened 5 years ago
I considered using RcppR6 but did not for 2 reasons:
In pytorch they have a script to automatically generate wraper code.
https://github.com/pytorch/pytorch/blob/master/tools/autograd/gen_python_functions.py
We probably could do something similar in R.
NimTorch also generates wraper code here: https://github.com/fragcolor-xyz/nimtorch/blob/85b548e43d4bc18580871c3f8a4a0b4670a89cec/torch/generator.nim
altought I didn't find this Declarations.yaml file. Maybe we could generate the source code from here: https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/native_functions.yaml
There's also a rust binding the auto generates code here: https://github.com/torchrs/torchrs/blob/master/scripts/generate_wrappers.py
Maybe this is the declaration file they use: https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/native_functions.yaml
Found that Declarations.yaml is created when building pytorch from source. The file looks like this:
- name: add_
matches_jit_signature: false
schema_string: aten::add_(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor
method_prefix_derived: ''
arguments:
- dynamic_type: Tensor
is_nullable: false
name: self
type: Tensor &
- dynamic_type: Tensor
is_nullable: false
name: other
type: const Tensor &
- default: 1
dynamic_type: Scalar
is_nullable: false
kwarg_only: true
name: alpha
type: Scalar
method_of:
- Type
- Tensor
mode: native
python_module: ''
returns:
- dynamic_type: Tensor
name: self
type: Tensor &
inplace: true
is_factory_method: null
abstract: false
requires_tensor: false
device_guard: true
with_gil: false
deprecated: false
There is RcppR6 project, mb worth to explore. But I haven't used it myself, so can't tell for sure whether it is relevant or not.