Skip to content

Commit

Permalink
Added support to build pymnn with openmp
Browse files Browse the repository at this point in the history
Signed-off-by: avinash31d <avinash31d@gmail.com>
  • Loading branch information
avinash31d committed May 13, 2024
1 parent 6a22d17 commit ffc9ebb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pymnn/pip_package/build_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
USE_INTERNAL = False
USE_RENDER = False
USE_SSE = True
USE_OPENMP = False

if len(sys.argv) > 1 and sys.argv[1] != None:
if "trt" in sys.argv[1]:
Expand All @@ -48,6 +49,8 @@
USE_RENDER = True
if "no_sse" in sys.argv[1]:
USE_SSE = False
if "openmp" in sys.argv[1]:
USE_OPENMP = True

print ("USE_INTERNAL:", USE_INTERNAL)
print ("USE_TRT:", USE_TRT)
Expand All @@ -58,6 +61,7 @@
print ("USE_VULKAN:", USE_VULKAN)
print ("USE_RENDER:", USE_RENDER)
print ("USE_SSE:", USE_SSE)
print ("USE_OPENMP:", USE_OPENMP)

def build_deps():
""" build depency """
Expand All @@ -75,6 +79,8 @@ def build_deps():
extra_opts += ' -DMNN_VULKAN=ON -DMNN_VULKAN_IMAGE=OFF'
if USE_OPENCL:
extra_opts += ' -DMNN_OPENCL=ON'
extra_opts += ' -DMNN_USE_THREAD_POOL=OFF -DMNN_OPENMP=ON' if USE_OPENMP else ' -DMNN_USE_THREAD_POOL=ON -DMNN_OPENMP=OFF'

if IS_WINDOWS:
os.system('cmake -G "Ninja" ' + extra_opts +' -DMNN_BUILD_TRAIN=ON -DMNN_BUILD_CONVERTER=on -DMNN_BUILD_TORCH=OFF\
-DMNN_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DMNN_WIN_RUNTIME_MT=ON\
Expand All @@ -92,7 +98,7 @@ def build_deps():
os.system('cmake ' + extra_opts +
'-DMNN_BUILD_CONVERTER=on -DMNN_BUILD_TRAIN=ON -DCMAKE_BUILD_TYPE=Release \
-DMNN_BUILD_SHARED_LIBS=OFF -DMNN_AAPL_FMWK=OFF -DMNN_SEP_BUILD=OFF -DMNN_BUILD_OPENCV=ON -DMNN_IMGCODECS=ON \
-DMNN_USE_THREAD_POOL=ON -DMNN_OPENMP=OFF .. && make MNN MNNTrain MNNConvertDeps -j32')
.. && make MNN MNNTrain MNNConvertDeps -j32')
else:
extra_opts += ' -DMNN_INTERNAL=ON ' if USE_INTERNAL else ' '
extra_opts += ' -DMNN_BUILD_TORCH=ON ' if USE_TORCH else ' '
Expand Down

0 comments on commit ffc9ebb

Please sign in to comment.