tensorflow/lite/kernels/dynamic_update_slice.cc
// TFLite DynamicUpdateSlice op follows the semantics of XLA DynamicUpdateSlice
// op. See https://www.tensorflow.org/xla/operation_semantics#dynamicupdateslice
// for details.
TFLite DynamicUpdateSlice op follows the semantics of XLA DynamicUpdateSlice
op.
TFLite DynamicUpdateSlice op follows the semantics of XLA DynamicUpdateSlice op .
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
  const TfLiteTensor* operand;
  TF_LITE_ENSURE_OK(context,
                    GetInputSafe(context, node, kOperandTensor, &operand));
  const TfLiteTensor* update;
  TF_LITE_ENSURE_OK(context,
                    GetInputSafe(context, node, kUpdateTensor, &update));
  const TfLiteTensor* start_indices;
  TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kStartIndicesTensor,
                                          &start_indices));
  TfLiteTensor* output;
  TF_LITE_ENSURE_OK(context,
                    GetOutputSafe(context, node, kOutputTensor, &output));
  TF_LITE_ENSURE(context, NumDimensions(start_indices) == 1);
  TF_LITE_ENSURE(context,
                 SizeOfDimension(start_indices, 0) == NumDimensions(operand));
  TF_LITE_ENSURE(context, NumDimensions(update) == NumDimensions(operand));
  for (int i = 0; i < NumDimensions(operand); i++) {
    TF_LITE_ENSURE(context,
                   SizeOfDimension(update, i) <= SizeOfDimension(operand, i));
  }
  TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);
  TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
  TF_LITE_ENSURE_TYPES_EQ(context, operand->type, update->type);
  TF_LITE_ENSURE_TYPES_EQ(context, start_indices->type, kTfLiteInt32);
  output->type = operand->type;
  TfLiteIntArray* output_size = TfLiteIntArrayCopy(operand->dims);
  return context->ResizeTensor(context, output, output_size);
}
TfLiteStatus Prepare ( TfLiteContext * context , TfLiteNode * node ) { const TfLiteTensor * operand ; TF_LITE_ENSURE_OK ( context , GetInputSafe ( context , node , kOperandTensor , & operand ) ) ; const TfLiteTensor * update ; TF_LITE_ENSURE_OK ( context , GetInputSafe ( context , node , kUpdateTensor , & update ) ) ; const TfLiteTensor * start_indices ; TF_LITE_ENSURE_OK ( context , GetInputSafe ( context , node , kStartIndicesTensor , & start_indices ) ) ; TfLiteTensor * output ; TF_LITE_ENSURE_OK ( context , GetOutputSafe ( context , node , kOutputTensor , & output ) ) ; TF_LITE_ENSURE ( context , NumDimensions ( start_indices ) == 1 ) ; TF_LITE_ENSURE ( context , SizeOfDimension ( start_indices , 0 ) == NumDimensions ( operand ) ) ; TF_LITE_ENSURE ( context , NumDimensions ( update ) == NumDimensions ( operand ) ) ; for ( int i = 0 ; i < NumDimensions ( operand ) ; i ++ ) { TF_LITE_ENSURE ( context , SizeOfDimension ( update , i ) <= SizeOfDimension ( operand , i ) ) ; } TF_LITE_ENSURE_EQ ( context , NumInputs ( node ) , 3 ) ; TF_LITE_ENSURE_EQ ( context , NumOutputs ( node ) , 1 ) ; TF_LITE_ENSURE_TYPES_EQ ( context , operand -> type , update -> type ) ; TF_LITE_ENSURE_TYPES_EQ ( context , start_indices -> type , kTfLiteInt32 ) ; output -> type = operand -> type ; TfLiteIntArray * output_size = TfLiteIntArrayCopy ( operand -> dims ) ; return context -> ResizeTensor ( context , output , output_size ) ; }
TFLite DynamicUpdateSlice op follows the semantics of XLA DynamicUpdateSlice
op.
TFLite DynamicUpdateSlice op follows the semantics of XLA DynamicUpdateSlice op .
// The shape of start_indices must be rank == 1, with dimension size equal to // the rank of operand. // Update must be less than or equal to the operand size for each dimension to // avoid generating out-of-bounds update indices.