Add experimental Lantern-backed Tensor API#1470
Draft
dfalbel wants to merge 11 commits into
Draft
Conversation
dfalbel
force-pushed
the
experimental-tensor-api
branch
from
July 16, 2026 17:22
e9ee9b2 to
a15c466
Compare
Member
Author
|
Added the experimental tensor creation API in Exposed under
Each factory supports LibTorch-style default options, and applicable overloads accept the existing |
dfalbel
force-pushed
the
experimental-tensor-api
branch
from
July 16, 2026 19:26
e6ae16d to
ac503b6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
torch::experimental::TensorC++ facade backed by Lantern calls. It supports direct use in Rcpp exports, including fluent code such asinput.relu().reshape({-1}).The initial handwritten facade covers core Tensor behavior and conversions, while generated methods expose the broader Tensor namespace from
src/gen-namespace.cpp. The generator currently emits 758 overloads and audits coverage of 815 public Lantern Tensor entry points.Why
Packages using torch currently receive handle types but cannot write a LibTorch-style Tensor API without linking directly against LibTorch. This facade keeps the existing Lantern ABI boundary while providing a familiar C++ interface.
Impact
torch::experimental; existing APIs are unchanged.Validation
python3 tools/generate-experimental-tensor.py --check— passes (758 generated overloads; 815 Lantern Tensor entry points covered).testthat::test_file("tests/testthat/test-experimental-cpp-codegen.R")— passes.testthat::test_file("tests/testthat/test-experimental-cpp-api.R")— passes all 5 runtime assertions against the installed branch and configured Lantern runtime.BUILD_LANTERN=1 R CMD INSTALL .before running the tests.