<p dir="auto">We currently use scientific notation (E-notation) to print large integer tensors. We shouldn't do this because it hides meaningful digits and because E-notation corresponds to floating point data types in Python.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; x = torch.ones(525076, dtype=torch.int)
&gt;&gt;&gt; x.sum()
tensor(5.2508e+05)
&gt;&gt;&gt; x.sum().item()
525076"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">torch</span>.<span class="pl-en">ones</span>(<span class="pl-c1">525076</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">torch</span>.<span class="pl-s1">int</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-en">sum</span>()
<span class="pl-en">tensor</span>(<span class="pl-c1">5.2508e+05</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-en">sum</span>().<span class="pl-en">item</span>()
<span class="pl-c1">525076</span></pre></div>
<h2 dir="auto"><g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji> Feature</h2>
<p dir="auto">It'd be great for developer productivity if file lists were shared among build systems.</p>
<h2 dir="auto">Motivation</h2>
<p dir="auto">We're maintaining 3 different build systems right now (CMake, two FB-internal flavors of Buck) and Bazel support is on the way - <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="587251362" data-permission-text="Title is private" data-url="https://github.com/pytorch/pytorch/issues/35316" data-hovercard-type="issue" data-hovercard-url="/pytorch/pytorch/issues/35316/hovercard" href="https://github.com/pytorch/pytorch/issues/35316">#35316</a> . Parts of buck build are exposed as <a href="https://github.com/pytorch/pytorch/blob/master/tools/build_variables.bzl">https://github.com/pytorch/pytorch/blob/master/tools/build_variables.bzl</a> . Today they duplicate lists of files manually (including upcoming <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="586429451" data-permission-text="Title is private" data-url="https://github.com/pytorch/pytorch/issues/35220" data-hovercard-type="pull_request" data-hovercard-url="/pytorch/pytorch/pull/35220/hovercard" href="https://github.com/pytorch/pytorch/pull/35220">#35220</a>). It's bad for developer productivity as it's easy to forget to add new file.</p>
<h2 dir="auto">Pitch</h2>
<p dir="auto">We could put the lists of files in a very simple format - just a text file with file names would do, or a very simple python program. All major build systems support importing external file lists. For buck/bazel it can be done by writing .bzl function and importing results.</p>
<p dir="auto">For CMake simple proof of concept is <a href="https://gist.github.com/dzhulgakov/8f6cc0a7fd710b8f29689ba5e5858f7d">https://gist.github.com/dzhulgakov/8f6cc0a7fd710b8f29689ba5e5858f7d</a></p>
<h2 dir="auto">Alternatives</h2>
<p dir="auto">Alternative is to use globs aggressively. It's not a full solution as we currently mix different targets in the same directory (e.g. python and no-python sources). And globs can be tricky with triggering incremental rebuilds correctly.</p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/kostmo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/kostmo">@kostmo</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/malfet/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/malfet">@malfet</a></p>