|
|
| Tensor () |
| | Initializes an empty tensor.
|
| |
| | Tensor (const vector< TIndex > &dims) |
| | Creates a tensor of the given dimension. More...
|
| |
|
| Tensor (const vector< int > &dims) |
| |
| template<class SrcContext , class ContextForCopy > |
| | Tensor (const Tensor< SrcContext > &src, ContextForCopy *context) |
| | Creates a tensor from a source tensor, copying over the content. More...
|
| |
| template<class SrcContext > |
| | Tensor (const Tensor< SrcContext > &src) |
| | Creates a tensor from a source tensor, copying over the content. More...
|
| |
|
template<typename T > |
| | Tensor (const vector< TIndex > &dims, const vector< T > &values, Context *context) |
| | Creates a tensor, and fills its contents with the given values.
|
| |
|
template<typename T , typename = typename std::enable_if<std::is_scalar<T>::value>::type> |
| | Tensor (const T &value, Context *context) |
| | Creates a scalar tensor, and fills its content with the given value.
|
| |
|
template<class SrcContext , class ContextForCopy > |
| void | CopyFrom (const Tensor< SrcContext > &src, ContextForCopy *context) |
| | Copies the data from a source tensor, with a contex provided to carry out the underlying memcpy operation.
|
| |
| template<class SrcContext > |
| void | CopyFrom (const Tensor< SrcContext > &src) |
| | Copies the data from a source tensor. More...
|
| |
| template<class ContextForCopy > |
| void | Extend (TIndex num, float growthPct, ContextForCopy *context) |
| | Extends the outer-most dimension of this tensor by num elements, preserving the existing data. More...
|
| |
|
template<class T , class ContextForCopy > |
| void | Reserve (const std::vector< T > &newCapacity, ContextForCopy *context) |
| |
| void | Shrink (TIndex outer_dim) |
| | Shrinks the outer-most dimension to given size, keeping the data. More...
|
| |
| template<typename... Ts> |
| void | Resize (Ts... dim_source) |
| | Resizes a tensor. More...
|
| |
| template<class OtherContext > |
| void | ResizeLike (const Tensor< OtherContext > &src_tensor) |
| | Resize the tensor like the source tensor. More...
|
| |
| void | Reshape (const vector< TIndex > &dims) |
| | Resizes the tensor without touching underlying storage. More...
|
| |
|
void | Reshape (const vector< int > &dims) |
| |
| string | DebugString () const |
| | A utility function to print the debug string for the tensor. More...
|
| |
| void | ShareData (const Tensor &src) |
| | Shares the data with another tensor. More...
|
| |
| template<typename T > |
| void | ShareExternalPointer (T *src, size_t capacity=0) |
| | Shares the data with an externally managed pointer. More...
|
| |
| template<typename T , typename Deleter > |
| void | ShareExternalPointer (T *src, size_t capacity, Deleter &&d) |
| | Shares the data with an externally managed pointer. More...
|
| |
|
void | ShareExternalPointer (void *src, const TypeMeta &meta, size_t capacity=0) |
| |
|
template<class Deleter > |
| void | ShareExternalPointer (void *src, const TypeMeta &meta, size_t capacity, Deleter &&d) |
| |
|
bool | shares_data () |
| |
| const void * | raw_data () const |
| | Returns a const raw void* pointer of the underlying storage. More...
|
| |
| template<typename T > |
| const T * | data () const |
| | Returns a typed pointer of the underlying storage. More...
|
| |
| void * | raw_mutable_data (const TypeMeta &meta) |
| | Returns a mutable raw pointer of the underlying storage. More...
|
| |
| void * | raw_mutable_data () |
| | Returns a mutable raw pointer of the underlying storage. More...
|
| |
| template<typename T > |
| T * | mutable_data () |
| | Returns a typed pointer of the underlying storage. More...
|
| |
|
int | ndim () const |
| | Returns the number of dimensions of the data.
|
| |
| TIndex | size () const |
| | Returns the size (i.e. More...
|
| |
|
size_t | itemsize () const |
| | Return the number of bytes each item takes in the tensor.
|
| |
| size_t | nbytes () const |
| | Returns the total number of bytes of the storage. More...
|
| |
|
size_t | capacity_nbytes () const |
| |
|
const vector< TIndex > & | dims () const |
| | Returns the dimensions of the tensor as a vector.
|
| |
|
TIndex | size_from_dim (int k) const |
| |
|
TIndex | size_to_dim (int k) const |
| |
| int | canonical_axis_index (int axis_index) const |
| | Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e.g., -1 for the last axis). More...
|
| |
|
template<typename T > |
| bool | IsType () const |
| | Checks if the tensor content is of the given data type.
|
| |
|
const TypeMeta & | meta () const |
| | Returns the TypeMeta object associated with the current data type.
|
| |
| int | dim32 (const int i) const |
| | Returns the i-th dimension of the tensor in int. More...
|
| |
| TIndex | dim (const int i) const |
| | Returns the i-th dimension of the tensor. More...
|
| |
template<class Context>
class caffe2::Tensor< Context >
Tensor is the basic class in Caffe2 that stores a contiguous memory with its shape information.
The Tensor class is essentially a wrapper around a device-specific memory (the device is specified by the Context template argument), and deals with the allocation and de-allocation of such memory. We make a simplified assumption that the memory is always contiguous.
Definition at line 73 of file tensor.h.