code: def matmul_4d_kernel(
      # Pointers to matrices
      a_ptr,
      b_ptr,
      c_ptr,
      # Matrix dimensions
      M,
      N,
      K,
      CACHE_M,
      CACHE_N,
      CACHE_K,
      stride_ab,
      stride_ah,
      stride_am,
      stride_ak,
      stride_bb,
      stride_bh,
      stride_bk,
      stride_bn,
      stride_cb,
      stride_ch,
      stride_cm,
      stride_cn,
      scale,
      # Meta-parameters
      BLOCK_SIZE_M: tl.constexpr,
      BLOCK_SIZE_N: tl.constexpr,
      BLOCK_SIZE_K: tl.constexpr,
      GROUP_SIZE_M: tl.constexpr,
      MASK: tl.constexpr,
  ):
      """Kernel for computing the matmul C = A x B.
      A has shape (M, K), B has shape (K, N) and C has shape (M, N)
      """
      pid = tl.program_id(axis=0)
      head = tl.program_id(axis=1)
      batch = tl.program_id(axis=2)
      num_pid_m = tl.cdiv(M, BLOCK_SIZE_M)
      num_pid_n = tl.cdiv(N, BLOCK_SIZE_N)
      num_pid_in_group = GROUP_SIZE_M * num_pid_n
      group_id = pid // num_pid_in_group
      first_pid_m = group_id * GROUP_SIZE_M
      group_size_m = min(num_pid_m - first_pid_m, GROUP_SIZE_M)
      pid_m = first_pid_m + (pid % group_size_m)
      pid_n = (pid % num_pid_in_group) // group_size_m
  
      if MASK:
          if (pid_m + 1) * BLOCK_SIZE_M - 1 < pid_n * BLOCK_SIZE_N:
              c = tl.zeros(
                  (BLOCK_SIZE_M, BLOCK_SIZE_N),
                  dtype=c_ptr.dtype.element_ty,
              ) - float("inf")
              offs_cm = pid_m * BLOCK_SIZE_M + tl.arange(
                  0, BLOCK_SIZE_M
              )
              offs_cn = pid_n * BLOCK_SIZE_N + tl.arange(
                  0, BLOCK_SIZE_N
              )
              c_ptrs = (
                  c_ptr
                  + batch * stride_cb
                  + head * stride_ch
                  + stride_cm * offs_cm[:, None]
                  + stride_cn * offs_cn[None, :]
              )
              tl.store(c_ptrs, c)
              return
  
      offs_am = pid_m * BLOCK_SIZE_M + tl.arange(0, BLOCK_SIZE_M)
      offs_bn = pid_n * BLOCK_SIZE_N + tl.arange(0, BLOCK_SIZE_N)
      offs_k = tl.arange(0, BLOCK_SIZE_K)
      a_ptrs = (
          a_ptr
          + batch * stride_ab
          + head * stride_ah
          + (offs_am[:, None] * stride_am + offs_k[None, :] * stride_ak)
      )
      b_ptrs = (
          b_ptr
          + batch * stride_bb
          + head * stride_bh
          + (offs_k[:, None] * stride_bk + offs_bn[None, :] * stride_bn)
      )
  
      accumulator = tl.zeros(
          (BLOCK_SIZE_M, BLOCK_SIZE_N), dtype=tl.float32
      )
      for k in range(0, K, BLOCK_SIZE_K):
          a_mask = (offs_am[:, None] < M) & (offs_k[None, :] + k < K)
          b_mask = (offs_k[:, None] + k < K) & (offs_bn[None, :] < N)
          a = tl.load(a_ptrs, mask=a_mask, other=0.0)
          b = tl.load(b_ptrs, mask=b_mask, other=0.0)
          accumulator += tl.dot(a, b)
          a_ptrs += BLOCK_SIZE_K * stride_ak
          b_ptrs += BLOCK_SIZE_K * stride_bk
  
      c = accumulator.to(c_ptr.dtype.element_ty)
      if scale > 0:
          c = c * scale.to(c_ptr.dtype.element_ty)
  
      offs_cm = pid_m * BLOCK_SIZE_M + tl.arange(0, BLOCK_SIZE_M)
      offs_cn = pid_n * BLOCK_SIZE_N + tl.arange(0, BLOCK_SIZE_N)
      if MASK:
          c += tl.where(
              offs_cm[:, None] >= offs_cn[None, :], 0, float("-inf")
          )
      c_ptrs = (
          c_ptr
          + batch * stride_cb
          + head * stride_ch
          + stride_cm * offs_cm[:, None]
          + stride_cn * offs_cn[None, :]
      )
      c_mask = (offs_cm[:, None] < M) & (offs_cn[None, :] < N)
      tl.store(c_ptrs, c, mask=c_mask)
  
file_path: deepspeed/deepspeed/ops/transformer/inference/triton/triton_matmul_kernel.py
imports: import triton
  import triton.language
  from .gelu import gelu_functor
  import torch
label_desc: Use image node_id 5 for calling a global function with example usage: matmul_4d_kernel(a_ptr, b_ptr, c_ptr, M, N, K, CACHE_M, CACHE_N, CACHE_K, stride_ab, stride_ah, stride_am, stride_ak, stride_bb, stride_bh, stride_bk, stride_bn, stride_cb, stride_ch, stride_cm, stride_cn, scale, BLOCK_SIZE_M, BLOCK_SIZE_N, BLOCK_SIZE_K, GROUP_SIZE_M, MASK) without return types