/**
 * Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
 * CANN Open Software License Agreement Version 2.0 (the "License").
 * Please refer to the License for details. You may not use this file except in compliance with the License.
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
 * See LICENSE in the root of the software repository for the full text of the License.
 */

/*!
 * \file apply_rotary_pos_emb_proto.h
 * \brief
 */
#ifndef OPS_OP_PROTO_INC_GRID_SAMPLE_OPS_H_
#define OPS_OP_PROTO_INC_GRID_SAMPLE_OPS_H_

#include "graph/operator_reg.h"

namespace ge {
/**
* @brief This operation samples input x by using interpolation based on flow field grid,
  which is usually generated by affine_grid.

* @par Inputs:
* @li x: 4-D Tensor. If the tensor is 4-D, the shape is `[batch, channels, height, width]` or
  `[batch, height, width, channels]`. The position of the channels axis depends on the 'channel_last' attribute.
* @li grid: flow field grid, 4-D Tensor with shape `[batch, output_height, output_width, 2]`.

* @par Attributes:
* @li interpolation_mode: An optional string specifying the interpolation method.
  The default value is "bilinear". Currently, only support "bilinear" and "bicubic".
* @li padding_mode: An optional string specifying the pad method,
  either "zeros", "border", or "reflection". The default value is "zeros".
* @li align_corners: An optional bool. If "true", the centers of the corner
  pixels of the input and output tensors are aligned. Defaults to "false".
* @li channel_last: An optional bool specifying the intput x shape. If "true", the x shape is
`[batch, height, width, channels]`, else if "false", the x shape is `[batch, channels, height, width]`. Defaults to
"false" .
* @li scheduler_mode: An optional int. 0: general; 1: sliding window.
  The value 1 is available only in the channel last scenario. The default value is 0.

* @par Outputs:
* y: Returns 4-D Tensor with the same dtype as `x`, the shape is `[batch, channels, output_height, output_width]`.

* @attention Constraints:
* @li The input value of the grid multiplied by the image (length or width) is
  greater than a 24 bit binary number (16777216), there may be errors in the sampling points,
  and the accuracy may be biased.
* @li If the grid contains data beyond the range of [-1, 1], errors may occur
  in the calculation of data in the small value range when bicubic interplation
  is used, and the precision may be inaccurate.
* @li If the grid contains a large amount of data that exceeds the range of [-1, 1],
  a large number of duplicate values in the calculation result will be obtained
  when the zeros or border padding policy is used.
* @li When bilinear or bicubic interpolation is used, the workspace memory
  is required for the float16 data type.

* @par Restrictions:
* Warning:THIS FUNCTION IS EXPERIMENTAL. Please do not use.
*/
REG_OP(GridSample)
    .INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT}))
    .INPUT(grid, TensorType({DT_FLOAT16, DT_FLOAT}))
    .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT}))
    .ATTR(interpolation_mode, String, "bilinear")
    .ATTR(padding_mode, String, "zeros")
    .ATTR(align_corners, Bool, false)
    .ATTR(channel_last, Bool, false)
    .ATTR(scheduler_mode, Int, 1)
    .OP_END_FACTORY_REG(GridSample)

}  // namespace ge

#endif