Heavy log crashes the iOS app when running Pytorch model on iOS

Tan-Anh: <p>Hello everyone. Recently I have learned to export pytorch model (either by torch,jit.trace or torch.jit.script) into a .pt file for android and iOS. The model ran well with no logging on linux or android. But on iOS it generates <strong>145MB</strong> worth of .txt log that starts with:<br>
<strong>[W TensorImpl.h:1408] Warning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (function operator())</strong><br>
the remaining of the log is filled with odd symbols, such as:<br>
<code>\321   \322   \323   \324   \325   \326   \327   \330   \331   \332   \333   \334   \335   \336   \337   \340   \341   \342   \343   \344   \345   \346   \347   \350   \351   \352   \353   \354   \355   \356   \357   \360   \361   \362   \363   \364   \365   \366   \367   \370   \371   \372   \373   \374   \375   \376   \377                                                                                       \377\377\377\377\377\377\377\377C                                     _\363 \377  \213\363 \377  \226\363 \377  \364 \377  7\364 \377  \360      RuneMagANONE                                            \375\377                              B  B   B   B   B                                                         @  (  (  (  (  (  (  (  (  (  (  (  (  (  (  (         a  	  (  (  (  (  (  (  (  \211 \211 \211  \211 \211 \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  \211  (  (  (  (  (  (                                                  (  (  (  (                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          a      	                                                        e                   !   "   #   $   %   &amp;   '   (   )   *   +   ,   -   .   /   0   1   2   3   4   5   6   7   8   9   :   ;   &lt;   =   &gt;   ?   @   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z   [   \   ]   ^   _   `   a   b   c   d   e   f   g   h   i   j   k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z   {   |   }   ~      \200   \201   \202   \203   \204   \205   \206   \207   \210   \211   \212   \213   \214   \215   \216   \217   \220   \221   \222   \223   \224   \225   \226   \227   \230   \231   \232   \233   \234   \235   \236   \237   \240   \241   \242   \243   \244   \245   \246   \247   \250   \251   \252   \253   \254   \255   \256   \257   \260   \261   \262   \263   \264   \265   \266   \267   \270   \271   \272   \273   \274   \275   \276   \277   \300   \301   \302   \303   \304   \305   \306   \307   \310   \311   \312   \313   \314   \315   \316   \317   \320   \321   \322   \323   \324   \325   \326   \327   \330   \331   \332   \333   \334   \335   \336   \337   \340   \341   \342   \343   \344   \345   \346   \347   \350   \351   \352   \353   \354   \355   \356   \357   \360   \361   \362   \363   \364   \365   \366   \367   \370   \371   \372   \373   \374   \375   \376   \377                         a                                             e                   !   "   #   $   %   &amp;   '   (   )   *   +   ,   -   .   /   0   1   2   3   4   5   6   7   8   9   :   ;   &lt;   =   &gt;   ?   @   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z   [   \   ]   ^   _   `   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z   {   |   }   ~      \200    </code><br>
, so much so that the log .txt file is <strong>145MB</strong>, which sometimes crashes the app. I have used the latest Pytorch version but this warning still appears.<br>
Does anyone know how to avoid this log on iOS device?</p>

Linbin: <p>You could try:</p>
<ol>
<li>avoid using named tensor in your model, as it suggested.</li>
<li>add this guard before any pytorch API in iOS</li>
</ol>
<pre><code class="lang-auto">c10::Warning::WarnAlways guard(false);
</code></pre>

Tan-Anh: <p>Thank you. I will look more into this.<br>
Can you explain how to find out if the variable used in iOS is a named tensor or not?<br>
Do you know what the main part of the log (the numbers, characters and signs,…) is, beside the Warning? Where do they come from?</p>

Linbin: <p>for named tensor, see <a href="https://pytorch.org/docs/stable/named_tensor.html" class="inline-onebox" rel="noopener nofollow ugc">Named Tensors — PyTorch 1.10 documentation</a><br>
I don’t know where these logs came from.</p>