aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/tools/accuracy/ilsvrc/BUILD
blob: 98e2835b2ebd2f7918a939fb89aebec0fd54fb43 (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
package(default_visibility = [
    "//visibility:public",
])

licenses(["notice"])  # Apache 2.0

load("//tensorflow:tensorflow.bzl", "tf_cc_binary", "tf_cc_test")
load("//tensorflow/contrib/lite:build_def.bzl", "tflite_copts", "tflite_linkopts")
load("//tensorflow/contrib/lite:special_rules.bzl", "tflite_portable_test_suite")

common_linkopts = tflite_linkopts() + select({
    "//conditions:default": [],
    "//tensorflow:android": [
        "-pie",
        "-llog",
    ],
})

cc_library(
    name = "inception_preprocessing",
    srcs = ["inception_preprocessing.cc"],
    hdrs = ["inception_preprocessing.h"],
    copts = tflite_copts(),
    deps = [
        "//tensorflow/contrib/lite/tools/accuracy:android_required_build_flags",
        "//tensorflow/contrib/lite/tools/accuracy:stage",
        "//tensorflow/cc:cc_ops",
        "//tensorflow/cc:scope",
    ] + select(
        {
            "//tensorflow:android": [
                "//tensorflow/core:android_tensorflow_lib",
                "//tensorflow/core/kernels:android_tensorflow_image_op",
            ],
            "//conditions:default": [
                "//tensorflow/core:tensorflow",
                "//tensorflow/core:protos_all_cc",
                "//tensorflow/core:core_cpu",
                "//tensorflow/core:framework",
                "//tensorflow/core:lib",
                "//tensorflow/core:ops",
            ],
        },
    ),
)

tf_cc_test(
    name = "inception_preprocessing_test",
    srcs = ["inception_preprocessing_test.cc"],
    args = [
        "--test_image=$(location :testdata/grace_hopper.jpg)",
    ],
    data = [":testdata/grace_hopper.jpg"],
    linkopts = common_linkopts,
    linkstatic = 1,
    tags = [
        "no_oss",  # b/114307765
        "tflite_not_portable_android",
        "tflite_not_portable_ios",
    ],
    deps = [
        ":inception_preprocessing",
        "//tensorflow/contrib/lite/tools/accuracy:android_required_build_flags",
        "@com_google_googletest//:gtest",
    ] + select(
        {
            "//tensorflow:android": [
                "//tensorflow/core:android_tensorflow_lib",
                "//tensorflow/core:android_tensorflow_test_lib",
            ],
            "//conditions:default": [
                "//tensorflow/core:core_cpu",
                "//tensorflow/core:framework_internal",
                "//tensorflow/core:lib",
            ],
        },
    ),
)

cc_library(
    name = "imagenet_topk_eval",
    srcs = ["imagenet_topk_eval.cc"],
    hdrs = ["imagenet_topk_eval.h"],
    copts = tflite_copts(),
    deps = [
        "//tensorflow/contrib/lite/tools/accuracy:accuracy_eval_stage",
    ] + select(
        {
            "//tensorflow:android": [
                "//tensorflow/core:android_tensorflow_lib",
            ],
            "//conditions:default": [
                "//tensorflow/core:framework",
                "//tensorflow/core:lib",
            ],
        },
    ),
)

tf_cc_test(
    name = "imagenet_topk_eval_test",
    srcs = ["imagenet_topk_eval_test.cc"],
    linkopts = common_linkopts,
    linkstatic = 1,
    tags = ["tflite_not_portable_ios"],
    deps = [
        ":imagenet_topk_eval",
        "@com_google_googletest//:gtest",
    ] + select(
        {
            "//tensorflow:android": [
                "//tensorflow/core:android_tensorflow_lib",
                "//tensorflow/core:android_tensorflow_test_lib",
            ],
            "//conditions:default": [
                "//tensorflow/core:framework",
            ],
        },
    ),
)

cc_library(
    name = "imagenet_model_evaluator",
    srcs = ["imagenet_model_evaluator.cc"],
    hdrs = ["imagenet_model_evaluator.h"],
    copts = tflite_copts(),
    deps = [
        ":imagenet_topk_eval",
        ":inception_preprocessing",
        "//tensorflow/contrib/lite/tools/accuracy:android_required_build_flags",
        "//tensorflow/contrib/lite/tools/accuracy:eval_pipeline",
        "//tensorflow/contrib/lite/tools/accuracy:eval_pipeline_builder",
        "//tensorflow/contrib/lite/tools/accuracy:file_reader_stage",
        "//tensorflow/contrib/lite/tools/accuracy:run_tflite_model_stage",
        "//tensorflow/contrib/lite/tools/accuracy:utils",
        "@com_google_absl//absl/memory",
        "//tensorflow/cc:cc_ops",
        "//tensorflow/cc:scope",
    ] + select(
        {
            "//tensorflow:android": [
                "//tensorflow/core:android_tensorflow_lib",
                "//tensorflow/core/kernels:android_whole_file_read_ops",
                "//tensorflow/core/kernels:android_tensorflow_image_op",
            ],
            "//conditions:default": [
                "//tensorflow/core:tensorflow",
                "//tensorflow/core:lib_internal",
                "//tensorflow/core:framework_internal",
                "//tensorflow/core:framework",
                "//tensorflow/core:lib",
                "//tensorflow/core:core_cpu",
            ],
        },
    ),
)

tf_cc_binary(
    name = "imagenet_accuracy_eval",
    srcs = ["imagenet_accuracy_eval.cc"],
    copts = tflite_copts(),
    linkopts = common_linkopts,
    deps = [
        ":imagenet_model_evaluator",
        ":imagenet_topk_eval",
        "@com_google_absl//absl/memory",
        "//tensorflow/contrib/lite/tools/accuracy:android_required_build_flags",
        "//tensorflow/contrib/lite/tools/accuracy:csv_writer",
    ] + select(
        {
            "//tensorflow:android": [
                "//tensorflow/core:android_tensorflow_lib",
            ],
            "//conditions:default": [
                "//tensorflow/core:lib",
                "//tensorflow/core:framework_internal",
            ],
        },
    ),
)

tflite_portable_test_suite()