-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
64 lines (57 loc) · 2.1 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
"""Install the nativeops package with `pip install .` in this dir."""
import os
from setuptools import setup, find_packages
class MissingTorchInstallationError(Exception):
pass
try:
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
except ModuleNotFoundError as exc:
raise MissingTorchInstallationError(
"Please install PyTorch before proceeding with this installation."
) from exc
TOP_DIR = os.path.dirname(__file__)
FBW_DIR = os.path.join(TOP_DIR, "i6_native_ops/fbw")
WARP_RNNT_DIR = os.path.join(TOP_DIR, "i6_native_ops/warp_rnnt")
FAST_VITERBI_DIR = os.path.join(TOP_DIR, "i6_native_ops/fast_viterbi")
MONOTONIC_RNNT_DIR = os.path.join(TOP_DIR, "i6_native_ops/monotonic_rnnt")
COMMON_DIR = os.path.join(TOP_DIR, "i6_native_ops/common")
setup(
name="i6 native ops",
packages=find_packages(),
ext_modules=[
CUDAExtension(
name="i6_native_ops.fbw.fbw_core",
sources=[f"{FBW_DIR}/fbw_torch.cpp", f"{FBW_DIR}/fbw_op.cu"],
include_dirs=[FBW_DIR, COMMON_DIR],
),
CUDAExtension(
name="i6_native_ops.warp_rnnt.warp_rnnt_core",
sources=[
f"{WARP_RNNT_DIR}/binding.cpp",
f"{WARP_RNNT_DIR}/core_compact.cu",
f"{WARP_RNNT_DIR}/core.cu",
f"{WARP_RNNT_DIR}/core_gather.cu",
],
include_dirs=[WARP_RNNT_DIR],
),
CUDAExtension(
name="i6_native_ops.fast_viterbi.fast_viterbi_core",
sources=[
f"{FAST_VITERBI_DIR}/binding.cpp",
f"{FAST_VITERBI_DIR}/core.cu",
],
include_dirs=[FAST_VITERBI_DIR, COMMON_DIR],
),
CUDAExtension(
name="i6_native_ops.monotonic_rnnt.monotonic_rnnt_core",
sources=[f"{MONOTONIC_RNNT_DIR}/monotonic_rnnt.cu"],
include_dirs=[f"{MONOTONIC_RNNT_DIR}/include"],
extra_compile_args=["-DRNNT_ENABLE_GPU"],
),
],
cmdclass={
"build_ext": BuildExtension,
},
version="0.0.1",
url="https://github.com/rwth-i6/i6_native_ops",
)