DeepGPR 0.0.4__tar.gz → 0.0.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DeepGPR
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Summary: PyTorch and CUDA for GPR FWI
5
5
  Author-email: Lei Liu <liulei990222@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "DeepGPR"
7
- version = "0.0.4"
7
+ version = "0.0.5"
8
8
  authors = [
9
9
  { name="Lei Liu", email="liulei990222@gmail.com" },
10
10
  ]
@@ -0,0 +1,139 @@
1
+ import ctypes
2
+ import os
3
+ import subprocess
4
+ import platform
5
+ from pathlib import Path
6
+
7
+
8
+ system_name = platform.system()
9
+ lib_dir = Path(__file__).parent / 'lib'
10
+ cu_file = lib_dir / 'deepgpr.cu'
11
+
12
+ if system_name == "Windows":
13
+ lib_extension = ".dll"
14
+ lib_filename = f'deepgpr{lib_extension}'
15
+ lib_path_obj = lib_dir / lib_filename
16
+
17
+ nvcc_cmd = [
18
+ 'nvcc', '-shared',
19
+ '-o', str(lib_path_obj),
20
+ str(cu_file)
21
+ ]
22
+ else:
23
+ lib_extension = ".so"
24
+ lib_filename = f'deepgpr{lib_extension}'
25
+ lib_path_obj = lib_dir / lib_filename
26
+
27
+ nvcc_cmd = [
28
+ 'nvcc', '-shared', '-Xcompiler', '-fPIC',
29
+ '-D_GLIBCXX_USE_CXX11_ABI=0',
30
+ '-o', str(lib_path_obj),
31
+ str(cu_file)
32
+ ]
33
+
34
+ if not lib_path_obj.is_file():
35
+ print(f'Compiling CUDA extension for {system_name} directly via nvcc...')
36
+ try:
37
+ subprocess.run(nvcc_cmd, check=True)
38
+ except FileNotFoundError:
39
+ raise RuntimeError(
40
+ "Compilation failed: 'nvcc' command not found. "
41
+ "Please ensure NVIDIA CUDA Toolkit is installed and 'nvcc' is added to your system PATH."
42
+ )
43
+ except subprocess.CalledProcessError as e:
44
+ raise RuntimeError(f"Compilation failed with error code {e.returncode}.")
45
+
46
+ lib_path = str(lib_path_obj)
47
+ c_lib = ctypes.cdll.LoadLibrary(lib_path)
48
+
49
+
50
+ c_lib.forward.argtypes = [
51
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
52
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
53
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
54
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
55
+ ctypes.POINTER(ctypes.c_float),
56
+ ctypes.POINTER(ctypes.c_float),
57
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
58
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
59
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
60
+
61
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
62
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
63
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
64
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
65
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
66
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
67
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
68
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
69
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
70
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
71
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
72
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
73
+
74
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
75
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
76
+
77
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
78
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
79
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
80
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
81
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
82
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
83
+
84
+ ctypes.c_float,ctypes.c_int,ctypes.c_int,ctypes.c_int,ctypes.c_float,
85
+ ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_float),
86
+ ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
87
+ ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_float),
88
+ ctypes.c_int
89
+ ]
90
+ c_lib.forward.restype = None
91
+
92
+ c_lib.backward.argtypes = [
93
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
94
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
95
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
96
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
97
+ ctypes.POINTER(ctypes.c_float),
98
+ ctypes.POINTER(ctypes.c_float),
99
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
100
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
101
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),#16
102
+
103
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
104
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
105
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
106
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
107
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
108
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
109
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
110
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
111
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
112
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
113
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
114
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),#40
115
+
116
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
117
+ ctypes.c_int, ctypes.c_int, ctypes.c_int,
118
+
119
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
120
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
121
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
122
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
123
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
124
+ ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float), #58
125
+
126
+ ctypes.c_float,ctypes.c_int,ctypes.c_int,ctypes.c_int,ctypes.c_float,
127
+ ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int,
128
+ ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_float),
129
+ ctypes.c_int ,ctypes.POINTER(ctypes.c_float), ctypes.POINTER(ctypes.c_float),
130
+ ctypes.c_int, ctypes.c_int
131
+ ]
132
+ c_lib.backward.restype = None
133
+ __all__ = ['c_lib']
134
+
135
+
136
+ from .common import *
137
+ from .compute2 import *
138
+ from .multiscale import *
139
+ from .wavelet import *