https://eigen.tuxfamily.org/index.php?title=Tensor_support&feed=atom&action=historyTensor support - Revision history2024-03-29T10:02:33ZRevision history for this page on the wikiMediaWiki 1.23.1https://eigen.tuxfamily.org/index.php?title=Tensor_support&diff=2114&oldid=prevBenoitsteiner: /* Supported features */2016-10-24T15:49:06Z<p><span dir="auto"><span class="autocomment">Supported features</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 15:49, 24 October 2016</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 21:</td>
<td colspan="2" class="diff-lineno">Line 21:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Contractions</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Contractions</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Parallelization over multiple CPU cores though multi-threading</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Parallelization over multiple CPU cores though multi-threading</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* Offloading of the computation to a CUDA GPU</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* Offloading of the computation to a CUDA GPU <ins class="diffchange diffchange-inline">or an OpenCL acccelerator.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The [https://bitbucket.org/eigen/eigen/src/default/unsupported/Eigen/CXX11/src/Tensor/README.md?fileviewer=file-view-default README] file contains a complete documentation of the module and its API.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>The [https://bitbucket.org/eigen/eigen/src/default/unsupported/Eigen/CXX11/src/Tensor/README.md?fileviewer=file-view-default README] file contains a complete documentation of the module and its API.</div></td></tr>
</table>Benoitsteinerhttps://eigen.tuxfamily.org/index.php?title=Tensor_support&diff=2018&oldid=prevBenoitsteiner: /* Known issues */2016-03-30T03:47:44Z<p><span dir="auto"><span class="autocomment">Known issues</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 03:47, 30 March 2016</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 82:</td>
<td colspan="2" class="diff-lineno">Line 82:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>== <del class="diffchange diffchange-inline">Known </del>issues ==</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== <ins class="diffchange diffchange-inline">Caveats and known </ins>issues ==</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* In order to run the tests for this module, one should specify <tt>-DEIGEN_TEST_CXX11=ON</tt>. <del class="diffchange diffchange-inline">But this currently contains a hack </del>to <del class="diffchange diffchange-inline">add </del><tt>-<del class="diffchange diffchange-inline">std</del>=<del class="diffchange diffchange-inline">c++0x</del></tt> to the <del class="diffchange diffchange-inline">compiler flags, which will not work for MSVC for example.</del></div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* In order to run the tests for this module, one should specify <tt>-DEIGEN_TEST_CXX11=ON</tt>. <ins class="diffchange diffchange-inline">Furthermore, one need </ins>to <ins class="diffchange diffchange-inline">specify </ins><tt>-<ins class="diffchange diffchange-inline">DEIGEN_TEST_NVCC</ins>=<ins class="diffchange diffchange-inline">ON</ins></tt> to <ins class="diffchange diffchange-inline">enable </ins>the <ins class="diffchange diffchange-inline">CUDA tests</ins>.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del class="diffchange diffchange-inline">* <tt>.setZero()</tt> uses <tt>memset()</tt> because packet access is not implemented yet. Unfortunately, this only works with POD types</del>.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Exploiting tensor symmetries ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Exploiting tensor symmetries ==</div></td></tr>
</table>Benoitsteinerhttps://eigen.tuxfamily.org/index.php?title=Tensor_support&diff=2017&oldid=prevBenoitsteiner: /* Supported features */2016-03-29T22:25:41Z<p><span dir="auto"><span class="autocomment">Supported features</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:25, 29 March 2016</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 23:</td>
<td colspan="2" class="diff-lineno">Line 23:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Offloading of the computation to a CUDA GPU</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* Offloading of the computation to a CUDA GPU</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>The [<del class="diffchange diffchange-inline">http</del>://bitbucket.org/eigen/eigen/src/<del class="diffchange diffchange-inline">3008d58b8f95b758738c61bdd29274e6eebedd77</del>/unsupported/Eigen/CXX11/src/Tensor/README.md?<del class="diffchange diffchange-inline">at=default&</del>fileviewer=file-view-default README] file contains a complete documentation of the module and its API.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>The [<ins class="diffchange diffchange-inline">https</ins>://bitbucket.org/eigen/eigen/src/<ins class="diffchange diffchange-inline">default</ins>/unsupported/Eigen/CXX11/src/Tensor/README.md?fileviewer=file-view-default README] file contains a complete documentation of the module and its API.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Using the Tensor module ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Using the Tensor module ==</div></td></tr>
</table>Benoitsteinerhttps://eigen.tuxfamily.org/index.php?title=Tensor_support&diff=2016&oldid=prevBenoitsteiner: /* Supported features */2016-03-29T22:16:30Z<p><span dir="auto"><span class="autocomment">Supported features</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 22:16, 29 March 2016</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 12:</td>
<td colspan="2" class="diff-lineno">Line 12:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Currently, the Tensor module only supports the following few features:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Currently, the Tensor module only supports the following few features:</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* basic storage for dynamic-sized objects</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* basic storage for dynamic-<ins class="diffchange diffchange-inline">sized and statically </ins>sized objects</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* setting to zero (<tt>.setZero()</tt>) for POD types</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* setting to zero (<tt>.setZero()</tt>) for POD types</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* simple assignments to other tensors of the same type</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* simple assignments to other tensors of the same type</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* getting the dimensionality of the tensor</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>* getting the dimensionality of the tensor</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Coefficient extraction and manipulation through slicing, shuffling, and more...</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Coefficient-wise operations (addition, subtraction, ...)</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Reductions</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Contractions</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Parallelization over multiple CPU cores though multi-threading</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">* Offloading of the computation to a CUDA GPU</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">The [http://bitbucket.org/eigen/eigen/src/3008d58b8f95b758738c61bdd29274e6eebedd77/unsupported/Eigen/CXX11/src/Tensor/README.md?at=default&fileviewer=file-view-default README] file contains a complete documentation of the module and its API.</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Using the Tensor module ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Using the Tensor module ==</div></td></tr>
</table>Benoitsteinerhttps://eigen.tuxfamily.org/index.php?title=Tensor_support&diff=1783&oldid=prevChristian Seiler: made link in the beginning look nicer, some typos2014-06-08T11:12:12Z<p>made link in the beginning look nicer, some typos</p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 11:12, 8 June 2014</td>
</tr><tr><td colspan="2" class="diff-lineno">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''IMPORTANT NOTE: The current developement version of Eigen (post-3.2) supports Tensors. This support is experimental and a moving target.'''</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>'''IMPORTANT NOTE: The current developement version of Eigen (post-3.2) supports Tensors. This support is experimental and a moving target.'''</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>For a TODO list / discussion on further features, see [[<del class="diffchange diffchange-inline">Working_notes_</del>-<del class="diffchange diffchange-inline">_Tensor_module</del>]].</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>For a TODO list / discussion on further features, see [[<ins class="diffchange diffchange-inline">Working notes </ins>- <ins class="diffchange diffchange-inline">Tensor module</ins>]].</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Requirements ==</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>== Requirements ==</div></td></tr>
<tr><td colspan="2" class="diff-lineno">Line 69:</td>
<td colspan="2" class="diff-lineno">Line 69:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>assert(dims[2] == 3);</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>assert(dims[2] == 3);</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div></pre></div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>By default, Tensors are stored in "column-major" order, <tt>&t(x+1, ...) == &t(x, ...) + 1</tt>, <tt>&<del class="diffchange diffchange-inline">tt</del>(x, y+1, ...) == &t(x, y, ...) + t.dimension(0)</tt>, etc. But by using a flag, they can also be changed to "row-major" ordering:</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>By default, Tensors are stored in "column-major" order, <tt>&t(x+1, ...) == &t(x, ...) + 1</tt>, <tt>&<ins class="diffchange diffchange-inline">t</ins>(x, y+1, ...) == &t(x, y, ...) + t.dimension(0)</tt>, etc. But by using a flag, they can also be changed to "row-major" ordering:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Eigen::Tensor<double, 4, Eigen::RowMajor> rowMajorTensor(4, 6, 3, 2);</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>Eigen::Tensor<double, 4, Eigen::RowMajor> rowMajorTensor(4, 6, 3, 2);</div></td></tr>
</table>Christian Seilerhttps://eigen.tuxfamily.org/index.php?title=Tensor_support&diff=1781&oldid=prevChristian Seiler: Some initial notes on Tensors2014-06-06T22:01:04Z<p>Some initial notes on Tensors</p>
<p><b>New page</b></p><div>'''IMPORTANT NOTE: The current developement version of Eigen (post-3.2) supports Tensors. This support is experimental and a moving target.'''<br />
<br />
For a TODO list / discussion on further features, see [[Working_notes_-_Tensor_module]].<br />
<br />
== Requirements ==<br />
<br />
Since using objects with an (in principle) arbitrary number of indices requires variadic templates, Eigen's tensor module requires C++11. The initial version of the Tensor module has been tested with g++ from 4.6 as well as clang 3.2 and 3.3. Intel's 13.1 compiler also works in principle (13.0 crashes during compilation), but produces non-optimal code. For these compilers, please supply at least <tt>-std=c++0x</tt>, <tt>-std=c++11</tt> or even <tt>-std=c++1y</tt> to the compiler as a flag so that they switch to C++11/C++14 mode.<br />
<br />
It has not yet been tested with other compilers.<br />
<br />
== Supported features ==<br />
<br />
Currently, the Tensor module only supports the following few features:<br />
* basic storage for dynamic-sized objects<br />
* setting to zero (<tt>.setZero()</tt>) for POD types<br />
* simple assignments to other tensors of the same type<br />
* getting the dimensionality of the tensor<br />
<br />
== Using the Tensor module ==<br />
<br />
In order to use Tensors, include the Tensor module with the following include statement:<br />
<pre><br />
#include <unsupported/Eigen/CXX11/Tensor><br />
</pre><br />
The following example demonstrates how the Tensor class can be used:<br />
<pre><br />
Eigen::Tensor<double, 3> epsilon(3,3,3);<br />
epsilon.setZero();<br />
epsilon(0,1,2) = 1;<br />
epsilon(1,2,0) = 1;<br />
epsilon(2,0,1) = 1;<br />
epsilon(1,0,2) = -1;<br />
epsilon(2,1,0) = -1;<br />
epsilon(0,2,1) = -1;<br />
Eigen::Tensor<double, 4> grassmannIdentity(3,3,3,3);<br />
grassmannIdentity.setZero();<br />
// this is not the most efficient way to write such a product,<br />
// but is the only way possible with the current feature set<br />
for (int i = 0; i < 3; i++) {<br />
for (int j = 0; j < 3; j++) {<br />
for (int k = 0; k < 3; k++) {<br />
for (int l = 0; l < 3; l++) {<br />
for (int m = 0; m < 3; m++) {<br />
grassmannIdentity(i,j,l,m) += epsilon(i,j,k) * epsilon(k,l,m);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
// verify<br />
for (int i = 0; i < 3; i++) {<br />
for (int j = 0; j < 3; j++) {<br />
for (int l = 0; l < 3; l++) {<br />
for (int m = 0; m < 3; m++) {<br />
assert(grassmannIdentity(i,j,l,m) == (int(i == l) * int(j == m) - int(i == m) * int(j == l)));<br />
}<br />
}<br />
}<br />
}<br />
<br />
// dimensionalities<br />
assert(epsilon.dimension(0) == 3);<br />
assert(epsilon.dimension(1) == 3);<br />
assert(epsilon.dimension(2) == 3);<br />
auto dims = epsilon.dimensions();<br />
assert(dims[0] == 3);<br />
assert(dims[1] == 3);<br />
assert(dims[2] == 3);<br />
</pre><br />
By default, Tensors are stored in "column-major" order, <tt>&t(x+1, ...) == &t(x, ...) + 1</tt>, <tt>&tt(x, y+1, ...) == &t(x, y, ...) + t.dimension(0)</tt>, etc. But by using a flag, they can also be changed to "row-major" ordering:<br />
<pre><br />
Eigen::Tensor<double, 4, Eigen::RowMajor> rowMajorTensor(4, 6, 3, 2);<br />
</pre><br />
<br />
== Known issues ==<br />
<br />
* In order to run the tests for this module, one should specify <tt>-DEIGEN_TEST_CXX11=ON</tt>. But this currently contains a hack to add <tt>-std=c++0x</tt> to the compiler flags, which will not work for MSVC for example.<br />
* <tt>.setZero()</tt> uses <tt>memset()</tt> because packet access is not implemented yet. Unfortunately, this only works with POD types.<br />
<br />
== Exploiting tensor symmetries ==<br />
<br />
Often, Tensors have intrinsic symmetries between indices, which may be exploited. There is an additional module <tt>TensorSymmetry</tt> that contains support for this. It may be included via<br />
<pre><br />
#include <unsupported/Eigen/CXX11/TensorSymmetry><br />
</pre><br />
The current implementation works in the following way:<br />
* every symmetry is assumed to be a relation of the tensor to itself with two swapped indices, e.g. identities such as <tt>t(a,b,c) == t(b,a,c)</tt> or <tt>epsilon(a,b,c) == -epsilon(b,a,c)</tt> (currently supported are symmetry, antisymmetry, hermiticity and antihermiticity)<br />
* the tensor itself stores the full values<br />
* a single assignment sets all elements of the tensor related through symmetry<br />
At a later point in time, the code could be extended to use symmetries to reduce the required storage (while at the same time making memory layout much more complicated), but there are no concrete plans so far to do so.<br />
<br />
=== Constructing the symmetry group ===<br />
<br />
The first step is to construct the full symmetry group that relates all the given symmetries to each other.<br />
<br />
To take the example of the epsilon tensor, it has two elementary symmetries: antisymmetry between the first two and the last two indices (or equivalently, the first two and the first and the last index). The following four ways show how to create the corresponding group:<br />
<pre><br />
StaticSGroup<AntiSymmetry<0,1>, AntiSymmetry<1,2>> ssym1;<br />
StaticSGroup<AntiSymmetry<0,1>, AntiSymmetry<0,2>> ssym2;<br />
DynamicSGroup dsym; dsym.addAntiSymmetry(0,1); dsym.addAntiSymmetry(1,2);<br />
SGroup<AntiSymmetry<0,1>, AntiSymmetry<1,2>> sym;<br />
</pre><br />
In their result, all four are equivalent. The difference between <tt>StaticSGroup</tt> template and the <tt>DynamicSGroup</tt> class is that the <tt>StaticSGroup</tt> template generates the whole group at compile time (through some very involved template logic), while the <tt>DynamicSGroup</tt> class performs the group computation at run time.<br />
<br />
The <tt>SGroup</tt> template is a wrapper that will instantiate the static case if the number of symmetries specified is at most four ''and'' the number of elements in the group is at most 16. If there are more than four symmetry specifiers (i.e. generators of the group apart from the identity), this might cause the compiler to use up GB of RAM and take hours/days/weeks to compile.<br />
<br />
=== Trivially zero tensors / elements ===<br />
<br />
Different combinations of symmetries / antisymmetries are not necessarily useful. For example, any tensor that has the property that the first two indices are antisymmetric and the second and third indices are symmetric has to be zero by definition. The code detects this properties of a symmetry group, but does not react to it by default.<br />
<br />
The user can check after the construction of a symmetry group whether any tensor with this symmetry is trivially zero, trivially real or trivially imaginary:<br />
<pre><br />
if (sym.globalFlags() & Eigen::GlobalZeroFlag) {<br />
// any tensor with this symmetry is trivially zero<br />
} else if (sym.globalFlags() & Eigen::GlobalRealFlag) {<br />
// any tensor with this symmetry is trivially real<br />
} else if (sym.globalFlags() & Eigen::GlobalImagFlag) {<br />
// any tensor with this symmetry is trivially imaginary<br />
} else {<br />
// the symmetry does not pose any restrictions on the tensor in<br />
// general<br />
}<br />
</pre><br />
Note that currently <tt>Eigen::GlobalZeroFlag == Eigen::GlobalRealFlag | Eigen::GlobalImagFlag</tt> (since 0 is the only number that is both on the real and imaginary axis), therefore it is necessary to check it first.<br />
<br />
Alternatively, the user can<br />
<pre><br />
#define EIGEN_TENSOR_SYMMETRY_CHECK_VALUES<br />
</pre><br />
before including the <tt>TensorSymmetry</tt> module. This will activate checks upon assignment to a tensor that the values assigned fulfill these criteria exactly (i.e. whether they are zero, purely real or purely imaginary) and fails an assertion if not.<br />
<br />
Even if the symmetry itself does not restrict the tensor, some elements may be restricted. For example, if there is an antisymmetry between two indices, all elements where both are equal are zero. Similarly, all elements with equal indices that have a hermiticity relation are real. The define <tt>EIGEN_TENSOR_SYMMETRY_CHECK_VALUES</tt> also activates checks for this.<br />
<br />
Note that the <tt>EIGEN_TENSOR_SYMMETRY_CHECK_VALUES</tt> checks are expensive (and incur quite a bit of runtime cost) and should therefore only be used for developement and debugging.<br />
<br />
=== Applying to a tensor ===<br />
<br />
The initialization of the epsilon tensor can be rewritten as:<br />
<pre><br />
Eigen::Tensor<double, 3> epsilon(3,3,3);<br />
epsilon.setZero();<br />
Eigen::SGroup<Eigen::AntiSymmetry<0,1>, Eigen::AntiSymmetry<1,2>> sym;<br />
sym(epsilon, 0, 1, 2) = 1;<br />
</pre><br />
Here, the last line sets all related elements (i.e. the specified element (0,1,2) and all 5 other permutations of these indices) to the proper value. Since the group here is small enough (2 generators, 6 elements), <tt>SGroup</tt> chooses the <tt>StaticSGroup</tt> implementation for this group. Therefore, the entire group is generated at compile time and the assignment incurs '''no runtime penalty''' compared to just having 6 assignments (when compiled with optimization on a decent compiler), because the loop over the group elements is unrolled at compile time.<br />
<br />
For larger groups, it can be better to not unroll the loop at compile time in order to reduce the code size to better fit it in the processor cache. For this reason, the <tt>SGroup</tt> template will choose the <tt>DynamicSGroup</tt> variant if the group has more than 16 elements, even if it does not have more than four generators.</div>Christian Seiler