未验证 提交 7c36b887 编写于 作者: A Aganlengzi 提交者: GitHub

fix unittests (#49203) (#49210)

上级 fb19648a
...@@ -13,18 +13,19 @@ ...@@ -13,18 +13,19 @@
# limitations under the License. # limitations under the License.
import os import os
from paddle.fluid import core
from distutils.sysconfig import get_python_lib from distutils.sysconfig import get_python_lib
from distutils.core import setup, Extension
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
from paddle.fluid import core
# refer: https://note.qidong.name/2018/03/setup-warning-strict-prototypes # refer: https://note.qidong.name/2018/03/setup-warning-strict-prototypes
# Avoid a gcc warning below: # Avoid a gcc warning below:
# cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid # cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid
# for C/ObjC but not for C++ # for C/ObjC but not for C++
class BuildExt(build_ext): class BuildExt(build_ext):
def build_extensions(self): def build_extensions(self):
if '-Wstrict-prototypes' in self.compiler.compiler_so: if '-Wstrict-prototypes' in self.compiler.compiler_so:
self.compiler.compiler_so.remove('-Wstrict-prototypes') self.compiler.compiler_so.remove('-Wstrict-prototypes')
...@@ -48,8 +49,9 @@ paddle_custom_kernel_include = [ ...@@ -48,8 +49,9 @@ paddle_custom_kernel_include = [
os.path.join(site_packages_path, 'paddle', 'include'), os.path.join(site_packages_path, 'paddle', 'include'),
] ]
# include path third_party # include path third_party
compile_third_party_path = os.path.join(os.environ['PADDLE_BINARY_DIR'], compile_third_party_path = os.path.join(
'third_party') os.environ['PADDLE_BINARY_DIR'], 'third_party'
)
paddle_custom_kernel_include += [ paddle_custom_kernel_include += [
os.path.join(compile_third_party_path, 'install/gflags/include'), # gflags os.path.join(compile_third_party_path, 'install/gflags/include'), # gflags
os.path.join(compile_third_party_path, 'install/glog/include'), # glog os.path.join(compile_third_party_path, 'install/glog/include'), # glog
...@@ -69,10 +71,13 @@ custom_kernel_dot_module = Extension( ...@@ -69,10 +71,13 @@ custom_kernel_dot_module = Extension(
include_dirs=paddle_custom_kernel_include, include_dirs=paddle_custom_kernel_include,
library_dirs=paddle_custom_kernel_library_dir, library_dirs=paddle_custom_kernel_library_dir,
libraries=libs, libraries=libs,
extra_compile_args=paddle_extra_compile_args) extra_compile_args=paddle_extra_compile_args,
)
setup(name='custom_kernel_dot_c', setup(
name='custom_kernel_dot_c',
version='1.0', version='1.0',
description='custom kernel fot compiling', description='custom kernel fot compiling',
cmdclass={'build_ext': BuildExt}, cmdclass={'build_ext': BuildExt},
ext_modules=[custom_kernel_dot_module]) ext_modules=[custom_kernel_dot_module],
)
...@@ -14,18 +14,17 @@ ...@@ -14,18 +14,17 @@
import os import os
import site import site
from paddle.fluid import core from setuptools import Extension, setup
from distutils.sysconfig import get_python_lib
from distutils.core import setup, Extension
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
from paddle.fluid import core
# refer: https://note.qidong.name/2018/03/setup-warning-strict-prototypes # refer: https://note.qidong.name/2018/03/setup-warning-strict-prototypes
# Avoid a gcc warning below: # Avoid a gcc warning below:
# cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid # cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid
# for C/ObjC but not for C++ # for C/ObjC but not for C++
class BuildExt(build_ext): class BuildExt(build_ext):
def build_extensions(self): def build_extensions(self):
if '-Wstrict-prototypes' in self.compiler.compiler_so: if '-Wstrict-prototypes' in self.compiler.compiler_so:
self.compiler.compiler_so.remove('-Wstrict-prototypes') self.compiler.compiler_so.remove('-Wstrict-prototypes')
...@@ -46,12 +45,15 @@ if core.is_compiled_with_npu(): ...@@ -46,12 +45,15 @@ if core.is_compiled_with_npu():
# include path # include path
site_packages_path = site.getsitepackages() site_packages_path = site.getsitepackages()
paddle_custom_kernel_include = list( paddle_custom_kernel_include = list(
map(lambda path: os.path.join(path, 'paddle', 'include'), map(
site_packages_path)) lambda path: os.path.join(path, 'paddle', 'include'), site_packages_path
)
)
# include path third_party # include path third_party
compile_third_party_path = os.path.join(os.environ['PADDLE_BINARY_DIR'], compile_third_party_path = os.path.join(
'third_party') os.environ['PADDLE_BINARY_DIR'], 'third_party'
)
paddle_custom_kernel_include += [ paddle_custom_kernel_include += [
os.path.join(compile_third_party_path, 'install/gflags/include'), # gflags os.path.join(compile_third_party_path, 'install/gflags/include'), # gflags
os.path.join(compile_third_party_path, 'install/glog/include'), # glog os.path.join(compile_third_party_path, 'install/glog/include'), # glog
...@@ -59,7 +61,8 @@ paddle_custom_kernel_include += [ ...@@ -59,7 +61,8 @@ paddle_custom_kernel_include += [
# libs path # libs path
paddle_custom_kernel_library_dir = list( paddle_custom_kernel_library_dir = list(
map(lambda path: os.path.join(path, 'paddle', 'fluid'), site_packages_path)) map(lambda path: os.path.join(path, 'paddle', 'fluid'), site_packages_path)
)
# libs # libs
libs = [':libpaddle.so'] libs = [':libpaddle.so']
...@@ -70,10 +73,13 @@ custom_kernel_dot_module = Extension( ...@@ -70,10 +73,13 @@ custom_kernel_dot_module = Extension(
include_dirs=paddle_custom_kernel_include, include_dirs=paddle_custom_kernel_include,
library_dirs=paddle_custom_kernel_library_dir, library_dirs=paddle_custom_kernel_library_dir,
libraries=libs, libraries=libs,
extra_compile_args=paddle_extra_compile_args) extra_compile_args=paddle_extra_compile_args,
)
setup(name='custom_kernel_dot', setup(
name='custom_kernel_dot',
version='1.0', version='1.0',
description='custom kernel fot compiling', description='custom kernel fot compiling',
cmdclass={'build_ext': BuildExt}, cmdclass={'build_ext': BuildExt},
ext_modules=[custom_kernel_dot_module]) ext_modules=[custom_kernel_dot_module],
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册