MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MakeLiteTensor

Function MakeLiteTensor

tensorflow/lite/delegates/flex/buffer_map_test.cc:35–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34template <typename T>
35UniqueTfLiteTensor MakeLiteTensor(const std::vector<int>& shape,
36 const std::vector<T>& data) {
37 auto tensor = UniqueTfLiteTensor(new TfLiteTensor, [](TfLiteTensor* t) {
38 TfLiteTensorDataFree(t);
39 TfLiteIntArrayFree(t->dims);
40 delete t;
41 });
42 tensor->allocation_type = kTfLiteDynamic;
43 tensor->type = typeToTfLiteType<T>();
44 tensor->dims = ConvertVectorToTfLiteIntArray(shape);
45 tensor->data.raw = nullptr;
46 tensor->is_variable = false;
47 memset(&tensor->quantization, 0, sizeof(TfLiteQuantization));
48 TfLiteTensorRealloc(data.size() * sizeof(T), tensor.get());
49 memcpy(tensor->data.raw, data.data(), data.size() * sizeof(T));
50 return tensor;
51}
52
53template <>
54UniqueTfLiteTensor MakeLiteTensor<string>(const std::vector<int>& shape,

Callers

nothing calls this directly

Calls 7

TfLiteTensorDataFreeFunction · 0.85
TfLiteIntArrayFreeFunction · 0.85
TfLiteTensorReallocFunction · 0.85
sizeMethod · 0.45
getMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected