| 108 | |
| 109 | template <typename PositionT> |
| 110 | TfLiteStatus GatherStrings(TfLiteContext* context, const TfLiteTensor* input, |
| 111 | const TfLiteTensor* positions, |
| 112 | TfLiteTensor* output) { |
| 113 | // TODO(mgubin): Currently support only for 1D output tensors. |
| 114 | DynamicBuffer buffer; |
| 115 | const PositionT* indexes = GetTensorData<PositionT>(positions); |
| 116 | const PositionT num_strings = GetStringCount(input); |
| 117 | for (int i = 0; i < positions->dims->data[0]; ++i) { |
| 118 | const PositionT pos = indexes[i]; |
| 119 | TF_LITE_ENSURE(context, pos < num_strings); |
| 120 | const auto string_ref = GetString(input, pos); |
| 121 | buffer.AddString(string_ref.str, string_ref.len); |
| 122 | } |
| 123 | buffer.WriteToTensorAsVector(output); |
| 124 | return kTfLiteOk; |
| 125 | } |
| 126 | |
| 127 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 128 | const auto* params = |
nothing calls this directly
no test coverage detected