"git@developer.sourcefind.cn:OpenDAS/torch-sparce.git" did not exist on "1c4fdfe2bbe72f9942231daffe176a5b19692df4"
Commit 984cce35 authored by Hang Zhang's avatar Hang Zhang
Browse files

debuging

parent 963c408f
...@@ -10,24 +10,31 @@ ...@@ -10,24 +10,31 @@
import os import os
import torch import torch
import platform
from torch.utils.ffi import create_extension from torch.utils.ffi import create_extension
package_base = os.path.dirname(torch.__file__) package_base = os.path.dirname(torch.__file__)
this_file = os.path.dirname(os.path.realpath(__file__)) this_file = os.path.dirname(os.path.realpath(__file__))
include_path = [os.path.join(os.environ['HOME'],'pytorch/torch/lib/THC'), include_path = [os.path.join(os.environ['HOME'],'pytorch/torch/lib/THC'),
os.path.join(this_file,'encoding/src/'), os.path.join(package_base,'lib/include/ENCODING'),
os.path.join(this_file,'encoding/kernel/')] os.path.join(this_file,'encoding/src/')]
sources = ['encoding/src/encoding_lib.cpp'] sources = ['encoding/src/encoding_lib.cpp']
headers = ['encoding/src/encoding_lib.h'] headers = ['encoding/src/encoding_lib.h']
defines = [('WITH_CUDA', None)] defines = [('WITH_CUDA', None)]
with_cuda = True with_cuda = True
extra_objects = ['lib/libENCODING.dylib'] if platform.system() == 'Darwin':
extra_objects = [os.path.join(package_base, fname) for fname in extra_objects] ENCODING_LIB = os.path.join(package_base, 'lib/libENCODING.dylib')
else:
ENCODING_LIB = os.path.join(package_base, 'lib/libENCODING.so')
print(extra_objects) def make_relative_rpath(path):
if platform.system() == 'Darwin':
return '-Wl,-rpath,' + path
else:
return '-Wl,-rpath,' + path
ffi = create_extension( ffi = create_extension(
'encoding._ext.encoding_lib', 'encoding._ext.encoding_lib',
...@@ -38,7 +45,10 @@ ffi = create_extension( ...@@ -38,7 +45,10 @@ ffi = create_extension(
relative_to=__file__, relative_to=__file__,
with_cuda=with_cuda, with_cuda=with_cuda,
include_dirs = include_path, include_dirs = include_path,
extra_objects=extra_objects, extra_link_args = [
make_relative_rpath(os.path.join(package_base, 'lib')),
ENCODING_LIB,
],
) )
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -11,17 +11,6 @@ ...@@ -11,17 +11,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.8) CMAKE_POLICY(VERSION 2.8)
OPTION(NDEBUG "disable asserts (WARNING: this may result in silent UB e.g. with out-of-bound indices)")
IF(NOT NDEBUG)
MESSAGE(STATUS "Removing -DNDEBUG from compile flags")
STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS "" ${CMAKE_C_FLAGS})
STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_DEBUG "" ${CMAKE_C_FLAGS_DEBUG})
STRING(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "" ${CMAKE_C_FLAGS_RELEASE})
STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS "" ${CMAKE_CXX_FLAGS})
STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "" ${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE "" ${CMAKE_CXX_FLAGS_RELEASE})
ENDIF()
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindTorch.cmake) INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindTorch.cmake)
#IF(NOT Torch_FOUND) #IF(NOT Torch_FOUND)
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
FILE(GLOB TORCH_LIB_HINTS FILE(GLOB TORCH_LIB_HINTS
"/anaconda/lib/python3.6/site-packages/torch/lib" "/anaconda/lib/python3.6/site-packages/torch/lib"
"/anaconda2/lib/python3.6/site-packages/torch/lib" "/anaconda2/lib/python3.6/site-packages/torch/lib"
"${HOME}/anaconda/lib/python2.7/site-packages/torch/lib" "$ENV{HOME}/anaconda/lib/python2.7/site-packages/torch/lib"
"${HOME}/anaconda2/lib/python2.7/site-packages/torch/lib" "$ENV{HOME}/anaconda2/lib/python2.7/site-packages/torch/lib"
) )
FIND_PATH(TORCH_BUILD_DIR FIND_PATH(TORCH_BUILD_DIR
NAMES "THNN.h" NAMES "THNN.h"
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/ */
#include <THC/THC.h> #include <THC/THC.h>
#include "thc_encoding.h" #include <thc_encoding.h>
extern THCState *state; extern THCState *state;
......
#!/usr/bin/env bash
cd encoding/
mkdir -p build && cd build
cmake ..
make install
cd ../..
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment