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

Function GatherStrings

tensorflow/lite/kernels/gather.cc:110–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109template <typename PositionT>
110TfLiteStatus 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
127TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
128 const auto* params =

Callers

nothing calls this directly

Calls 4

GetStringCountFunction · 0.85
GetStringFunction · 0.85
AddStringMethod · 0.80
WriteToTensorAsVectorMethod · 0.80

Tested by

no test coverage detected