C++ extensions using AMD's MIOpen

username: yngtodd
cooked: <p>After taking a look at the <a href="https://pytorch.org/tutorials/advanced/cpp_extension.html" rel="nofollow noopener">C++ Extension guide</a>, I was wondering, is there a way to write C++ extensions for AMD’s <a href="https://github.com/ROCmSoftwarePlatform/MIOpen" rel="nofollow noopener">MIOpen</a> library?</p>
<p>Normally, I would use the following to write add in some custom CUDA bit:</p>
<pre><code class="lang-auto">from torch.utils.cpp_extension import BuildExtension, CUDAExtension
</code></pre>
<p>How difficult would it be to add something like a <code>MIOpenExtension</code>? If this would be cumbersome, would the developers recommend using the C++ frontend to interact with custom AMD accelerator kernels?</p>
<p>Thanks!</p>

username: tom
cooked: <p>I think the idea is that one would re-use the CUDAExtension.<br>
There is a patch regarding CUDAExtensions on ROCm (it seems to be stalled but you could use locally, probably, and it would seem to be a relatively future-proof way) :</p>
<aside class="onebox githubpullrequest">
  <header class="source">
      <a href="https://github.com/pytorch/pytorch/pull/22091" target="_blank" rel="nofollow noopener">github.com/pytorch/pytorch</a>
  </header>
  <article class="onebox-body">
    <div class="github-row">
  <div class="github-icon-container" title="Pull Request">
    <svg width="60" height="60" class="github-icon" viewbox="0 0 12 16" aria-hidden="true"><path d="M11 11.28V5c-.03-.78-.34-1.47-.94-2.06C9.46 2.35 8.78 2.03 8 2H7V0L4 3l3 3V4h1c.27.02.48.11.69.31.21.2.3.42.31.69v6.28A1.993 1.993 0 0 0 10 15a1.993 1.993 0 0 0 1-3.72zm-1 2.92c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zM4 3c0-1.11-.89-2-2-2a1.993 1.993 0 0 0-1 3.72v6.56A1.993 1.993 0 0 0 2 15a1.993 1.993 0 0 0 1-3.72V4.72c.59-.34 1-.98 1-1.72zm-.8 10c0 .66-.55 1.2-1.2 1.2-.65 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"></path></svg>
  </div>

  <div class="github-info-container">
    <h4>
      <a href="https://github.com/pytorch/pytorch/pull/22091" target="_blank" rel="nofollow noopener">[ROCm] Initial port of CUDAExtensions to HIP</a>
    </h4>

    <div class="branches">
      <code>pytorch:master</code> ← <code>iotamudelta:feature_extensions</code>
    </div>

    <div class="github-info">
      <div class="date">
        opened <span class="discourse-local-date" data-format="ll" data-date="2019-06-21" data-time="22:02:21" data-timezone="UTC">10:02PM - 21 Jun 19 UTC</span>
      </div>

      <div class="user">
        <a href="https://github.com/iotamudelta" target="_blank" rel="nofollow noopener">
          <img alt="iotamudelta" src="https://avatars2.githubusercontent.com/u/12565466?v=4" class="onebox-avatar-inline" width="20" height="20">
          iotamudelta
        </a>
      </div>

      <div class="lines" title="6 commits changed 1 files with 22 additions and 8 deletions">
        <a href="https://github.com/pytorch/pytorch/pull/22091/files" target="_blank" rel="nofollow noopener">
          <span class="added">+22</span>
          <span class="removed">-8</span>
        </a>
      </div>
    </div>

  </div>
</div>
  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>Best regards</p>
<p>Thomas</p>

username: yngtodd
cooked: <p>Oh, I hadn’t seen that! Thanks, <a class="mention" href="/u/tom">@tom</a>, that is great.</p>