Truncate接口

接口功能

对输入张量对象进行截断。

接口格式

bool Truncate(const size_t truncLen)

接口参数

参数

是否必选

说明

取值要求

truncLen

合法的数据长度大小。

合法的数据长度大小,类型为size_t。

使用样例

构造一个名为"INPUT_IDS",数据类型为INT64,数据维度为{1,2}的Tensor对象,对张量对象进行截断,截断长度为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);

返回值

无。