| 103 | } |
| 104 | |
| 105 | void DynamicBuffer::WriteToTensor(TfLiteTensor* tensor, |
| 106 | TfLiteIntArray* new_shape) { |
| 107 | char* tensor_buffer; |
| 108 | int bytes = WriteToBuffer(&tensor_buffer); |
| 109 | |
| 110 | if (new_shape == nullptr) { |
| 111 | new_shape = TfLiteIntArrayCopy(tensor->dims); |
| 112 | } |
| 113 | |
| 114 | // Set tensor content pointer to tensor_buffer, and release original data. |
| 115 | TfLiteTensorReset(tensor->type, tensor->name, new_shape, tensor->params, |
| 116 | tensor_buffer, bytes, kTfLiteDynamic, tensor->allocation, |
| 117 | tensor->is_variable, tensor); |
| 118 | } |
| 119 | |
| 120 | int GetStringCount(const char* raw_buffer) { |
| 121 | // The first integers in the raw buffer is the number of strings. |