-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsetup.py
67 lines (58 loc) · 2.79 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import setuptools
import setuptools.command.build_ext
import distutils.errors
import distutils.sysconfig
import openembedding_setup
work_path = os.path.dirname(os.path.realpath(__file__)) + '/'
cpp_flags = ['--std=c++14', '-Wall', '-Wextra', '-frecord-gcc-switches', '-fPIC']
link_flags = ['-lcexb_pack', '-L' + work_path + 'openembedding']
libexb = setuptools.Extension('openembedding.libexb', [])
tensorflow_exb_ops = setuptools.Extension('openembedding.tensorflow.exb_ops', [])
class custom_build_ext(setuptools.command.build_ext.build_ext):
def build_extensions(self):
self.build_core_extension()
self.build_tensorflow_extension()
def build_core_extension(self):
import pybind11
libexb.sources = ['openembedding/entry/py_api.cc']
libexb.extra_compile_args = cpp_flags + ['-I' + pybind11.get_include()]
libexb.extra_link_args = link_flags
distutils.sysconfig.customize_compiler(self.compiler)
self.build_extension(libexb)
def build_tensorflow_extension(self):
import tensorflow as tf
tensorflow_exb_ops.sources = ['openembedding/tensorflow/exb_ops.cpp']
tensorflow_exb_ops.extra_compile_args = cpp_flags + tf.sysconfig.get_compile_flags()
tensorflow_exb_ops.extra_link_args = link_flags + tf.sysconfig.get_link_flags()
distutils.sysconfig.customize_compiler(self.compiler)
self.build_extension(tensorflow_exb_ops)
import textwrap
setuptools.setup(
name='openembedding',
version=openembedding_setup.__version__,
description='Distributed framework to accelerate training and support serving.',
author='4paradigm',
author_email='[email protected]',
long_description=textwrap.dedent('''\
OpenEmbedding is a distributed framework to accelerate TensorFlow training and
support TensorFlow Serving. It uses the parameter server architecture to store
the Embedding Layer. So that single machine memory is not the limit of model size.
OpenEmbedding can cooperate with all-reduce framework to support both data parallel
and model parallel.'''),
url='https://github.com/4paradigm/OpenEmbedding',
keywords=['deep learning', 'tensorflow', 'keras', 'AI'],
classifiers=[
'Programming Language :: Python :: 3',
'Development Status :: 2 - Pre-Alpha',
'Operating System :: POSIX :: Linux',
'License :: OSI Approved :: Apache Software License'],
python_requires='>=3.6',
setup_requires=['pybind11'],
extras_require={'tensorflow':['tensorflow']},
packages=setuptools.find_packages(),
package_data={'': [work_path + 'openembedding/libcexb_pack.so']},
ext_modules=[libexb, tensorflow_exb_ops],
cmdclass={'build_ext': custom_build_ext})