How to use Glow

tkg.rahul: <p>Hi Everyone,</p>
<p>I am new to Glow and PyTorch (trying to learn both). I have trained a very simple Neural network based classifier in PyTorch(C++). I want to do inferencing on PI3 and want to take advantage of glow. Requesting you to please let me know what all steps I need to follow to achieve this.</p>
<p>While checking example/mnist.cpp I observed that training, testing and validation is done using glow, however I was under the impression that glow has inference support only?</p>
<p>Is there any example where glow is applied on computational graph?</p>
<p>Thanks</p>

jfix: <blockquote>
<p>I am new to Glow and PyTorch (trying to learn both). I have trained a very simple Neural network based classifier in PyTorch(C++). I want to do inferencing on PI3 and want to take advantage of glow. Requesting you to please let me know what all steps I need to follow to achieve this.</p>
</blockquote>
<p>I think the best way here would be to use our AOT executable bundles, see <a href="https://github.com/pytorch/glow/blob/master/docs/AOT.md" rel="noopener nofollow ugc">here</a> for more info.</p>
<blockquote>
<p>While checking example/mnist.cpp I observed that training, testing and validation is done using glow, however I was under the impression that glow has inference support only?</p>
</blockquote>
<p>Glow supports training to some extent – we support autograd and execution of many grad ops. However we have focused much more on inference.</p>
<blockquote>
<p>Is there any example where glow is applied on computational graph?</p>
</blockquote>
<p>Not sure what you’re asking about specifically here – you can find lots of simple examples of computational graphs we build directly in Glow IR in our <a href="https://github.com/pytorch/glow/blob/master/tests/unittests/OperatorTest.cpp" rel="noopener nofollow ugc"><code>OperatorTest.cpp</code></a>.</p>

tkg.rahul: <aside class="quote no-group" data-username="jfix" data-post="2" data-topic="96388">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jfix/48/21510_2.png" class="avatar"> jfix:</div>
<blockquote>
<p>Not sure what you’re asking about specifically here – you can find lots of simple examples of computational graphs we build directly in Glow IR in our <a href="https://github.com/pytorch/glow/blob/master/tests/unittests/OperatorTest.cpp" rel="noopener nofollow ugc"> <code>OperatorTest.cpp</code> </a>.</p>
</blockquote>
</aside>
<p>Thanks for the response <a class="mention" href="/u/jfix">@jfix</a>. I will check OperatorTest.cpp.<br>
Originally I wanted to know if there is any example which takes a pre trained model and converts this to computational graphs for which glow optimisation can be applied.<br>
Trained Model → computational graph → glow optimisation → binary</p>
<p>Apologies in advance if again I have confused you.</p>

jfix: <p>So a lot of Glow’s focus is on computational graphs, we use a Node-based Graph representation as our high level IR, and that is what we focus much of our optimizations on (GraphOptimizer.cpp). In OperatorTest.cpp you can find many such graphs that we build and run – they haven’t been trained on real models, it’s more for unit test and general functionality. For real models, we have e.g. many CV examples that are run through the <code>image-classifier</code> tool. For many of these you can take the Function in the code and run e.g. <code>function-&gt;dumpDAG("graph.dot")</code>, and then use that <a href="https://en.wikipedia.org/wiki/DOT_(graph_description_language)" rel="nofollow noopener">dot file</a> to visualize the graph. Hope this helps.</p>