vtensor
Region-local device tensor handles with HWC shape metadata and packed-buffer crop staging.
| Quick fact | Value |
|---|---|
| Module | vtensor |
| Import | use external "vtensor/vtensor.vy"; |
| Depends on | an active @device region for device helpers |
| Status | Unstable — the public surface may change between releases. |
This page is generated from the library's in-repo manual (vyne/modules/external/vtensor/README.md) so signatures and behaviour stay aligned with the source tree. Examples assume a desktop target unless the text says otherwise.
vtensor is the small metadata layer over @device handles. It does not own device memory and it does not allocate by itself. A DeviceTensor pairs an Int64 device handle with HWC shape and element count so higher-level device helpers can pass shape safely without long argument lists.
Rules
- Handles are region-local. Do not store
DeviceTensorvalues outside the@deviceregion that owns their handles. - V1 is HWC-only because it targets image models first.
- Helpers marked
@device_fnare callable only from active@deviceregions or other@device_fnhelpers.
API
| Function | Result |
|---|---|
vtensor.tensor(handle, h, w, c) | shape metadata for an existing handle |
vtensor.copy_slice(dst, packed, offset) | device-side packed-buffer crop staging |
DeviceTensor exposes handle, height, width, channels, and n (height * width * channels). Supply positive dimensions matching the actual allocation. Metadata does not validate the capacity or dtype of an arbitrary handle. copy_slice copies dst.n elements from the packed device buffer at offset; it does not create a host slice or a borrowed sub-tensor handle.
Use vnn for explicit neural-network blocks and the ESPCN project for the full graph.