aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/cmake/tf_core_ops.cmake
blob: 2aa03facafb4b4521c5d3cd41a2304287fd7a0d7 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#def tf_gen_op_libs(op_lib_names):
#  # Make library out of each op so it can also be used to generate wrappers
#  # for various languages.
#  for n in op_lib_names:
#    native.cc_library(name=n + "_op_lib"
#                      copts=tf_copts(),
#                      srcs=["ops/" + n + ".cc"],
#                      deps=(["//tensorflow/core:framework"]),
#                      visibility=["//visibility:public"],
#                      alwayslink=1,
#                      linkstatic=1,)


set(tf_op_lib_names
    "array_ops"
    "attention_ops"
    "candidate_sampling_ops"
    "control_flow_ops"
    "ctc_ops"
    "data_flow_ops"
    "image_ops"
    "io_ops"
    "linalg_ops"
    "logging_ops"
    "functional_ops"
    "math_ops"
    "nn_ops"
    "no_op"
    "parsing_ops"
    "random_ops"
    "script_ops"
    "sendrecv_ops"
    "sparse_ops"
    "state_ops"
    "string_ops"
    "summary_ops"
    "training_ops"
)

foreach(tf_op_lib_name ${tf_op_lib_names})
    ########################################################
    # tf_${tf_op_lib_name} library
    ########################################################
    file(GLOB tf_${tf_op_lib_name}_srcs
        "${tensorflow_source_dir}/tensorflow/core/ops/${tf_op_lib_name}.cc"
    )

    add_library(tf_${tf_op_lib_name} OBJECT ${tf_${tf_op_lib_name}_srcs})

    add_dependencies(tf_${tf_op_lib_name} tf_core_framework)

    target_include_directories(tf_${tf_op_lib_name} PRIVATE
        ${tensorflow_source_dir}
        ${eigen_INCLUDE_DIRS}
    )

    target_compile_options(tf_${tf_op_lib_name} PRIVATE
        -fno-exceptions
        -DEIGEN_AVOID_STL_ARRAY
    )

    # C++11
    target_compile_features(tf_${tf_op_lib_name} PRIVATE
        cxx_rvalue_references
    )
endforeach()

#cc_library(
#    name = "user_ops_op_lib"
#    srcs = glob(["user_ops/**/*.cc"]),
#    copts = tf_copts(),
#    linkstatic = 1,
#    visibility = ["//visibility:public"],
#    deps = [":framework"],
#    alwayslink = 1,
#)
########################################################
# tf_user_ops library
########################################################
file(GLOB_RECURSE tf_user_ops_srcs
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*.cc"
)

add_library(tf_user_ops OBJECT ${tf_user_ops_srcs})

add_dependencies(tf_user_ops tf_core_framework)

target_include_directories(tf_user_ops PRIVATE
    ${tensorflow_source_dir}
    ${eigen_INCLUDE_DIRS}
)

target_compile_options(tf_user_ops PRIVATE
    -fno-exceptions
    -DEIGEN_AVOID_STL_ARRAY
)

# C++11
target_compile_features(tf_user_ops PRIVATE
    cxx_rvalue_references
)


#tf_cuda_library(
#    name = "ops"
#    srcs = glob(
#        [
#            "ops/**/*.h"
#            "ops/**/*.cc"
#            "user_ops/**/*.h"
#            "user_ops/**/*.cc"
#        ],
#        exclude = [
#            "**/*test*"
#            "**/*main.cc"
#            "user_ops/**/*.cu.cc"
#        ],
#    ),
#    copts = tf_copts(),
#    linkstatic = 1,
#    visibility = ["//visibility:public"],
#    deps = [
#        ":core"
#        ":lib"
#        ":protos_cc"
#        "//tensorflow/models/embedding:word2vec_ops"
#        "//third_party/eigen3"
#    ],
#    alwayslink = 1,
#)

########################################################
# tf_core_ops library
########################################################
file(GLOB_RECURSE tf_core_ops_srcs
    "${tensorflow_source_dir}/tensorflow/core/ops/*.h"
    "${tensorflow_source_dir}/tensorflow/core/ops/*.cc"
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*.h"
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*.cc"
)

file(GLOB_RECURSE tf_core_ops_exclude_srcs
    "${tensorflow_source_dir}/tensorflow/core/ops/*test*.h"
    "${tensorflow_source_dir}/tensorflow/core/ops/*test*.cc"
    "${tensorflow_source_dir}/tensorflow/core/ops/*main.cc"
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*test*.h"
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*test*.cc"
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*main.cc"
    "${tensorflow_source_dir}/tensorflow/core/user_ops/*.cu.cc"
)

list(REMOVE_ITEM tf_core_ops_srcs ${tf_core_ops_exclude_srcs}) 

add_library(tf_core_ops OBJECT ${tf_core_ops_srcs})

add_dependencies(tf_core_ops tf_core_cpu)

target_include_directories(tf_core_ops PRIVATE
    ${tensorflow_source_dir}
    ${eigen_INCLUDE_DIRS}
)

#target_link_libraries(tf_core_ops
#    ${CMAKE_THREAD_LIBS_INIT}
#    ${PROTOBUF_LIBRARIES}
#    tf_protos_cc
#    tf_core_lib
#    tf_core_cpu
#    tf_models_word2vec_ops
#)

target_compile_options(tf_core_ops PRIVATE
    -fno-exceptions
    -DEIGEN_AVOID_STL_ARRAY
)

# C++11
target_compile_features(tf_core_ops PRIVATE
    cxx_rvalue_references
)