# ----------------------------------------------------------------------------
# Copyright (c) 2026 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.
# ----------------------------------------------------------------------------

operator:
  name: DepthwiseConv2D
  category: Contraction
  difficulty: L3
  formula: y[n,c,h,w] = bias[c] + sum_{kh,kw} x[n,c,h*s_h+kh*d_h-p_h,w*s_w+kw*d_w-p_w] * weight[c,kh,kw]
  description: 二维深度卷积运算(每输入通道独立卷积,groups = C,无跨通道求和)
  shape_support: 'x: [N, C, H, W], weight: [C, K_h, K_w], bias: [C]; 约束 groups == C'
  attrs:
  - name: kernelSize
    type: ListInt
    description: 卷积核大小
    required: true
  - name: stride
    type: ListInt
    description: 步长
    required: true
  - name: padding
    type: ListInt
    description: 填充
    required: true
  - name: dilation
    type: ListInt
    description: 膨胀率
    required: true
  - name: groups
    type: Int
    description: 分组数;depthwise 要求 groups == C(输入通道数)
    required: true
  inputs:
  - name: x
    description: 输入特征图
    dtype:
    - float16
    - float32
    - bfloat16
  - name: weight
    description: 卷积核
    dtype:
    - float16
    - float32
    - bfloat16
  - name: bias
    description: 偏置
    dtype:
    - float16
    - float32
    - bfloat16
  outputs:
  - name: y
    description: 输出特征图
    dtype:
    - float16
    - float32
    - bfloat16
  schema: depthwise_conv_2d(Tensor x, Tensor weight, Tensor bias, int[] kernelSize,
    int[] stride, int[] padding, int[] dilation, int groups) -> Tensor y