You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: papers/riku_sakamoto/main.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,33 @@ except ValueError as e:
163
163
164
164
```
165
165
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
# 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
+
166
193
### Array Operations
167
194
168
195
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
286
313
287
314
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.
288
315
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.
0 commit comments