Tensorfow GATHER operator

template <typename InputT, typename PositionsT>
TfLiteStatus Gather(TfLiteContext* context, const TfLiteGatherParams& params,
const TfLiteTensor* input, const TfLiteTensor* positions,
TfLiteTensor* output) {
const PositionsT* indexes = GetTensorData(positions);
bool indices_has_only_positive_elements = true;
const size_t num_indices = positions->bytes / sizeof(PositionsT);
for (size_t i = 0; i < num_indices; i++) {
if (indexes[i] < 0) {
indices_has_only_positive_elements = false;
TF_LITE_ENSURE(context, indices_has_only_positive_elements);

according to this code, I want to know when does indices_has_only_positive_elements become false

Hi @rita19991020,

Hope you understood the context of the code . Some extra details are given here.

The overall purpose of the code is to optimize the Gather operation for efficient execution on mobile and embedded devices. In the provided code, the Gather op requires to consider all valid indices only means that all positive elements in indexes tensor. Sometimes the indices become negative when tensors are over written in the same memory. If a single element in tensor is negative, ‘indices_has_only_positive_elements will throw `false’ indicating that the tensor consists of default values instead of actual values.
Thank You