SetRelease
Function
Sets whether to release the data memory for the input tensor object.
Format
void SetRelease(bool releaseFlag)
Parameters
Parameter |
Mandatory/Optional |
Description |
Value |
|---|---|---|---|
releaseFlag |
Mandatory |
Flag indicating whether to release the data memory |
Valid bool type |
Usage Example
Construct a tensor object whose name is INPUT_IDS, data type is INT64, and data shape is {1, 2}, and then set the flag indicating whether to release the data memory (true in the following example).
1 2 3 4 5 6 7 8 9 | std::string name = "INPUT_IDS"; mindie_llm::InferDataType dataType= mindie_llm::InferDataType::TYPE_INT64; int64_t dataSize = 2; std::vector<int64_t> dataShape = {1, dataSize}; auto inputsTensor = std::make_shared<mindie_llm::InferTensor>(name, dataType, dataShape); uint64_t bufferSize = dataSize * sizeof(int64_t); void *data = (void *)malloc(bufferSize); inputsTensor->SetBuffer(data, bufferSize, false); inputsTensor->SetRelease(true); |
Return Value
None
Parent topic: InferTensor