Skip to content

Commit 892f723

Browse files
committed
[update] reflect reviewer's suggestions
1 parent 46487c3 commit 892f723

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
17.1 KB
Loading
146 KB
Loading

papers/riku_sakamoto/main.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,33 @@ except ValueError as e:
163163
164164
```
165165

166+
PhlowerTensor supports in-place operations (e.g., +=, *=) while enforcing dimensional consistency. [](#inplace_operation_example) illustrates an example of in-place operations for `PhlowerTensor`.
167+
168+
```{code} python
169+
:label: inplace_operation_example
170+
:caption: In-place operation with dimensions
171+
172+
# Example: In-place operation for non-dimensional tensor
173+
# Objects other than PhlowerTensor (e.g., float) are treated as non-dimensional
174+
non_dimensional_value = phlower_tensor(torch.rand(10, 3), dimension={})
175+
non_dimensional_value += 5.0
176+
177+
# Example: A tensor representing pressure with dimensions M^1 T^-2 L^-1
178+
pressure = phlower_tensor(torch.rand(10, 1), dimension={"M": 1, "T": -2, "L": -1})
179+
180+
# In-place subtraction with compatible dimensions
181+
pressure -= phlower_tensor(torch.tensor(1.0), dimension={"M": 1, "T": -2, "L": -1})
182+
183+
# Attempting in-place addition with incompatible dimensions
184+
try:
185+
pressure += 5.0
186+
except ValueError as e:
187+
print(f"Error: {e}")
188+
# Output: Error: Add operation for different physical dimensions is not allowed.
189+
190+
```
191+
192+
166193
### Array Operations
167194

168195
This section demonstrates how `PhlowerTensor` supports array operations while maintaining dimensional consistency.
@@ -286,6 +313,8 @@ Several libraries and frameworks have been developed to support physical dimensi
286313

287314
In contrast to Pint or Python Quantities, Phlower has two key differences. First, it does not provide unit conversion functionalities; instead, it focuses on enforcing **dimensional consistency** in tensor operations. Second, `PhlowerTensor` represents physical dimensions as an exponent vector of physical quantities (such as mass, length, and time) and stores this metadata alongside a PyTorch tensor. This design enables seamless integration with PyTorch, supporting GPU acceleration and automatic differentiation while tracking and validating the physical dimensions of tensor computations.
288315

316+
Thus, while Pint and Python Quantities aim to provide general-purpose unit handling and conversions in scientific computing built on NumPy, Phlower is specifically designed to integrate dimension checking into deep learning workflows built on PyTorch.
317+
289318

290319
## Limitations
291320

0 commit comments

Comments
 (0)