|
Ctrl-Z
一个多线程机器人运动控制强化学习部署框架
|
TensorBase class, base class for tensor 更多...
#include <TensorType.hpp>
Public 类型 | |
| using | Shape = TensorShape<Dims...> |
| using | ValueType = T |
Public 成员函数 | |
| TensorBase () | |
| Construct a new Tensor Base object with all elements set to default value | |
| TensorBase (const T &val) | |
| Construct a new Tensor Base object with all elements set to given value | |
| TensorBase (const std::array< ValueType, Shape::total_size > &data) | |
| Construct a new Tensor Base object, copy from std::array | |
| TensorBase (std::array< ValueType, Shape::total_size > &&data) | |
| Construct a new Tensor Base object, move from std::array | |
| TensorBase (const TensorBase &other) noexcept | |
| Construct a new Tensor Base object, copy from another tensor | |
| TensorBase (TensorBase &&other) noexcept | |
| Construct a new Tensor Base object, move from another tensor | |
| TensorBase< T, Dims... > & | operator= (const TensorBase &other) noexcept |
| assignment operator, copy from another tensor | |
| TensorBase< T, Dims... > & | operator= (TensorBase &&other) noexcept |
| assignment operator, move from another tensor | |
| TensorBase< T, Dims... > | clone () const |
| clone function, used to deepcopy a tensor | |
| TensorBase< T, Dims... > | DeepCopy () const |
| DeepCopy function, used to deepcopy a tensor | |
| void | DeepCopy (TensorBase< T, Dims... > &other) |
| deep copy from other tensor without change data_ptr address, this is useful when the original tensor's data ptr is already registerd in somewhere else. (e.g. warped in onnx runtime) | |
| void | clone (TensorBase< T, Dims... > &other) |
| deep copy from other tensor without change data_ptr address, this is useful when the original tensor's data ptr is already registerd in somewhere else. (e.g. warped in onnx runtime) | |
| bool | same (const TensorBase &other) const |
| compare two tensors, used to check if the given two tensors are the same tensor. | |
| bool | equal (const TensorBase &other) const |
| compare two tensors, used to check if the given two tensors are the same tensor. | |
| std::array< ValueType, Shape::total_size > & | Array () |
| convert to std::array | |
| const std::array< ValueType, Shape::total_size > & | Array () const |
| ValueType * | data () |
| get data pointer | |
| T & | operator[] (size_t index) |
| get data according to index, this function will ignore the shape of tensor, the index is the offset in the memory. | |
| const T & | operator[] (size_t index) const |
| this function is a overload of operator[], it will return the data according to the index. | |
| template<typename... Indices> | |
| T & | operator() (Indices... indices) |
| get data according to indices, this function will calculate the offset according to the shape of tensor. for example, a tensor with shape {2, 3, 4}, the index (1, 2, 3) will be calculated as 1*3*4 + 2*4 + 3 = 35. | |
| template<typename... Indices> | |
| const T & | operator() (Indices... indices) const |
| this function is a overload of operator(), it will return the data according to the indices. | |
| template<typename... Indices> | |
| T & | at (Indices... indices) |
| get data according to indices, this function will calculate the offset according to the shape of tensor. for example, a tensor with shape {2, 3, 4}, the index (1, 2, 3) will be calculated as 1*3*4 + 2*4 + 3 = 35. | |
| template<typename... Indices> | |
| const T & | at (Indices... indices) const |
| this function is a overload of at, it will return the data according to the indices. | |
静态 Public 成员函数 | |
| static constexpr size_t | size () |
| get total size of tensor | |
| static constexpr std::array< int64_t, Shape::num_dims > | shape () |
| get shape of tensor | |
| static constexpr const int64_t * | shape_ptr () |
| static constexpr size_t | num_dims () |
| get the number of dimensions | |
静态 Protected 成员函数 | |
| template<typename... Indices> | |
| static constexpr size_t | calculate_index (Indices... indices) |
| calculate the index according to the indices | |
| static void | PrintTensorElements (std::ostream &os, const TensorBase &tensor, size_t index, size_t level) |
| print tensor elements recursively | |
Protected 属性 | |
| std::array< T, Shape::total_size > * | data_ptr__ = nullptr |
| data array, used to store tensor data | |
| std::atomic< size_t > * | ref_count__ = nullptr |
| reference count | |
友元 | |
| std::ostream & | operator<< (std::ostream &os, const TensorBase &tensor) |
| operator << for std::ostream, used to output tensor data | |
TensorBase class, base class for tensor
| T | type of tensor element |
| Dims | tensor shape |
|
inline |
Construct a new Tensor Base object, copy from std::array
| data | an array of data |
|
inline |
Construct a new Tensor Base object, move from std::array
| data | an array of data |
|
inlinenoexcept |
Construct a new Tensor Base object, copy from another tensor
| other | another tensor |
|
inlinenoexcept |
Construct a new Tensor Base object, move from another tensor
| other | another tensor |
|
inline |
convert to std::array
|
inline |
get data according to indices, this function will calculate the offset according to the shape of tensor. for example, a tensor with shape {2, 3, 4}, the index (1, 2, 3) will be calculated as 1*3*4 + 2*4 + 3 = 35.
| Indices | indices |
| indices | indices |
|
inline |
this function is a overload of at, it will return the data according to the indices.
| Indices | indices |
| indices | indices |
|
inlinestaticconstexprprotected |
calculate the index according to the indices
| Indices |
| indices |
|
inline |
clone function, used to deepcopy a tensor
|
inline |
deep copy from other tensor without change data_ptr address, this is useful when the original tensor's data ptr is already registerd in somewhere else. (e.g. warped in onnx runtime)
| other |
|
inline |
get data pointer
|
inline |
DeepCopy function, used to deepcopy a tensor
|
inline |
deep copy from other tensor without change data_ptr address, this is useful when the original tensor's data ptr is already registerd in somewhere else. (e.g. warped in onnx runtime)
| other |
|
inline |
compare two tensors, used to check if the given two tensors are the same tensor.
| other | another tensor |
|
inlinestaticconstexpr |
get the number of dimensions
|
inline |
get data according to indices, this function will calculate the offset according to the shape of tensor. for example, a tensor with shape {2, 3, 4}, the index (1, 2, 3) will be calculated as 1*3*4 + 2*4 + 3 = 35.
| Indices | indices |
| indices | indices |
|
inline |
this function is a overload of operator(), it will return the data according to the indices.
| Indices | indices |
| indices | indices |
|
inlinenoexcept |
assignment operator, copy from another tensor
| other | another tensor |
|
inlinenoexcept |
assignment operator, move from another tensor
| other | another tensor |
|
inline |
get data according to index, this function will ignore the shape of tensor, the index is the offset in the memory.
| index | data index |
|
inline |
this function is a overload of operator[], it will return the data according to the index.
| index | data index |
|
inlinestaticprotected |
print tensor elements recursively
| os | output stream |
| tensor | tensor to print |
| index | index of elements |
| level | level of elements |
|
inline |
compare two tensors, used to check if the given two tensors are the same tensor.
| other | another tensor |
|
inlinestaticconstexpr |
get shape of tensor
|
inlinestaticconstexpr |
get total size of tensor
|
friend |
operator << for std::ostream, used to output tensor data
| os | std::ostream |
| tensor | TensorBase |