From 6f2b99a0bc907313f08ea88bd40d32d8d7037d3f Mon Sep 17 00:00:00 2001 From: Jiacheng Huang <45955067+voltjia@users.noreply.github.com> Date: Fri, 26 Jun 2026 15:47:45 +0800 Subject: [PATCH] feat: add tensor-like TensorView constructor --- src/tensor_view.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tensor_view.h b/src/tensor_view.h index e747d19..0b6fc59 100644 --- a/src/tensor_view.h +++ b/src/tensor_view.h @@ -23,6 +23,14 @@ class TensorView { using Strides = std::vector; + template + TensorView(const TensorLike& tensor) + : data_{const_cast(static_cast(tensor.data()))}, + shape_{tensor.shape()}, + dtype_{tensor.dtype()}, + device_{tensor.device()}, + strides_{tensor.strides()} {} + template TensorView(void* data, const Shape& shape) : data_{data},