| 33 | |
| 34 | template <typename T> |
| 35 | UniqueTfLiteTensor 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 | |
| 53 | template <> |
| 54 | UniqueTfLiteTensor MakeLiteTensor<string>(const std::vector<int>& shape, |
nothing calls this directly
no test coverage detected