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
perf(autograd): optimize grey_dilation with striding
The previous implementation of `grey_dilation` was based on convolution, which was slow for both the forward and backward passes.
This commit replaces it with a high-performance implementation that uses NumPy's `as_strided` to create sliding window views of the input array. This avoids redundant computations and memory allocations, leading to significant speedups.
The VJP (gradient) for the primitive is also updated to use the same striding technique, ensuring the backward pass is also much faster.
Benchmarks show speedups of 10-100x depending on the array and kernel size.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
### Changed
15
15
- Switched to an analytical gradient calculation for spatially-varying pole-residue models (`CustomPoleResidue`).
16
16
17
+
### Changed
18
+
- Significantly improved performance of the `tidy3d.plugins.autograd.grey_dilation` morphological operation and its gradient calculation. The new implementation is orders of magnitude faster, especially for large arrays and kernel sizes.
19
+
17
20
### Fixed
18
21
- Arrow lengths are now scaled consistently in the X and Y directions, and their lengths no longer exceed the height of the plot window.
19
22
- Bug in `PlaneWave` defined with a negative `angle_theta` which would lead to wrong injection.
0 commit comments