Interesting use of xtensor with libtorch

dambo: <p>Hello,<br>
I have bumped into this repo:<br>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://github.githubassets.com/favicon.ico" class="site-icon" width="16" height="16">
      <a href="https://github.com/YeeCY/SMPLpp/" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars1.githubusercontent.com/u/40682795?s=400&amp;amp;v=4" class="thumbnail onebox-avatar" width="60" height="60">

<h3><a href="https://github.com/YeeCY/SMPLpp/" target="_blank" rel="nofollow noopener">YeeCY/SMPLpp</a></h3>

<p>C++ Implementation of SMPL: A Skinned Multi-Person Linear Model - YeeCY/SMPLpp</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
<br>
It uses xtensor for the dataflow from numpy to a C++ tensor to a libtorch tensor:<br>
<aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/YeeCY/SMPLpp/blob/ab221f34957d5a6001bd29bba402ee2aa8e7d9ab/SMPL%2B%2B/src/smpl/SMPL.cpp" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/YeeCY/SMPLpp/blob/ab221f34957d5a6001bd29bba402ee2aa8e7d9ab/SMPL%2B%2B/src/smpl/SMPL.cpp" target="_blank" rel="nofollow noopener">YeeCY/SMPLpp/blob/ab221f34957d5a6001bd29bba402ee2aa8e7d9ab/SMPL++/src/smpl/SMPL.cpp</a></h4>
<pre><code class="lang-cpp">/* ========================================================================= *
 *                                                                           *
 *                                 SMPL++                                    *
 *                    Copyright (c) 2018, Chongyi Zheng.                     *
 *                          All Rights reserved.                             *
 *                                                                           *
 * ------------------------------------------------------------------------- *
 *                                                                           *
 * This software implements a 3D human skinning model - SMPL: A Skinned      *
 * Multi-Person Linear Model with C++.                                       *
 *                                                                           *
 * For more detail, see the paper published by Max Planck Institute for      *
 * Intelligent Systems on SIGGRAPH ASIA 2015.                                *
 *                                                                           *
 * We provide this software for research purposes only.                      *
 * The original SMPL model is available at http://smpl.is.tue.mpg.           *
 *                                                                           *
 * ========================================================================= */

//=============================================================================
</code></pre>

  This file has been truncated. <a href="https://github.com/YeeCY/SMPLpp/blob/ab221f34957d5a6001bd29bba402ee2aa8e7d9ab/SMPL%2B%2B/src/smpl/SMPL.cpp" target="_blank" rel="nofollow noopener">show original</a>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
</p>
<pre><code class="lang-auto">// transformer
        xt::xarray&lt;int64_t&gt; kinematicTree;
        xt::from_json(m__model["kinematic_tree"], kinematicTree);
        m__kinematicTree = torch::from_blob(kinematicTree.data(),
            {2, JOINT_NUM}, torch::kInt64).to(m__device);// (2, 24)
</code></pre>

Shisho_Sama: <p>This could be very helpful, but I wonder why he would need to use xtensor when he is already using libtorch. basically nearly all numpy functions are either directlty implemented in libtorch or can be easily implemented using existing functionalities.<br>
I myself faced some conflicts couple of months ago when I tried to use both of them in a project and ultimately I gave up on xtensor and went full libtorch and I havent looked back.</p>

Abrar_Zahin_Shahriar: <p>What was the reason for not using xtensor?</p>