---
include: rocblas_common.yaml
include: known_bugs.yaml

Definitions:
  - &small_matrix_size_range
    - { M:    -1, N:    -1, K:    -1, lda:    -1, ldb:     1, ldc:     1, ldd:     1 }
    - { M:     8, N:     9, K:    10, lda:     8, ldb:    10, ldc:     8, ldd:     8 }
    - { M:     4, N:     3, K:     4, lda:     4, ldb:     4, ldc:     4, ldd:     4 }
    - { M:     3, N:     3, K:     3, lda:     3, ldb:     3, ldc:     3, ldd:     3 }
    - { M:     4, N:     4, K:     4, lda:     4, ldb:     4, ldc:     5, ldd:     5 }
    - { M:     8, N:     8, K:     8, lda:     8, ldb:     8, ldc:     8, ldd:     8 }
    - { M:    15, N:    15, K:    15, lda:    15, ldb:    15, ldc:    15, ldd:    15 }
    - { M:    16, N:    16, K:    16, lda:    16, ldb:    16, ldc:    16, ldd:    16 }
    - { M:    17, N:    17, K:    17, lda:    17, ldb:    17, ldc:    17, ldd:    17 }
    - { M:    31, N:    33, K:    35, lda:   101, ldb:   102, ldc:   103, ldd:   103 }
    - { M:    59, N:    61, K:    63, lda:   129, ldb:   131, ldc:   137, ldd:   137 }
    - { M:    63, N:    63, K:    63, lda:    63, ldb:    63, ldc:    63, ldd:    63 }
    - { M:    64, N:    64, K:    64, lda:    64, ldb:    64, ldc:    64, ldd:    64 }
    - { M:    65, N:    65, K:    65, lda:    65, ldb:    65, ldc:    65, ldd:    65 }
    - { M:   127, N:   127, K:   127, lda:   127, ldb:   127, ldc:   127, ldd:   127 }
    - { M:   128, N:   128, K:   128, lda:   128, ldb:   128, ldc:   128, ldd:   128 }
    - { M:   129, N:   129, K:   129, lda:   129, ldb:   129, ldc:   129, ldd:   129 }

  - &medium_matrix_size_range
    - { M:   129, N:   130, K:   131, lda:   132, ldb:   133, ldc:   134, ldd:   134 }
    - { M:   255, N:   255, K:   255, lda:   255, ldb:   255, ldc:   255, ldd:   255 }
    - { M:   256, N:   256, K:   256, lda:   256, ldb:   256, ldc:   256, ldd:   256 }
    - { M:   257, N:   257, K:   257, lda:   257, ldb:   257, ldc:   257, ldd:   257 }
    - { M:   501, N:   502, K:   103, lda:   504, ldb:   605, ldc:   506, ldd:   506 }

  - &large_matrix_size_range
    - { M:   511, N:   511, K:   511, lda:   511, ldb:   511, ldc:   511, ldd:   511 } 
    - { M:   512, N:   512, K:   512, lda:   512, ldb:   512, ldc:   512, ldd:   512 } 
    - { M:   513, N:   513, K:   513, lda:   513, ldb:   513, ldc:   513, ldd:   513 } 
    - { M:   513, N:   514, K:   515, lda:   516, ldb:   517, ldc:   518, ldd:   518 } 

  - &deepbench_vec
    - { M: 12544, N:    64, K:    64, lda: 12544, ldb:    64, ldc: 12544, ldd: 12544 }
    - { M:  3136, N:   256, K:    64, lda:  3136, ldb:    64, ldc:  3136, ldd:  3136 }
    - { M:  3136, N:    64, K:   256, lda:  3136, ldb:   256, ldc:  3136, ldd:  3136 }
    - { M:   784, N:   128, K:   512, lda:   784, ldb:   512, ldc:   784, ldd:   784 }
    - { M:   784, N:   512, K:   128, lda:   784, ldb:   128, ldc:   784, ldd:   784 }
    - { M:   784, N:    64, K:   192, lda:   784, ldb:   192, ldc:   784, ldd:   784 }
    - { M:   196, N:  1024, K:   256, lda:   196, ldb:  1024, ldc:   196, ldd:   196 }
    - { M:   196, N:   256, K:  1024, lda:   196, ldb:   256, ldc:   196, ldd:   196 }
    - { M:   196, N:   256, K:   256, lda:   196, ldb:   256, ldc:   196, ldd:   196 }
    - { M:   196, N:   512, K:   192, lda:   196, ldb:   512, ldc:   196, ldd:   196 }
    - { M:  3136, N:   256, K:    64, lda:  3136, ldb:   256, ldc:  3136, ldd:  3136 }
    - { M:  3136, N:    64, K:   256, lda:  3136, ldb:    64, ldc:  3136, ldd:  3136 }
    - { M:    49, N:  2048, K:   512, lda:    49, ldb:  2048, ldc:    49, ldd:    49 }
    - { M:    49, N:   512, K:  2048, lda:    49, ldb:   512, ldc:    49, ldd:    49 }
    - { M:    49, N:   512, K:   512, lda:    49, ldb:   512, ldc:    49, ldd:    49 }
    - { M:    49, N:   832, K:   256, lda:    49, ldb:   832, ldc:    49, ldd:    49 }
    - { M:   784, N:   128, K:   512, lda:   784, ldb:   128, ldc:   784, ldd:   784 }
    - { M:   784, N:   192, K:    64, lda:   784, ldb:   192, ldc:   784, ldd:   784 }
    - { M:   784, N:   512, K:   128, lda:   784, ldb:   512, ldc:   784, ldd:   784 }

  - &conv_resnet50_fwd
    - { M:  3025, N:    64, K:   256, lda:  3025, ldb:   256, ldc:  3025, ldd:  3025 }
    - { M:  3025, N:   256, K:    64, lda:  3025, ldb:    64, ldc:  3025, ldd:  3025 }

  - &conv_resnet50_bwddata
    - { M:  3025, N:   256, K:    64, lda:  3025, ldb:   256, ldc:  3025, ldd:  3025 }
    - { M:  3025, N:    64, K:   256, lda:  3025, ldb:    64, ldc:  3025, ldd:  3025 }
    - { M:  3025, N:    64, K:    64, lda:  3025, ldb:    64, ldc:  3025, ldd:  3025 }
    - { M:  3136, N:    64, K:    64, lda:  3136, ldb:    64, ldc:  3136, ldd:  3136 }

  - &conv_inception4_fwd
    - { M:  1225, N:   192, K:   384, lda:  1225, ldb:   384, ldc:  1225, ldd:  1225 }
    - { M:  1225, N:    64, K:   384, lda:  1225, ldb:   384, ldc:  1225, ldd:  1225 }
    - { M:  1225, N:    96, K:   384, lda:  1225, ldb:   384, ldc:  1225, ldd:  1225 }
    - { M:   289, N:   128, K:  1024, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:   289, N:   192, K:  1024, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:   289, N:   256, K:  1024, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:   289, N:   384, K:  1024, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:  5329, N:    64, K:   160, lda:  5329, ldb:   160, ldc:  5329, ldd:  5329 }

  - &conv_inception4_bwddata
    - { M:  1225, N:   384, K:   192, lda:  1225, ldb:   384, ldc:  1225, ldd:  1225 }
    - { M:  1225, N:   384, K:    64, lda:  1225, ldb:   384, ldc:  1225, ldd:  1225 }
    - { M:  1225, N:   384, K:    96, lda:  1225, ldb:   384, ldc:  1225, ldd:  1225 }
    - { M:   289, N:  1024, K:   128, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:   289, N:  1024, K:   192, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:   289, N:  1024, K:   256, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:   289, N:  1024, K:   384, lda:   289, ldb:  1024, ldc:   289, ldd:   289 }
    - { M:  5329, N:   160, K:    64, lda:  5329, ldb:   160, ldc:  5329, ldd:  5329 }
    - { M:    64, N:  1536, K:   256, lda:    64, ldb:  1536, ldc:    64, ldd:    64 }
    - { M:    64, N:  1536, K:   384, lda:    64, ldb:  1536, ldc:    64, ldd:    64 }

  - &conv_ctest_bwddata
    - { M:   121, N:  2048, K:     1, lda:   121, ldb:  2048, ldc:   121, ldd:   121 }
    - { M: 12544, N:    64, K:     1, lda: 12544, ldb:    64, ldc: 12544, ldd: 12544 }
    - { M:   144, N:  1024, K:     1, lda:   144, ldb:  1024, ldc:   144, ldd:   144 }
    - { M:   144, N:   256, K:     1, lda:   144, ldb:   256, ldc:   144, ldd:   144 }
    - { M:   144, N:   512, K:     1, lda:   144, ldb:   512, ldc:   144, ldd:   144 }
    - { M:   169, N:   256, K:     1, lda:   169, ldb:   256, ldc:   169, ldd:   169 }
    - { M:    16, N:   512, K:     1, lda:    16, ldb:   512, ldc:    16, ldd:    16 }
    - { M:    16, N:   528, K:     1, lda:    16, ldb:   528, ldc:    16, ldd:    16 }
    - { M:    16, N:   576, K:     1, lda:    16, ldb:   576, ldc:    16, ldd:    16 }
    - { M:    16, N:   608, K:     1, lda:    16, ldb:   608, ldc:    16, ldd:    16 }
    - { M:   196, N:   128, K:     1, lda:   196, ldb:   128, ldc:   196, ldd:   196 }
    - { M:   196, N:   192, K:     1, lda:   196, ldb:   192, ldc:   196, ldd:   196 }
    - { M:   196, N:   256, K:     1, lda:   196, ldb:   256, ldc:   196, ldd:   196 }
    - { M:   196, N:   480, K:     1, lda:   196, ldb:   480, ldc:   196, ldd:   196 }
    - { M:   196, N:   512, K:     1, lda:   196, ldb:   512, ldc:   196, ldd:   196 }
    - { M:   196, N:   528, K:     1, lda:   196, ldb:   528, ldc:   196, ldd:   196 }
    - { M:   196, N:   576, K:     1, lda:   196, ldb:   576, ldc:   196, ldd:   196 }
    - { M:   196, N:   608, K:     1, lda:   196, ldb:   608, ldc:   196, ldd:   196 }
    - { M:   196, N:    64, K:     1, lda:   196, ldb:    64, ldc:   196, ldd:   196 }
    - { M:  3136, N:   128, K:     1, lda:  3136, ldb:   128, ldc:  3136, ldd:  3136 }
    - { M:  3136, N:   256, K:     1, lda:  3136, ldb:   256, ldc:  3136, ldd:  3136 }
    - { M:  3136, N:    64, K:     1, lda:  3136, ldb:    64, ldc:  3136, ldd:  3136 }
    - { M: 32768, N:   480, K:     1, lda: 32768, ldb:   480, ldc: 32768, ldd: 32768 }
    - { M:    49, N:  1024, K:     1, lda:    49, ldb:  1024, ldc:    49, ldd:    49 }
    - { M:    49, N:  1056, K:     1, lda:    49, ldb:  1056, ldc:    49, ldd:    49 }
    - { M:    49, N:   192, K:     1, lda:    49, ldb:   192, ldc:    49, ldd:    49 }
    - { M:    49, N:   512, K:     1, lda:    49, ldb:   512, ldc:    49, ldd:    49 }
    - { M:    49, N:   832, K:     1, lda:    49, ldb:   832, ldc:    49, ldd:    49 }
    - { M:   729, N:    64, K:     1, lda:   729, ldb:    64, ldc:   729, ldd:   729 }
    - { M:   784, N:   128, K:     1, lda:   784, ldb:   128, ldc:   784, ldd:   784 }
    - { M:   784, N:   192, K:     1, lda:   784, ldb:   192, ldc:   784, ldd:   784 }
    - { M:   784, N:   256, K:     1, lda:   784, ldb:   256, ldc:   784, ldd:   784 }
    - { M:   784, N:   320, K:     1, lda:   784, ldb:   320, ldc:   784, ldd:   784 }
    - { M:   784, N:   512, K:     1, lda:   784, ldb:   512, ldc:   784, ldd:   784 }
    - { M:   784, N:    64, K:     1, lda:   784, ldb:    64, ldc:   784, ldd:   784 }
    - { M:  8192, N:   480, K:     1, lda:  8192, ldb:   480, ldc:  8192, ldd:  8192 }
    - { M:  8192, N:   512, K:     1, lda:  8192, ldb:   512, ldc:  8192, ldd:  8192 }
    - { M:  8192, N:   528, K:     1, lda:  8192, ldb:   528, ldc:  8192, ldd:  8192 }
    - { M:  8192, N:   832, K:     1, lda:  8192, ldb:   832, ldc:  8192, ldd:  8192 }

  - &conv_ctest_fwd
    - { M: 12544, N:     1, K:    64, lda: 12544, ldb:    64, ldc: 12544, ldd: 12544 }
    - { M:  3136, N:     1, K:   128, lda:  3136, ldb:   128, ldc:  3136, ldd:  3136 }
    - { M:  3136, N:     1, K:   256, lda:  3136, ldb:   256, ldc:  3136, ldd:  3136 }
    - { M:  3136, N:     1, K:    64, lda:  3136, ldb:    64, ldc:  3136, ldd:  3136 }
    - { M: 32768, N:     1, K:   480, lda: 32768, ldb:   480, ldc: 32768, ldd: 32768 }
    - { M:   729, N:     1, K:    64, lda:   729, ldb:    64, ldc:   729, ldd:   729 }
    - { M:   784, N:     1, K:   128, lda:   784, ldb:   128, ldc:   784, ldd:   784 }
    - { M:   784, N:     1, K:   192, lda:   784, ldb:   192, ldc:   784, ldd:   784 }
    - { M:   784, N:     1, K:   256, lda:   784, ldb:   256, ldc:   784, ldd:   784 }
    - { M:   784, N:     1, K:   320, lda:   784, ldb:   320, ldc:   784, ldd:   784 }
    - { M:   784, N:     1, K:   512, lda:   784, ldb:   512, ldc:   784, ldd:   784 }
    - { M:   784, N:     1, K:    64, lda:   784, ldb:    64, ldc:   784, ldd:   784 }
    - { M:  8192, N:     1, K:   480, lda:  8192, ldb:   480, ldc:  8192, ldd:  8192 }
    - { M:  8192, N:     1, K:   512, lda:  8192, ldb:   512, ldc:  8192, ldd:  8192 }
    - { M:  8192, N:     1, K:   528, lda:  8192, ldb:   528, ldc:  8192, ldd:  8192 }
    - { M:  8192, N:     1, K:   832, lda:  8192, ldb:   832, ldc:  8192, ldd:  8192 }

  - &transA_transB_range
    - { transA: N, transB: N }
    - { transA: N, transB: T }
    - { transA: C, transB: N }
    - { transA: T, transB: C }

  - &alpha_beta_range
    - { alpha:  1.0, beta:  0.0 }
    - { alpha: -2.0, beta: -3.0 }
    - { alpha:  0.0, beta:  1.0 }

  - &complex_alpha_beta_range
    - { alpha:  1, beta:  3, alphai:  3, betai:  1 }
    - { alpha: -1, beta: -3, alphai:  3, betai:  1 }


Tests:
- name: gemm_batched_bad_arg
  category: pre_checkin
  function:
    - gemm_batched_ex_bad_arg: *real_precisions
  transA: N
  transB: N

- name: gemm_batched_NaN
  category: pre_checkin
  function:
    - gemm_batched: *single_double_precisions
    - gemm_batched_ex: *single_double_precisions
  matrix_size: *small_matrix_size_range
  transA_transB: *transA_transB_range
  alpha: [ -1.0, 0.0, 1.0, 2.0 ]
  beta: .NaN  # converted to 0.0 in test code
  batch_count: [ 1, 3 ]

# TODO: Add int8 precisions by replacing *hpa_half_single_double_precisions with *real_precisions

- name: gemm_batched_small
  category: quick
  function:
    - gemm_batched: *half_single_double_precisions
    - gemm_batched_ex: *real_precisions
  matrix_size: *small_matrix_size_range
  alpha_beta: *alpha_beta_range
  transA_transB: *transA_transB_range
  batch_count: [ -1, 0, 1, 3 ]

- name: gemm_batched_small_complex
  category: quick
  function:
    gemm_batched: *single_double_precisions_complex
    gemm_batched_ex: *single_double_precisions_complex
  matrix_size: *small_matrix_size_range
  alpha_beta: *complex_alpha_beta_range
  transA_transB: *transA_transB_range
  batch_count: [ -1, 0, 1, 3 ]

- name: gemm_batched_medium
  category: pre_checkin
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *medium_matrix_size_range
  transA_transB: *transA_transB_range
  alpha_beta: *alpha_beta_range
  batch_count: [ -1, 0, 1, 3 ]

- name: gemm_batched_medium_complex
  category: pre_checkin
  function:
    gemm_batched: *single_double_precisions_complex
    gemm_batched_ex: *single_double_precisions_complex
  matrix_size: *medium_matrix_size_range
  transA_transB: *transA_transB_range
  alpha_beta: *complex_alpha_beta_range
  batch_count: [ -1, 0, 1, 3 ]

- name: gemm_batched_large
  category: pre_checkin
  function:
    - gemm_batched: *half_single_double_precisions
    - gemm_batched_ex: *half_single_double_precisions
  matrix_size: *large_matrix_size_range
  transA_transB: *transA_transB_range
  alpha_beta: *alpha_beta_range
  batch_count: [ -1, 0, 1, 3 ]

- name: gemm_batched_large_complex
  category: pre_checkin
  function:
    gemm_batched: *single_double_precisions_complex
    gemm_batched_ex: *single_double_precisions_complex
  matrix_size: *large_matrix_size_range
  transA_transB: *transA_transB_range
  alpha_beta: *alpha_beta_range
  batch_count: [ -1, 0, 1, 3 ]

- name: gemm_batched_deepbench
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *deepbench_vec
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: T
  batch_count: [ 2 ]

- name: gemm_batched_conv_resnet50_fwd
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *conv_resnet50_fwd
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: N
  batch_count: 4

- name: gemm_batched_conv_resnet50_bwddata
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *conv_resnet50_bwddata
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: T
  batch_count: 4

- name: gemm_batched_conv_inception4_fwd
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *conv_inception4_fwd
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: N
  batch_count: 4

- name: gemm_batched_conv_inception4_bwddata
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *conv_inception4_bwddata
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: T
  batch_count: 4

- name: gemm_batched_conv_ctest_bwddata
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *conv_ctest_bwddata
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: T
  batch_count: 1

- name: gemm_batched_conv_ctest_fwd
  category: nightly
  function:
    - gemm_batched: *half_single_precisions
    - gemm_batched_ex: *half_single_precisions
  matrix_size: *conv_ctest_fwd
  alpha: 1.0
  beta: 0.0
  transA: N
  transB: N
  batch_count: 1
...
