tvm
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
tensor.h File Reference

Device-independent tensor allocation, copies, views and serialization. More...

#include <tvm/ffi/cast.h>
#include <tvm/ffi/container/shape.h>
#include <tvm/ffi/container/tensor.h>
#include <tvm/ffi/dtype.h>
#include <tvm/ffi/optional.h>
#include <tvm/ffi/string.h>
#include <tvm/runtime/base.h>
#include <tvm/runtime/device_api.h>
#include <tvm/support/io.h>
#include <tvm/support/serializer.h>
#include <algorithm>
#include <atomic>
#include <functional>
#include <limits>
#include <mutex>
#include <unordered_map>
#include <utility>
#include <vector>
Include dependency graph for tensor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tvm::runtime::TensorMemoryPool
 A cache of owning device tensors. More...
 

Namespaces

namespace  tvm
 An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
 
namespace  tvm::runtime
 

Functions

TVM_RUNTIME_DLL ffi::Tensor tvm::runtime::Empty (ffi::Shape shape, DLDataType dtype, Device dev, ffi::Optional< ffi::String > mem_scope=std::nullopt)
 Allocate an uninitialized tensor through the runtime device allocator.
 
TVM_RUNTIME_DLL void tvm::runtime::CopyFromTo (ffi::TensorView source, ffi::TensorView destination, TVMStreamHandle stream=nullptr)
 Copy between existing tensors with exactly matching byte sizes.
 
TVM_RUNTIME_DLL ffi::Tensor tvm::runtime::CopyTo (ffi::TensorView source, Device dev, ffi::Optional< ffi::String > mem_scope=std::nullopt)
 Allocate a fresh tensor on dev, copy source, and synchronize the copy.
 
TVM_RUNTIME_DLL ffi::Tensor tvm::runtime::CreateView (ffi::Tensor source, ffi::Shape shape, DLDataType dtype, uint64_t relative_byte_offset=0)
 Create a compact view retaining ownership of source.
 
TVM_RUNTIME_DLL void tvm::runtime::CopyFromBytes (ffi::TensorView destination, const void *source_bytes, size_t nbytes, TVMStreamHandle stream=nullptr)
 Copy exactly nbytes from a byte buffer into a contiguous tensor.
 
TVM_RUNTIME_DLL void tvm::runtime::CopyToBytes (ffi::TensorView source, void *destination_bytes, size_t nbytes, TVMStreamHandle stream=nullptr)
 Copy a contiguous tensor into a byte buffer of exactly nbytes.
 
void tvm::runtime::SaveTensor (ffi::TensorView source, support::Stream *strm)
 Save a tensor in the portable CPU tensor format.
 
ffi::Tensor tvm::runtime::LoadTensor (support::Stream *strm)
 Load a tensor from the portable format into CPU storage.
 
Device tvm::runtime::GetPreferredHostDevice (Device device)
 Get the preferred host device from the input device.
 
TVM_RUNTIME_DLL ffi::ObjectPtr< TensorMemoryPool > tvm::runtime::CreateTensorMemoryPool (DLDevice device)
 Create the default pool for a device.
 

Variables

constexpr uint64_t tvm::runtime::kTVMTensorMagic = 0xDD5E40F096B4A13F
 Magic number for Tensor file.
 

Detailed Description

Device-independent tensor allocation, copies, views and serialization.