Skip to content

feat: add tensor-like TensorView constructor#10

Merged
voltjia merged 1 commit into
masterfrom
feat/tensor-view-from-tensor-like
Jun 26, 2026
Merged

feat: add tensor-like TensorView constructor#10
voltjia merged 1 commit into
masterfrom
feat/tensor-view-from-tensor-like

Conversation

@voltjia

@voltjia voltjia commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add a templated TensorView constructor for tensor-like objects in src/tensor_view.h.
  • The constructor reads data(), shape(), dtype(), device(), and strides() from the external tensor-like object.
  • This keeps InfiniRT as a view layer while letting InfiniOps convert caller-owned tensors to TensorView without ad hoc field-by-field construction.

Motivation

InfiniOps returning-style operator APIs need to allocate outputs through an external tensor type and then call the existing in-place operator implementation. A tensor-like TensorView constructor keeps that conversion centralized in InfiniRT instead of duplicating conversion helpers in InfiniOps.

Closes N/A.

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Smoke Test Result

Validated through InfiniOps #761 with this InfiniRT branch mounted as INFINI_RT_SOURCE_DIR:

$ python -m pip install .[dev] --no-build-isolation \
    -C cmake.define.INFINI_RT_SOURCE_DIR=/workspace/InfiniRT \
    -C cmake.define.INFINI_OPS_SMOKE_BUILD=ON \
    -C cmake.define.AUTO_DETECT_BACKENDS=OFF \
    -C cmake.define.WITH_TORCH=OFF
Successfully built InfiniOps
Successfully installed InfiniOps-0.1.0

$ python -m pytest -v --tb=short --junitxml=/workspace/results/test-results.xml tests/test_cpp_api.py
collected 2 items

tests/test_cpp_api.py::test_cpp_operator_call_instantiation_smoke PASSED [ 50%]
tests/test_cpp_api.py::test_cpp_returning_call_smoke PASSED              [100%]

============================== 2 passed in 2.55s ===============================

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA Yes smoke passed Validated through InfiniOps #761 external C++ API smoke.
Iluvatar No N/A - not affected Not tested.
MetaX No N/A - not affected Not tested.
Cambricon No N/A - not affected Not tested.
Moore No N/A - not affected Not tested.
Ascend No N/A - not affected Not tested.
Full `pytest` output (optional)
See smoke output above.

Benchmark / Performance Impact

N/A. This adds a convenience constructor for view construction and does not change runtime execution paths.

Notes for Reviewers

@voltjia voltjia marked this pull request as ready for review June 26, 2026 09:22
@voltjia voltjia changed the title feat: add tensor-like TensorView constructor feat: add tensor-like TensorView constructor Jun 26, 2026
@voltjia voltjia merged commit e303fec into master Jun 26, 2026
4 checks passed
@voltjia voltjia deleted the feat/tensor-view-from-tensor-like branch June 26, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant