| 1 |
# |
| 2 |
# Description: |
| 3 |
# gemmlowp is a small self-contained low-precision GEMM library. |
| 4 |
# https://github.com/google/gemmlowp |
| 5 |
|
| 6 |
licenses(["notice"]) # Apache 2.0 |
| 7 |
|
| 8 |
exports_files(["LICENSE"]) |
| 9 |
|
| 10 |
config_setting( |
| 11 |
name = "windows", |
| 12 |
values = { |
| 13 |
"cpu": "x64_windows", |
| 14 |
}, |
| 15 |
) |
| 16 |
|
| 17 |
config_setting( |
| 18 |
name = "android", |
| 19 |
values = { |
| 20 |
"crosstool_top": "//external:android/crosstool", |
| 21 |
}, |
| 22 |
) |
| 23 |
|
| 24 |
load(":flags.bzl", "LIB_COPTS", "LIB_LINKOPTS", "BIN_LINKOPTS") |
| 25 |
|
| 26 |
filegroup( |
| 27 |
name = "gemmlowp_private_headers", |
| 28 |
srcs = glob([ |
| 29 |
"fixedpoint/*.h", |
| 30 |
"internal/*.h", |
| 31 |
]), |
| 32 |
visibility = ["//visibility:private"], |
| 33 |
) |
| 34 |
|
| 35 |
filegroup( |
| 36 |
name = "gemmlowp_public_headers", |
| 37 |
srcs = glob([ |
| 38 |
"meta/*.h", |
| 39 |
"public/*.h", |
| 40 |
"profiling/*.h", |
| 41 |
]), |
| 42 |
visibility = ["//visibility:public"], |
| 43 |
) |
| 44 |
|
| 45 |
filegroup( |
| 46 |
name = "gemmlowp_headers", |
| 47 |
srcs = [ |
| 48 |
":gemmlowp_private_headers", |
| 49 |
":gemmlowp_public_headers", |
| 50 |
], |
| 51 |
visibility = ["//visibility:private"], |
| 52 |
) |
| 53 |
|
| 54 |
filegroup( |
| 55 |
name = "eight_bit_int_gemm_headers", |
| 56 |
srcs = glob(["eight_bit_int_gemm/*.h"]), |
| 57 |
visibility = ["//visibility:private"], |
| 58 |
) |
| 59 |
|
| 60 |
filegroup( |
| 61 |
name = "eight_bit_int_gemm_public_headers", |
| 62 |
srcs = [ |
| 63 |
":eight_bit_int_gemm_headers", |
| 64 |
":gemmlowp_public_headers", |
| 65 |
], |
| 66 |
visibility = ["//visibility:public"], |
| 67 |
) |
| 68 |
|
| 69 |
filegroup( |
| 70 |
name = "eight_bit_int_gemm_sources_with_no_headers", |
| 71 |
srcs = glob(["eight_bit_int_gemm/*.cc"]), |
| 72 |
visibility = ["//visibility:private"], |
| 73 |
) |
| 74 |
|
| 75 |
filegroup( |
| 76 |
name = "eight_bit_int_gemm_sources", |
| 77 |
srcs = [ |
| 78 |
":eight_bit_int_gemm_headers", |
| 79 |
":eight_bit_int_gemm_sources_with_no_headers", |
| 80 |
":gemmlowp_headers", |
| 81 |
], |
| 82 |
visibility = ["//visibility:public"], |
| 83 |
) |
| 84 |
|
| 85 |
filegroup( |
| 86 |
name = "gemmlowp_test_headers", |
| 87 |
srcs = [":gemmlowp_headers"] + glob(["test/*.h"]), |
| 88 |
visibility = ["//visibility:private"], |
| 89 |
) |
| 90 |
|
| 91 |
filegroup( |
| 92 |
name = "fixedpoint_private_headers", |
| 93 |
srcs = glob([ |
| 94 |
"fixedpoint/*.h", |
| 95 |
]) + [ |
| 96 |
"internal/common.h", |
| 97 |
"internal/detect_platform.h", |
| 98 |
], |
| 99 |
visibility = ["//visibility:private"], |
| 100 |
) |
| 101 |
|
| 102 |
cc_library( |
| 103 |
name = "fixedpoint", |
| 104 |
srcs = [ |
| 105 |
":fixedpoint_private_headers", |
| 106 |
], |
| 107 |
hdrs = [ |
| 108 |
"fixedpoint/fixedpoint.h", |
| 109 |
], |
| 110 |
# Blaze warning: |
| 111 |
# "setting 'linkstatic=1' is recommended if there are no object files." |
| 112 |
linkstatic = 1, |
| 113 |
visibility = ["//visibility:public"], |
| 114 |
) |
| 115 |
|
| 116 |
cc_library( |
| 117 |
name = "gemmlowp", |
| 118 |
hdrs = [":gemmlowp_headers"], |
| 119 |
linkopts = LIB_LINKOPTS, |
| 120 |
# Blaze warning: |
| 121 |
# "setting 'linkstatic=1' is recommended if there are no object files." |
| 122 |
linkstatic = 1, |
| 123 |
visibility = ["//visibility:public"], |
| 124 |
deps = [":fixedpoint"], |
| 125 |
) |
| 126 |
|
| 127 |
cc_library( |
| 128 |
name = "eight_bit_int_gemm", |
| 129 |
srcs = [":eight_bit_int_gemm_sources_with_no_headers"], |
| 130 |
hdrs = [ |
| 131 |
":eight_bit_int_gemm_headers", |
| 132 |
":gemmlowp_private_headers", |
| 133 |
":gemmlowp_public_headers", |
| 134 |
], |
| 135 |
copts = LIB_COPTS, |
| 136 |
linkopts = LIB_LINKOPTS, |
| 137 |
visibility = ["//visibility:public"], |
| 138 |
deps = [":gemmlowp"], |
| 139 |
) |
| 140 |
|
| 141 |
cc_library( |
| 142 |
name = "profiler", |
| 143 |
hdrs = [ |
| 144 |
"profiling/instrumentation.h", |
| 145 |
"profiling/profiler.h", |
| 146 |
"profiling/pthread_everywhere.h", |
| 147 |
], |
| 148 |
visibility = ["//visibility:public"], |
| 149 |
) |
| 150 |
|
| 151 |
# The main gemmlowp unit test |
| 152 |
cc_test( |
| 153 |
name = "test", |
| 154 |
size = "medium", |
| 155 |
srcs = [ |
| 156 |
"test/test.cc", |
| 157 |
"test/test_data.cc", |
| 158 |
":gemmlowp_test_headers", |
| 159 |
], |
| 160 |
copts = ["-O3"], |
| 161 |
deps = [":eight_bit_int_gemm"], |
| 162 |
) |
| 163 |
|
| 164 |
# Math helpers test |
| 165 |
cc_test( |
| 166 |
name = "test_math_helpers", |
| 167 |
size = "small", |
| 168 |
srcs = [ |
| 169 |
"test/test_math_helpers.cc", |
| 170 |
":gemmlowp_test_headers", |
| 171 |
], |
| 172 |
) |
| 173 |
|
| 174 |
# BlockingCounter test |
| 175 |
cc_test( |
| 176 |
name = "test_blocking_counter", |
| 177 |
size = "medium", |
| 178 |
srcs = [ |
| 179 |
"test/test_blocking_counter.cc", |
| 180 |
":gemmlowp_test_headers", |
| 181 |
], |
| 182 |
linkopts = BIN_LINKOPTS, |
| 183 |
) |
| 184 |
|
| 185 |
# Allocator test |
| 186 |
cc_test( |
| 187 |
name = "test_allocator", |
| 188 |
size = "small", |
| 189 |
srcs = [ |
| 190 |
"test/test_allocator.cc", |
| 191 |
":gemmlowp_test_headers", |
| 192 |
], |
| 193 |
) |
| 194 |
|
| 195 |
# FixedPoint test |
| 196 |
cc_test( |
| 197 |
name = "test_fixedpoint", |
| 198 |
size = "small", |
| 199 |
srcs = [ |
| 200 |
"test/test_fixedpoint.cc", |
| 201 |
":gemmlowp_test_headers", |
| 202 |
], |
| 203 |
) |
| 204 |
|
| 205 |
# Benchmark |
| 206 |
cc_binary( |
| 207 |
name = "benchmark", |
| 208 |
srcs = [ |
| 209 |
"test/benchmark.cc", |
| 210 |
":gemmlowp_test_headers", |
| 211 |
], |
| 212 |
copts = [ |
| 213 |
"-O3", |
| 214 |
"-DNDEBUG", |
| 215 |
], |
| 216 |
linkopts = BIN_LINKOPTS, |
| 217 |
) |
| 218 |
|
| 219 |
# Benchmark |
| 220 |
cc_binary( |
| 221 |
name = "benchmark_profile", |
| 222 |
srcs = [ |
| 223 |
"test/benchmark.cc", |
| 224 |
":gemmlowp_test_headers", |
| 225 |
], |
| 226 |
copts = [ |
| 227 |
"-O3", |
| 228 |
"-DNDEBUG", |
| 229 |
"-DGEMMLOWP_TEST_PROFILE", |
| 230 |
], |
| 231 |
linkopts = BIN_LINKOPTS, |
| 232 |
) |