Class Tensor
Defined in File tensor.h
Inheritance Relationships
Base Type
public mindspore::api::Value
(Class Value)
Class Documentation
-
class Tensor : public mindspore::api::Value
Tensor represents a multi-dimensional array of elements.
Public Functions
-
Tensor(TypeId data_type, const ShapeVector &shape)
Create a lazy allocated tensor.
- Parameters
data_type – [in] [TypeId] Data type of the tensor.
shape – [in] The shape represented by ShapeVector of the tensor.
-
Tensor(TypeId data_type, const ShapeVector &shape, void *data, size_t data_len)
Create a tensor with input data buffer.
- Parameters
data_type – [in] [TypeId] Data type of the tensor.
shape – [in] The shape represented by ShapeVector of the tensor.
data – [in] The input data to be copied into tensor.
data_len – [in] The length of data in bytes.
-
const ShapeVector &shape() const
Get the shape of the tensor. The shape of a tensor is stored in a vector<int64_t>. Each element of the vector represents the size of a dimension of the tensor. The order of each element in the vector is the same as the the dimension’s order it represents.
- Returns
A vector<int64_t> which represents the shape of the tensor.
-
void set_shape(const ShapeVector &shape)
Set the shape of tensor.
- Parameters
shape – [in] The shape to be set.
-
TypeId data_type() const
Get the data type of the tensor.
- Returns
The data type of the tensor.
-
void set_data_type(const TypeId data_type)
Set the data type of the tensor.
- Parameters
data_type – [in] The data type to be set.
-
const void *data() const
Get The pointer to the underlying memory block for data storage.
- Returns
The pointer to the underlying data.
-
void *data()
Get The pointer to the underlying memory block for data storage.
- Returns
The pointer to the underlying data.
-
size_t DataSize() const
Get tensor data size.
- Returns
The total number of elements in the tensor.
-
std::size_t Size() const
Get tensor data size in bytes.
- Returns
The total number of bytes for the tensor data.
-
Tensor(TypeId data_type, const ShapeVector &shape)