昇腾社区首页
中文
注册

简介

Shape结构体用于描述一个tensor的shape,包含两个信息:

size_t dim_num_;
int64_t dims_[kMaxDimNum];

其中,dim_num_表示shape的维数,dims_数组表示tensor具体的shape。

需要包含的头文件

1
#include <shape.h>

Public成员函数

Shape() : dim_num_(0), dims_{0}
Shape(const std::initializer_list<int64_t> &args) : Shape()
Shape(const Shape &other)
Shape &operator=(const Shape &other)
bool operator==(const Shape &rht) const
bool operator!=(const Shape &rht) const
const int64_t &operator[](const size_t idx) const
int64_t &operator[](const size_t idx)
bool IsScalar() const
void SetScalar()
size_t GetDimNum() const
void SetDimNum(const size_t dim_num)
int64_t GetDim(const size_t idx) const
void SetDim(size_t idx, const int64_t dim_value)
Shape& AppendDim(const int64_t value)