GetData
Function
Obtains data of a tensor object.
Format
void* GetData() 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 then obtain data of the object.
1 2 3 4 5 6 7 8 | 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); size_t bufferSize = dataSize * sizeof(int64_t); inputsTensor->Allocate(bufferSize); auto data = inputsTensor->GetData(); |
Return Value
Start address of the tensor object data.
Parent topic: InferTensor