DeepGPR 0.0.13__tar.gz → 0.0.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {deepgpr-0.0.13 → deepgpr-0.0.14}/PKG-INFO +18 -3
  2. {deepgpr-0.0.13 → deepgpr-0.0.14}/README.md +11 -2
  3. deepgpr-0.0.14/license +21 -0
  4. {deepgpr-0.0.13 → deepgpr-0.0.14}/pyproject.toml +18 -3
  5. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/__init__.py +44 -0
  6. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/compute2.py +28 -22
  7. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/lib/deepgpr.cu +369 -247
  8. deepgpr-0.0.14/src/DeepGPR/lib/deepgpr.dll +0 -0
  9. deepgpr-0.0.14/src/DeepGPR/lib/deepgpr.so +0 -0
  10. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/lib/deepgpr_cpu.c +232 -199
  11. deepgpr-0.0.14/src/DeepGPR/lib/deepgpr_cpu.dll +0 -0
  12. deepgpr-0.0.14/src/DeepGPR/lib/deepgpr_cpu.dylib +0 -0
  13. deepgpr-0.0.14/src/DeepGPR/lib/deepgpr_cpu.so +0 -0
  14. deepgpr-0.0.14/src/DeepGPR/lib/libomp.dylib +0 -0
  15. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR.egg-info/PKG-INFO +18 -3
  16. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR.egg-info/SOURCES.txt +4 -1
  17. deepgpr-0.0.13/src/DeepGPR/lib/deepgpr.dll +0 -0
  18. deepgpr-0.0.13/src/DeepGPR/lib/deepgpr.so +0 -0
  19. deepgpr-0.0.13/src/DeepGPR/lib/deepgpr_cpu.dll +0 -0
  20. deepgpr-0.0.13/src/DeepGPR/lib/deepgpr_cpu.so +0 -0
  21. {deepgpr-0.0.13 → deepgpr-0.0.14}/setup.cfg +0 -0
  22. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/common.py +0 -0
  23. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/multiscale.py +0 -0
  24. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR/wavelet.py +0 -0
  25. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR.egg-info/dependency_links.txt +0 -0
  26. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR.egg-info/requires.txt +0 -0
  27. {deepgpr-0.0.13 → deepgpr-0.0.14}/src/DeepGPR.egg-info/top_level.txt +0 -0
@@ -1,19 +1,25 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DeepGPR
3
- Version: 0.0.13
3
+ Version: 0.0.14
4
4
  Summary: PyTorch and CUDA for GPR FWI
5
5
  Author-email: Lei Liu <liulei990222@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/songc0a/DeepGPR
8
+ Project-URL: Repository, https://github.com/songc0a/DeepGPR
6
9
  Classifier: Programming Language :: Python :: 3
7
10
  Classifier: Operating System :: Microsoft :: Windows
8
11
  Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Operating System :: MacOS :: MacOS X
9
13
  Classifier: Topic :: Scientific/Engineering
10
14
  Classifier: Topic :: Scientific/Engineering :: Physics
11
15
  Requires-Python: >=3.8
12
16
  Description-Content-Type: text/markdown
17
+ License-File: license
13
18
  Requires-Dist: numpy
14
19
  Requires-Dist: scipy
15
20
  Requires-Dist: matplotlib
16
21
  Requires-Dist: torch
22
+ Dynamic: license-file
17
23
 
18
24
  # DeepGPR
19
25
 
@@ -144,7 +150,8 @@ def compute(device, dx=None, dt=None,
144
150
  model_gradient_sampling_interval=1,
145
151
  use_async_offload=False,
146
152
  fdtd_order=2,
147
- mode=2):
153
+ mode=2,
154
+ debug=False):
148
155
  ```
149
156
  ## 📥 Input Parameters
150
157
  ### 1. Basic Physics & Grid Parameters
@@ -156,6 +163,7 @@ def compute(device, dx=None, dt=None,
156
163
  | **`dt`** | `float` | Time step size. **Note**: Must strictly satisfy the CFL (Courant-Friedrichs-Lewy) stability condition, or an exception will be raised. Typically in seconds (s). |
157
164
  | **`fdtd_order`** | `int` | Spatial finite-difference order used by the FDTD field updates. Supported values are `2`, `4`, and `8`; default is `2` for compatibility with earlier versions. |
158
165
  | **`mode`** | `int` | FWI gradient mode. `2` keeps the previous Ez-only model-gradient calculation. `3` uses Ex, Ey, and Ez electric-field contributions for relative permittivity and conductivity gradients. |
166
+ | **`debug`** | `bool` | Runs expensive NaN/Inf and zero-field validation checks when `True`. The default `False` keeps these checks disabled for faster production runs. |
159
167
  ### 2. Medium Model Parameters
160
168
 
161
169
  This section defines the electromagnetic properties of the simulation space. For 2D simulations, set `nz=1`.
@@ -212,7 +220,14 @@ cc -std=c99 -O3 -fopenmp -fPIC -shared -o src/DeepGPR/lib/deepgpr_cpu.so src/Dee
212
220
  # macOS
213
221
  brew install libomp
214
222
  LIBOMP_PREFIX="$(brew --prefix libomp)"
215
- cc -std=c99 -O3 -Xpreprocessor -fopenmp -DDEEPGPR_USE_OPENMP -I"$LIBOMP_PREFIX/include" -Wl,-rpath,"$LIBOMP_PREFIX/lib" -L"$LIBOMP_PREFIX/lib" -fPIC -shared -o src/DeepGPR/lib/deepgpr_cpu.dylib src/DeepGPR/lib/deepgpr_cpu.c -lomp
223
+ LIBOMP_RUNTIME_NAME="/opt/llvm-openmp/lib/libomp.dylib"
224
+ cc -std=c99 -O3 -Xpreprocessor -fopenmp -DDEEPGPR_USE_OPENMP -I"$LIBOMP_PREFIX/include" -L"$LIBOMP_PREFIX/lib" -fPIC -shared -o src/DeepGPR/lib/deepgpr_cpu.dylib src/DeepGPR/lib/deepgpr_cpu.c -lomp
225
+ cp "$LIBOMP_PREFIX/lib/libomp.dylib" src/DeepGPR/lib/libomp.dylib
226
+ install_name_tool -id "$LIBOMP_RUNTIME_NAME" src/DeepGPR/lib/libomp.dylib
227
+ LIBOMP_DEP="$(otool -L src/DeepGPR/lib/deepgpr_cpu.dylib | awk '/libomp\.dylib/ {print $1; exit}')"
228
+ install_name_tool -change "$LIBOMP_DEP" "$LIBOMP_RUNTIME_NAME" src/DeepGPR/lib/deepgpr_cpu.dylib
229
+ codesign --force --sign - src/DeepGPR/lib/libomp.dylib
230
+ codesign --force --sign - src/DeepGPR/lib/deepgpr_cpu.dylib
216
231
  ```
217
232
 
218
233
  On Windows, build `src\DeepGPR\lib\deepgpr_cpu.dll` with MSVC:
@@ -127,7 +127,8 @@ def compute(device, dx=None, dt=None,
127
127
  model_gradient_sampling_interval=1,
128
128
  use_async_offload=False,
129
129
  fdtd_order=2,
130
- mode=2):
130
+ mode=2,
131
+ debug=False):
131
132
  ```
132
133
  ## 📥 Input Parameters
133
134
  ### 1. Basic Physics & Grid Parameters
@@ -139,6 +140,7 @@ def compute(device, dx=None, dt=None,
139
140
  | **`dt`** | `float` | Time step size. **Note**: Must strictly satisfy the CFL (Courant-Friedrichs-Lewy) stability condition, or an exception will be raised. Typically in seconds (s). |
140
141
  | **`fdtd_order`** | `int` | Spatial finite-difference order used by the FDTD field updates. Supported values are `2`, `4`, and `8`; default is `2` for compatibility with earlier versions. |
141
142
  | **`mode`** | `int` | FWI gradient mode. `2` keeps the previous Ez-only model-gradient calculation. `3` uses Ex, Ey, and Ez electric-field contributions for relative permittivity and conductivity gradients. |
143
+ | **`debug`** | `bool` | Runs expensive NaN/Inf and zero-field validation checks when `True`. The default `False` keeps these checks disabled for faster production runs. |
142
144
  ### 2. Medium Model Parameters
143
145
 
144
146
  This section defines the electromagnetic properties of the simulation space. For 2D simulations, set `nz=1`.
@@ -195,7 +197,14 @@ cc -std=c99 -O3 -fopenmp -fPIC -shared -o src/DeepGPR/lib/deepgpr_cpu.so src/Dee
195
197
  # macOS
196
198
  brew install libomp
197
199
  LIBOMP_PREFIX="$(brew --prefix libomp)"
198
- cc -std=c99 -O3 -Xpreprocessor -fopenmp -DDEEPGPR_USE_OPENMP -I"$LIBOMP_PREFIX/include" -Wl,-rpath,"$LIBOMP_PREFIX/lib" -L"$LIBOMP_PREFIX/lib" -fPIC -shared -o src/DeepGPR/lib/deepgpr_cpu.dylib src/DeepGPR/lib/deepgpr_cpu.c -lomp
200
+ LIBOMP_RUNTIME_NAME="/opt/llvm-openmp/lib/libomp.dylib"
201
+ cc -std=c99 -O3 -Xpreprocessor -fopenmp -DDEEPGPR_USE_OPENMP -I"$LIBOMP_PREFIX/include" -L"$LIBOMP_PREFIX/lib" -fPIC -shared -o src/DeepGPR/lib/deepgpr_cpu.dylib src/DeepGPR/lib/deepgpr_cpu.c -lomp
202
+ cp "$LIBOMP_PREFIX/lib/libomp.dylib" src/DeepGPR/lib/libomp.dylib
203
+ install_name_tool -id "$LIBOMP_RUNTIME_NAME" src/DeepGPR/lib/libomp.dylib
204
+ LIBOMP_DEP="$(otool -L src/DeepGPR/lib/deepgpr_cpu.dylib | awk '/libomp\.dylib/ {print $1; exit}')"
205
+ install_name_tool -change "$LIBOMP_DEP" "$LIBOMP_RUNTIME_NAME" src/DeepGPR/lib/deepgpr_cpu.dylib
206
+ codesign --force --sign - src/DeepGPR/lib/libomp.dylib
207
+ codesign --force --sign - src/DeepGPR/lib/deepgpr_cpu.dylib
199
208
  ```
200
209
 
201
210
  On Windows, build `src\DeepGPR\lib\deepgpr_cpu.dll` with MSVC:
deepgpr-0.0.14/license ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lei Liu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,21 +1,24 @@
1
1
  [build-system]
2
- requires = ["setuptools>=70", "wheel"]
2
+ requires = ["setuptools>=77", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "DeepGPR"
7
- version = "0.0.13"
7
+ version = "0.0.14"
8
8
  authors = [
9
9
  { name = "Lei Liu", email = "liulei990222@gmail.com" }
10
10
  ]
11
11
  description = "PyTorch and CUDA for GPR FWI"
12
12
  readme = "README.md"
13
+ license = "MIT"
14
+ license-files = ["license"]
13
15
  requires-python = ">=3.8"
14
16
 
15
17
  classifiers = [
16
18
  "Programming Language :: Python :: 3",
17
19
  "Operating System :: Microsoft :: Windows",
18
20
  "Operating System :: POSIX :: Linux",
21
+ "Operating System :: MacOS :: MacOS X",
19
22
  "Topic :: Scientific/Engineering",
20
23
  "Topic :: Scientific/Engineering :: Physics"
21
24
  ]
@@ -27,6 +30,10 @@ dependencies = [
27
30
  "torch"
28
31
  ]
29
32
 
33
+ [project.urls]
34
+ Homepage = "https://github.com/songc0a/DeepGPR"
35
+ Repository = "https://github.com/songc0a/DeepGPR"
36
+
30
37
  [tool.setuptools]
31
38
  package-dir = { "" = "src" }
32
39
  include-package-data = true
@@ -44,5 +51,13 @@ DeepGPR = [
44
51
  "lib/*.c",
45
52
  "lib/*.dll",
46
53
  "lib/*.so",
54
+ "lib/*.dylib",
47
55
  "lib/*.pyd"
48
- ]
56
+ ]
57
+
58
+ [tool.setuptools.exclude-package-data]
59
+ DeepGPR = [
60
+ ".DS_Store",
61
+ "__pycache__/*",
62
+ "*.pyc"
63
+ ]
@@ -13,6 +13,7 @@ _PACKAGE_DIR = Path(__file__).resolve().parent
13
13
  _LIB_DIR = _PACKAGE_DIR / "lib"
14
14
  _SYSTEM_NAME = platform.system()
15
15
  _LOADED_LIBS: dict[str, ctypes.CDLL] = {}
16
+ _OPENMP_RUNTIME: ctypes.CDLL | None = None
16
17
 
17
18
 
18
19
  def _candidate_library_paths(kind: str) -> list[Path]:
@@ -88,6 +89,46 @@ def _add_windows_dll_search_paths() -> None:
88
89
  pass
89
90
 
90
91
 
92
+ def _preload_macos_openmp_runtime() -> None:
93
+ """Preload the OpenMP runtime used by PyTorch on macOS.
94
+
95
+ Args:
96
+ None.
97
+ """
98
+ global _OPENMP_RUNTIME
99
+
100
+ if _SYSTEM_NAME != "Darwin" or _OPENMP_RUNTIME is not None:
101
+ return
102
+
103
+ candidates: list[Path] = []
104
+ try:
105
+ import torch
106
+
107
+ candidates.append(Path(torch.__file__).resolve().parent / "lib" / "libomp.dylib")
108
+ except Exception:
109
+ pass
110
+
111
+ conda_prefix = os.environ.get("CONDA_PREFIX")
112
+ if conda_prefix:
113
+ candidates.append(Path(conda_prefix) / "lib" / "libomp.dylib")
114
+
115
+ candidates.append(_LIB_DIR / "libomp.dylib")
116
+
117
+ seen = set()
118
+ for path in candidates:
119
+ path = Path(path)
120
+ if path in seen:
121
+ continue
122
+ seen.add(path)
123
+ if not path.is_file():
124
+ continue
125
+ try:
126
+ _OPENMP_RUNTIME = ctypes.CDLL(str(path.resolve()), mode=ctypes.RTLD_GLOBAL)
127
+ return
128
+ except OSError:
129
+ continue
130
+
131
+
91
132
  def _require_exported_symbols(lib: ctypes.CDLL, symbols: tuple[str, ...], path: Path) -> None:
92
133
  """Validate that a loaded native library exports required symbols.
93
134
 
@@ -189,6 +230,9 @@ def _load_deepgpr_library(kind: str) -> ctypes.CDLL:
189
230
  return _LOADED_LIBS[kind]
190
231
 
191
232
  _add_windows_dll_search_paths()
233
+ if kind == "cpu":
234
+ _preload_macos_openmp_runtime()
235
+
192
236
  candidates = _candidate_library_paths(kind)
193
237
  load_errors: list[str] = []
194
238
 
@@ -57,7 +57,8 @@ def compute(device, dx=None, dt=None,
57
57
  model_gradient_sampling_interval=1,
58
58
  use_async_offload=False,
59
59
  fdtd_order=2,
60
- mode=2):
60
+ mode=2,
61
+ debug=False):
61
62
  """Run DeepGPR FDTD forward modeling with autograd support.
62
63
 
63
64
  Args:
@@ -80,6 +81,7 @@ def compute(device, dx=None, dt=None,
80
81
  use_async_offload: Whether CUDA should offload saved wavefields to pinned CPU memory.
81
82
  fdtd_order: Spatial finite-difference order, supported values are 2, 4, and 8.
82
83
  mode: FWI gradient mode; 2 uses Ez only, 3 uses Ex, Ey, and Ez.
84
+ debug: Whether to run expensive tensor validation checks.
83
85
  """
84
86
  device = torch.device(device)
85
87
  if fdtd_order not in (2, 4, 8):
@@ -97,7 +99,7 @@ def compute(device, dx=None, dt=None,
97
99
  x0EPhi1,x0EPhi2,x0HPhi1,x0HPhi2,xmEPhi1,xmEPhi2,xmHPhi1,xmHPhi2,y0EPhi1,y0EPhi2,y0HPhi1,y0HPhi2,ymEPhi1,ymEPhi2,ymHPhi1,ymHPhi2,z0EPhi1,z0EPhi2,z0HPhi1,z0HPhi2,zmEPhi1,zmEPhi2,zmHPhi1,zmHPhi2=build_pml_phi(x0,xm,y0,ym,z0,zm,nstep,PML,device)
98
100
 
99
101
  Ex,Ey,Ez,Hx,Hy,Hz,x0EPhi1,x0EPhi2,x0HPhi1,x0HPhi2,xmEPhi1,xmEPhi2,xmHPhi1,xmHPhi2,y0EPhi1,y0EPhi2,y0HPhi1,y0HPhi2,ymEPhi1,ymEPhi2,ymHPhi1,ymHPhi2,z0EPhi1,z0EPhi2,z0HPhi1,z0HPhi2,zmEPhi1,zmEPhi2,zmHPhi1,zmHPhi2,Eall,receiver_amplitudes = DeepGPR.apply(
100
- er, se,Ex,Ey,Ez,Hx,Hy,Hz,x0EPhi1,x0EPhi2,x0HPhi1,x0HPhi2,xmEPhi1,xmEPhi2,xmHPhi1,xmHPhi2,y0EPhi1,y0EPhi2,y0HPhi1,y0HPhi2,ymEPhi1,ymEPhi2,ymHPhi1,ymHPhi2,z0EPhi1,z0EPhi2,z0HPhi1,z0HPhi2,zmEPhi1,zmEPhi2,zmHPhi1,zmHPhi2, mr,dx,nx,ny,nz,dt,nt,nstep,source_amplitudes,source_location,receiver_location,pmlthick,nsr,nrx,device,dtype,x0,xm,y0,ym,z0,zm,x01,x02,xm1,xm2,y01,y02,ym1,ym2,z01,z02,zm1,zm2,ere,see,source_direction, reciever_direction, model_gradient_sampling_interval, use_async_offload, fdtd_order, mode)
102
+ er, se,Ex,Ey,Ez,Hx,Hy,Hz,x0EPhi1,x0EPhi2,x0HPhi1,x0HPhi2,xmEPhi1,xmEPhi2,xmHPhi1,xmHPhi2,y0EPhi1,y0EPhi2,y0HPhi1,y0HPhi2,ymEPhi1,ymEPhi2,ymHPhi1,ymHPhi2,z0EPhi1,z0EPhi2,z0HPhi1,z0HPhi2,zmEPhi1,zmEPhi2,zmHPhi1,zmHPhi2, mr,dx,nx,ny,nz,dt,nt,nstep,source_amplitudes,source_location,receiver_location,pmlthick,nsr,nrx,device,dtype,x0,xm,y0,ym,z0,zm,x01,x02,xm1,xm2,y01,y02,ym1,ym2,z01,z02,zm1,zm2,ere,see,source_direction, reciever_direction, model_gradient_sampling_interval, use_async_offload, fdtd_order, mode, debug)
101
103
 
102
104
  return Eall,(Ex,Ey,Ez),(Hx,Hy,Hz),(x0EPhi1,x0EPhi2,x0HPhi1,x0HPhi2,xmEPhi1,xmEPhi2,xmHPhi1,xmHPhi2,y0EPhi1,y0EPhi2,y0HPhi1,y0HPhi2,ymEPhi1,ymEPhi2,ymHPhi1,ymHPhi2,z0EPhi1,z0EPhi2,z0HPhi1,z0HPhi2,zmEPhi1,zmEPhi2,zmHPhi1,zmHPhi2),receiver_amplitudes
103
105
 
@@ -112,7 +114,7 @@ class DeepGPR(torch.autograd.Function):
112
114
  y0,ym,z0,zm,x01,x02,xm1,xm2,
113
115
  y01,y02,ym1,ym2,z01,z02,zm1,zm2,
114
116
  ere,see,source_direction, reciever_direction,
115
- model_gradient_sampling_interval, use_async_offload, fdtd_order, mode):
117
+ model_gradient_sampling_interval, use_async_offload, fdtd_order, mode, debug):
116
118
  """Call the native forward solver and save tensors for backward.
117
119
 
118
120
  Args:
@@ -155,6 +157,7 @@ class DeepGPR(torch.autograd.Function):
155
157
  use_async_offload: Whether CUDA should offload saved wavefields to pinned CPU memory.
156
158
  fdtd_order: Spatial finite-difference order.
157
159
  mode: FWI gradient mode; 2 uses Ez only, 3 uses Ex, Ey, and Ez.
160
+ debug: Whether to run expensive tensor validation checks.
158
161
  """
159
162
 
160
163
  source_amplitudes = source_amplitudes.contiguous()
@@ -179,6 +182,7 @@ class DeepGPR(torch.autograd.Function):
179
182
  ctx.use_async_offload = bool(use_async_offload and device.type == "cuda")
180
183
  ctx.fdtd_order = fdtd_order
181
184
  ctx.mode = mode
185
+ ctx.debug = bool(debug)
182
186
 
183
187
  nt_saved = (nt + model_gradient_sampling_interval - 1) // model_gradient_sampling_interval
184
188
  e_components = 3 if mode == 3 else 1
@@ -252,23 +256,24 @@ class DeepGPR(torch.autograd.Function):
252
256
  mode)
253
257
  _sync_cuda_device(device)
254
258
 
255
- check_tensors_for_nan_inf(d="forward",
256
- Ex=Ex, Ey=Ey, Ez=Ez,
257
- Hx=Hx, Hy=Hy, Hz=Hz,
258
- x0EPhi1=x0EPhi1, x0EPhi2=x0EPhi2,
259
- x0HPhi1=x0HPhi1, x0HPhi2=x0HPhi2,
260
- xmEPhi1=xmEPhi1, xmEPhi2=xmEPhi2,
261
- xmHPhi1=xmHPhi1, xmHPhi2=xmHPhi2,
262
- y0EPhi1=y0EPhi1, y0EPhi2=y0EPhi2,
263
- y0HPhi1=y0HPhi1, y0HPhi2=y0HPhi2,
264
- ymEPhi1=ymEPhi1, ymEPhi2=ymEPhi2,
265
- ymHPhi1=ymHPhi1, ymHPhi2=ymHPhi2,
266
- z0EPhi1=z0EPhi1, z0EPhi2=z0EPhi2,
267
- z0HPhi1=z0HPhi1, z0HPhi2=z0HPhi2,
268
- zmEPhi1=zmEPhi1, zmEPhi2=zmEPhi2,
269
- zmHPhi1=zmHPhi1, zmHPhi2=zmHPhi2
270
- )
271
- _check_nonzero_source_created_fields(c_lib, source_amplitudes, Ex, Ey, Ez, Hx, Hy, Hz)
259
+ if ctx.debug:
260
+ check_tensors_for_nan_inf(d="forward",
261
+ Ex=Ex, Ey=Ey, Ez=Ez,
262
+ Hx=Hx, Hy=Hy, Hz=Hz,
263
+ x0EPhi1=x0EPhi1, x0EPhi2=x0EPhi2,
264
+ x0HPhi1=x0HPhi1, x0HPhi2=x0HPhi2,
265
+ xmEPhi1=xmEPhi1, xmEPhi2=xmEPhi2,
266
+ xmHPhi1=xmHPhi1, xmHPhi2=xmHPhi2,
267
+ y0EPhi1=y0EPhi1, y0EPhi2=y0EPhi2,
268
+ y0HPhi1=y0HPhi1, y0HPhi2=y0HPhi2,
269
+ ymEPhi1=ymEPhi1, ymEPhi2=ymEPhi2,
270
+ ymHPhi1=ymHPhi1, ymHPhi2=ymHPhi2,
271
+ z0EPhi1=z0EPhi1, z0EPhi2=z0EPhi2,
272
+ z0HPhi1=z0HPhi1, z0HPhi2=z0HPhi2,
273
+ zmEPhi1=zmEPhi1, zmEPhi2=zmEPhi2,
274
+ zmHPhi1=zmHPhi1, zmHPhi2=zmHPhi2
275
+ )
276
+ _check_nonzero_source_created_fields(c_lib, source_amplitudes, Ex, Ey, Ez, Hx, Hy, Hz)
272
277
 
273
278
  ctx.Eall = Eall
274
279
  return (Ex,Ey,Ez,Hx,Hy,Hz,x0EPhi1,x0EPhi2,x0HPhi1,x0HPhi2,xmEPhi1,xmEPhi2,xmHPhi1,xmHPhi2,y0EPhi1,y0EPhi2,y0HPhi1,y0HPhi2,ymEPhi1,ymEPhi2,ymHPhi1,ymHPhi2,z0EPhi1,z0EPhi2,z0HPhi1,z0HPhi2,zmEPhi1,zmEPhi2,zmHPhi1,zmHPhi2,Eall,receiver_amplitudes[:,reciever_direction,:,:])
@@ -462,7 +467,8 @@ class DeepGPR(torch.autograd.Function):
462
467
  if serequiregrad == 1:
463
468
  tensors_to_check["grad_se"] = grad_se
464
469
 
465
- check_tensors_for_nan_inf(d="backward", **tensors_to_check)
470
+ if ctx.debug:
471
+ check_tensors_for_nan_inf(d="backward", **tensors_to_check)
466
472
 
467
473
  ctx.Eall = None
468
474
  del Eall,er, se, mr,receiver_location,x0,xm,y0,ym,z0,zm,x01,x02,xm1,xm2,y01,y02,ym1,ym2,z01,z02,zm1,zm2,ere,see, Eupdatecoffs0, Eupdatecoffs1, Eupdatecoffs4, Hupdatecoffs0, Hupdatecoffs1, Hupdatecoffs4
@@ -481,5 +487,5 @@ class DeepGPR(torch.autograd.Function):
481
487
  None, None, None, None, None, None, None, None,
482
488
  None, None, None, None, None, None, None, None,
483
489
  None, None, None, None, None, None, None, None,
484
- None, None, None
490
+ None, None, None, None
485
491
  )