#
# SPDX-FileCopyrightText: Copyright (c) 2022-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
name: CustomQKVToContextPluginDynamic
interface: "IPluginV3"
versions:
  "4":
    inputs:
      - input
    outputs:
      - output
    input_dims:
      input: 5
    output_dims:
      output: "input_0, input_1, hidden_size_0, 1, 1"
    attributes:
      - type_id
      - hidden_size
      - num_heads
      - has_mask
      - dq_probs
    attribute_types:
      type_id: int32
      hidden_size: int32
      num_heads: int32
      has_mask: int32
      dq_probs: float32
    attribute_length:
      type_id: 1
      hidden_size: 1
      num_heads: 1
      has_mask: 1
      dq_probs: 1
    attribute_options:
      type_id:
        - 0
        - 1
        - 2
      hidden_size:
        min: "0"
        max: "=pinf"
      num_heads:
        min: "0"
        max: "=pinf"
      has_mask:
        - 0
        - 1
      dq_probs:
        min: "0"
        max: "=pinf"
    attribute_constraints:
      - "num_heads * k == hidden_size"
    attributes_required:
      - type_id
      - hidden_size
      - num_heads
      - has_mask
    golden_io_path: "plugin/CustomQKVToContextPluginDynamic_PluginGoldenIO.json"
    abs_tol: 1e-5
    rel_tol: 1e-5
    fp16_atol: 1e-2
    fp16_rtol: 1e-2
    configs:
      config1:
        input_types:
          input: float16
        attribute_options:
          type_id:
            value: 1
            shape: "1"
          hidden_size:
            value: 768
            shape: "1"
          num_heads:
            value: 12
            shape: "1"
          has_mask:
            value: 0
            shape: "1"
        output_types:
          output: float16
      config2:
        input_types:
          input: float16
        attribute_options:
          type_id:
            value: 1
            shape: "1"
          hidden_size:
            value: 1024
            shape: "1"
          num_heads:
            value: 16
            shape: "1"
          has_mask:
            value: 0
            shape: "1"
        output_types:
          output: float16
      config5:
        input_types:
          input: float16
        attribute_options:
          type_id:
            value: 1
            shape: "1"
          hidden_size:
            value: 384
            shape: "1"
          num_heads:
            value: 12
            shape: "1"
          has_mask:
            value: 0
            shape: "1"
        output_types:
          output: float16
      has_mask:
        input_types:
          input: float32
          input_mask: int32
        attribute_options:
          type_id:
            value: 0
            shape: "1"
          hidden_size:
            value: 3
            shape: "1"
          num_heads:
            value: 3
            shape: "1"
          has_mask:
            value: 1
            shape: "1"
        output_types:
          output: float32
  "5":
    inputs:
      - input
      - input_mask
    outputs:
      - output
    input_dims:
      input: 5
      input_mask: 1
    output_dims:
      output: "input_0, input_mask_0, hidden_size_0, 1, 1"
    attributes:
      - type_id
      - hidden_size
      - num_heads
      - has_mask
      - dq_probs
      - var_seqlen
      - use_int8_scale_max
    attribute_types:
      type_id: int32
      hidden_size: int32
      num_heads: int32
      has_mask: int32
      dq_probs: float32
      var_seqlen: int32
      use_int8_scale_max: int32
    attribute_length:
      type_id: 1
      hidden_size: 1
      num_heads: 1
      has_mask: 1
      dq_probs: 1
      var_seqlen: 1
      use_int8_scale_max: 1
    attribute_options:
      type_id:
        - 0
        - 1
        - 2
      hidden_size:
        min: "0"
        max: "=pinf"
      num_heads:
        min: "0"
        max: "=pinf"
      has_mask:
        - 0
        - 1
      dq_probs:
        min: "0"
        max: "=pinf"
      use_int8_scale_max:
        - 0
        - 1
      var_seqlen:
        - 0
        # - 1 # Disabled since SM specific tests are not supported yet
    attributes_required:
      - type_id
      - hidden_size
      - num_heads
      - has_mask

  # "3": #version3 - Not supported yet
...
