-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixes 152 * Committing license headers --------- Co-authored-by: license[bot] <license[bot]@github.com>
- Loading branch information
1 parent
c8ba448
commit 05beb6e
Showing
4 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ TensorWrapper Background | |
|
||
key_features | ||
other_choices | ||
logical_v_physical | ||
terminology |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.. Copyright 2023 NWChemEx-Project | ||
.. | ||
.. Licensed under the Apache License, Version 2.0 (the "License"); | ||
.. you may not use this file except in compliance with the License. | ||
.. You may obtain a copy of the License at | ||
.. | ||
.. http://www.apache.org/licenses/LICENSE-2.0 | ||
.. | ||
.. Unless required by applicable law or agreed to in writing, software | ||
.. distributed under the License is distributed on an "AS IS" BASIS, | ||
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
.. See the License for the specific language governing permissions and | ||
.. limitations under the License. | ||
######################################################## | ||
Logical Versus Physical: Understanding the Tensor Layout | ||
######################################################## | ||
|
||
Most tensor libraries conceptually support what we call physical and logical | ||
layouts; however, they often do not distinguish among them. The point of this | ||
page is to introduce the logical vs. physical concept, provide some examples, | ||
and explain why the explicit distinction is important. | ||
|
||
********** | ||
Motivation | ||
********** | ||
|
||
Ideally, users of a tensor library should only have to specify the properties | ||
of the tensor as they relate to the problem being modeled. Roughly speaking, | ||
this amounts to the literal values of the tensor, the symmetry of the tensor, | ||
and the sparsity of the tensor. The literal implementation may need additional | ||
structure, for example tiling and distribution. This additional structure | ||
effectively changes the properties of the tensor (vide infra), and moreover | ||
this additional structure may only appear on certain hardware. | ||
|
||
In an effort to distinguish the problem-specific structure from the | ||
implementation-/hardware-specific structure we term the former the "logical" | ||
structure and the latter the "physical" structure. Generally speaking, the | ||
physical structure will describe how the tensor is actually structured, whereas | ||
the logical structure describes how the user thinks the tensor is structured. | ||
|
||
******** | ||
Examples | ||
******** | ||
|
||
.. _fig_logical_v_physical: | ||
|
||
.. figure:: assets/logical_v_physical.png | ||
:align: center | ||
|
||
Illustration of how tiling a tensor effectively changes its rank. | ||
|
||
The motivation for introducing the logical vs. physical distinction is tiling | ||
of a tensor. :numref:`fig_logical_v_physical` illustrates this process for a | ||
matrix. The left side of :numref:`fig_logical_v_physical` shows the logical view | ||
of the matrix. This is how the end-user thinks of the tensor, *i.e.*, it's some | ||
number of rows by some number of columns. When the user interacts with this | ||
tensor they expect to give two indices, one for the row and one for the column. | ||
All interactions of the end-user with the tensor should behave like the tensor | ||
is a matrix. | ||
|
||
The right side of :numref:`fig_logical_v_physical` shows how TensorWrapper | ||
"physically" lays out a tiled matrix, namely a matrix of matrices. Row and | ||
column offsets in the outer matrix are used to select a tile. Row and column | ||
offsets in a tile are used to select an element. In turn, when interacting with | ||
the physical tensor a user needs to provide four indices. Clearly the logical | ||
and physical views are not compatible without knowing the mapping. | ||
|
||
******* | ||
Summary | ||
******* | ||
|
||
- Ideally users will interact with tensors in a manner dictated by the problem | ||
being modeled. This "logical" interaction will ideally be performance | ||
portable. | ||
- Ideally, TensorWrapper will automatically map the logical view to a | ||
"physical" performant representation. | ||
- Generally speaking, the physical representation will not be the same as the | ||
logical representation. | ||
- In practice, TensorWrapper is unlikely to automate the logical to physical | ||
mapping anytime soon so users will likely need to consider both the logical | ||
and physical representations. | ||
- By distinguishing between logical and physical views and writing TensorWrapper | ||
infrastructure in terms of the physical views we can move towards ideality by | ||
having the logical views dispatch to the physical views. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters