Developing a package that plugs into torch is a big problem that you solved via lantern, so it would be nice to export that solution for other packages. In fact, you partially did, putting the API in inst/include, but it's not currently usable.
Basically I have an algorithm in C++, so going through the R API is not an option, and it would be great to have access to torch directly, same access as e.g. RcppEigen or RcppArmadillo provide. In other words, it would be nice to be able to do something like
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcp::depends(torch)]]
#include <torch.h>
// [[Rcpp::export]]
torch::Tensor zeros(int rows, int cols) {
int64_t sizes[2] = {rows, cols};
torch::IntArrayRef sizes_ref = torch::IntArrayRef(sizes);
torch::TensorOptions options = lantern_TensorOptions();
torch::Dtype dtype = lantern_Dtype_float64();
options = lantern_TensorOptions_dtype(options.get(), dtype.get());
return lantern_zeros_intarrayref_tensoroptions(sizes_ref.get(), options.get());
}
/*** R
zeros(5, 3)
*/
If this worked, we could basically embed access to torch in C++ code without routing anything through R. AFAICT, to provide this, torch would need to:
- Provide the mechanism to inject the includes into CPPFLAGS.
- Provide a low-level API point to start lantern.
- Register a bunch of functions like deleters and so on, so that objects in the torch namespace work.
Developing a package that plugs into torch is a big problem that you solved via lantern, so it would be nice to export that solution for other packages. In fact, you partially did, putting the API in
inst/include, but it's not currently usable.Basically I have an algorithm in C++, so going through the R API is not an option, and it would be great to have access to torch directly, same access as e.g. RcppEigen or RcppArmadillo provide. In other words, it would be nice to be able to do something like
If this worked, we could basically embed access to torch in C++ code without routing anything through R. AFAICT, to provide this, torch would need to: