# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This yaml file contains operators that are also defined by the ATen library.
# For lean mode:
#   - Codegen'd target `executorch_generated_lib` will be reading all the information
#     from this file, including operator schema and kernel metadata.
#   - Selective build target `codegen:executorch_defined_ops` now is selecting all the
#     operators in this file, by dumping all the op names into `selected_operators.yaml`.
#
# See the README.md file in executorch/kernels/portable for a description of the syntax used
# by this file.


# aten ops
- op: _to_copy.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::to_copy_out

- op: _softmax.out
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::_softmax_out

- op: add.out
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::add_out

- op: bmm.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::bmm_out

- op: cat.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::cat_out

- op: clone.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::clone_out

- op: div.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::div_out

- op: div.out_mode
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::div_out_mode

- op: embedding.out
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::embedding_out

- op: empty.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::empty_out

- op: expand_copy.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::expand_copy_out

- op: full.out
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::full_out

- op: gelu.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::gelu_out

- op: hardtanh.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::hardtanh_out

- op: max_pool2d_with_indices.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::max_pool2d_with_indices_out

- op: mean.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::mean_dim_out

- op: mul.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::mul_out

- op: mul.Scalar_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::mul_scalar_out

- op: permute_copy.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::permute_copy_out

- op: rsqrt.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::rsqrt_out

- op: sigmoid.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::sigmoid_out

- op: slice_copy.Tensor_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::slice_copy_Tensor_out

- op: split_with_sizes_copy.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::split_with_sizes_copy_out

- op: sub.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::sub_out

- op: view_copy.out
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::view_copy_out

- op: where.self_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::where_out

- op: transpose_copy.int_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::transpose_copy_int_out

- op: eq.Scalar_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::eq_scalar_out

- op: logical_not.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::logical_not_out

- op: any.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::any_out

- op: native_group_norm.out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::native_group_norm_out

- op: sum.IntList_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::sum_dim_out

- op: select_copy.int_out
  kernels:
    - arg_meta: null
      kernel_name: torch::executor::select_copy_int_out

# custom ops
- func: cadence::quantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
  variants: function
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantize_per_tensor_out

- func: cadence::dequantize_per_tensor.out(Tensor input, float scale, int zero_point, int quant_min, int quant_max, ScalarType dtype, *, Tensor(a!) out) -> Tensor(a!)
  variants: function
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::dequantize_per_tensor_out

- func: cadence::quantized_conv.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_conv_out

- func: cadence::quantized_conv2d_nchw.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_conv2d_nchw_out

- func: cadence::quantized_conv2d_nhwc.out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, Tensor weight_zero_point, Tensor bias_scale, float out_scale, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_conv2d_nhwc_out

- func: cadence::quantized_layer_norm.out(Tensor input, Tensor in_scale, Tensor in_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_layer_norm_out
- func: cadence::quantized_layer_norm.per_tensor_out(Tensor input, float in_scale, int in_zero_point, int[] normalized_shape, Tensor weight, Tensor bias, float eps, float output_scale, int output_zero_point, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_layer_norm_per_tensor_out

- func: cadence::quantized_linear.out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, Tensor weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_linear_out

- func: cadence::quantized_relu.out(Tensor X, Tensor X_zero_point, int out_zero_point, Tensor out_multiplier, Tensor out_shift, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_relu_out

- func: cadence::quantized_relu.per_tensor_out(Tensor X, int X_zero_point, int out_zero_point, int out_multiplier, int out_shift, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_relu_per_tensor_out

- func: cadence::quantized_matmul.out(Tensor X, int X_zero_point, Tensor Y, int Y_zero_point, Tensor? bias, int out_multiplier, int out_shift, int out_zero_point, bool transposed, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_matmul_out

- func: cadence::quantized_linear.per_tensor_out(Tensor src, Tensor weight, Tensor bias, SymInt src_zero_point, SymInt weight_zero_point, SymInt out_multiplier, SymInt out_shift, SymInt out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_linear_per_tensor_out

- func: cadence::im2row.out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, Tensor in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::im2row_out

- func: cadence::im2row.per_tensor_out(Tensor input, int[2] kernel_size, int[2] dilation, int[2] padding, int[2] stride, int in_zero_point, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::im2row_per_tensor_out

- func: cadence::quantized_conv.per_tensor_out(Tensor input, Tensor weight, Tensor bias, int[] stride, SymInt[] padding, int[] dilation, int groups, int input_zero_point, int weight_zero_point, float bias_scale, float out_scale, int out_zero_point, int out_multiplier, int out_shift, bool channel_last=False, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_conv_per_tensor_out

- func: cadence::quantized_fully_connected.out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, Tensor weight_zero_point, Tensor out_multiplier, Tensor out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_fully_connected_out

- func: cadence::quantized_fully_connected.per_tensor_out(Tensor src, Tensor weight, Tensor bias, int src_zero_point, int weight_zero_point, int out_multiplier, int out_shift, int out_zero_point, Tensor? offset, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::quantized_fully_connected_per_tensor_out

- func: cadence::requantize.out(Tensor input, Tensor in_scale, Tensor in_zero_point, Tensor out_scale, Tensor out_zero_point, ScalarType out_dtype, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::requantize_out

- func: cadence::requantize.per_tensor_out(Tensor input, float in_scale, int in_zero_point, float out_scale, int out_zero_point, ScalarType out_dtype, *, Tensor(a!) out) -> Tensor(a!)
  kernels:
    - arg_meta: null
      kernel_name: impl::vision::requantize_per_tensor_out
