GetShape

Function

Obtains the shape of a tensor object.

Format

const std::vector<int64_t> &GetShape() const

Parameters

None

Usage Example

Construct a tensor object whose name is INPUT_IDS, data type is INT64, and data shape is {1, 2}, and obtain the shape information.

1
2
3
4
5
std::string name = "INPUT_IDS";
mindie_llm::InferDataType dataType = mindie_llm::InferDataType::TYPE_INT64;
std::vector<int64_t> dataShape = {1, 2};
auto inputsTensor = std::make_shared<mindie_llm::InferTensor>(name, dataType, dataShape);
std::vector<int64_t> shape = inputsTensor->GetShape();

Return Value

Tensor data shape, which is of the vector<int64_t> type.