<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/146760>146760</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir][amdgpu][docs] Add op examples to dialect docs
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kuhar
      </td>
    </tr>
</table>

<pre>
    The amdgpu dialect docs contain op description and auto-generated syntax but not actual examples. We should improve dialect documentation by adding an example(s) for each op.

Other dialects like [arith](https://mlir.llvm.org/docs/Dialects/ArithOps/) or [SPIR-V](https://mlir.llvm.org/docs/Dialects/SPIR-V/) can be referenced for inspiration on how to provide examples, e.g.:

> Example:
> ```mlir
> // Scalar addition.
> %a = arith.addi %b, %c : i64

> // Scalar addition with overflow flags.
> %a = arith.addi %b, %c overflow<nsw, nuw> : i64

> // SIMD vector element-wise addition.
> %f = arith.addi %g, %h : vector<4xi32>

> // Tensor element-wise addition.
> %x = arith.addi %y, %z : tensor<4x?xi8>
> ```

We should be able to extract examples by looking at op tests in https://github.com/llvm/llvm-project/blob/main/mlir/test/Dialect/AMDGPU/ops.mlir
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVE2P2zYQ_TXUZbACRUr-OOjgrFdFDkGCJm3PFDmS2KVJgaRsb399QfpjE8AI0gIGLAw57808vhkRgh4tYkuaD6TZF2KJk_Pt6zIJX_ROvbXfJgRxUOO8gNLCoIygnAwgnY1CW3AzKAzS6zlqZ0FYBWKJ7mlEi15EVBDebBRn6JcI1kUQMi7CAJ7FYTYYSvgLIUxuMQr0YfbuiN8TLQe0UWTo_g2EUtqOIOwtnbBNIGwLg_OAQk7g5pLQHaG7z3FCf0MKYPQrAmk-CK_jRJo9YZspxjkQviOsI6w7GO1LY46H0vmRsC41SVi3vwIQ1u1S6uc55PtbcD7hff3y8fenP_8f4DX3AieFhR7B44AerUSVe9I2zNpf-ncWJneC6CCppBXeNSTsGbAcy8Sdmyf8BV6uCvFbgKzo5Zcqu8VyqfBVCiN8ljdRlffTRgDhe8iqlek4xfrER1gjgfAd6FV9u_4zTDjpOIE7oh-MO8FgxBh-meeWRvizDacUtsspZ_6sgI-f9nBEGZM3DCYjPZ10wEdtDg_oxyv9lFkuQIQ_12fNGeEvDzm_oQ2_QHd-QPd2pfsn08UMlOkI78568x3j7R0vb_0-Pj2C6A0mh-A5eiHj3SFpeIxzr3l6YhraiCEG0BZ-dO2o47T0pXQHwrrk3uvf0-zd3ygjYV1vXJ_8LbS92pywLsG9uztNy6f9b1_-IKxzcyjTpUK1XG35VhTYVuumqje82m6KqR3UukKGw4o367puUFQoq0Fu6WpVs0o2hW4ZZQ1dU1Zt6YqvS9psKkopW_NBbBVlpKZ4ENrcx63QISzYVvVqvaKFET2akFccY5d6WVp2vs2d9csYSE2NDjG8I0QdTV6LOaHZp92R1-DlO09zs4edUknNu87R_bAmi8Wb9j8rnKtPG-LawLFl_wYAAP__l07D_w">