Truncate interface

Function

Truncates the input tensor object.

Format

bool Truncate(const size_t truncLen)

Parameters

Parameter

Mandatory/Optional

Description

Value

truncLen

Mandatory

Valid data length.

Valid data length. The type is size_t.

Usage Example

Constructs an INPUT_IDS tensor object whose data type is INT64 and data dimension is {1, 2}. The tensor object is truncated to length 1.

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);
bool ret = inputsTensor->Truncate(1);

Return Value

N/A