Skip to content

Commit f3e1530

Browse files
lu-wang-gtflite-support-robot
authored andcommitted
Move Task BertNLClassifier into the root dir of task/text
Matching the directory structure of other domains, such as vision and audio PiperOrigin-RevId: 398849802
1 parent 5e75502 commit f3e1530

File tree

11 files changed

+57
-55
lines changed

11 files changed

+57
-55
lines changed

tensorflow_lite_support/c/task/text/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ cc_library_with_tflite(
4444
"nl_classifier_common.h",
4545
],
4646
tflite_deps = [
47-
"//tensorflow_lite_support/cc/task/text/nlclassifier:bert_nl_classifier",
47+
"//tensorflow_lite_support/cc/task/text:bert_nl_classifier",
4848
],
4949
deps = [
5050
":nl_classifier_common",

tensorflow_lite_support/c/task/text/bert_nl_classifier.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ limitations under the License.
1919

2020
#include "external/com_google_absl/absl/strings/string_view.h"
2121
#include "tensorflow_lite_support/cc/task/core/category.h"
22-
#include "tensorflow_lite_support/cc/task/text/nlclassifier/bert_nl_classifier.h"
22+
#include "tensorflow_lite_support/cc/task/text/bert_nl_classifier.h"
2323
#include "tensorflow_lite_support/cc/task/text/proto/bert_nl_classifier_options_proto_inc.h"
2424

2525
namespace {
2626
using CategoryCpp = ::tflite::task::core::Category;
27-
using BertNLClassifierCpp =
28-
::tflite::task::text::nlclassifier::BertNLClassifier;
27+
using BertNLClassifierCpp = ::tflite::task::text::BertNLClassifier;
2928
using BertNLClassifierOptionsCpp =
3029
::tflite::task::text::BertNLClassifierOptions;
3130

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
load(
2+
"@org_tensorflow//tensorflow/lite/core/shims:cc_library_with_tflite.bzl",
3+
"cc_library_with_tflite",
4+
)
5+
6+
package(
7+
default_visibility = ["//tensorflow_lite_support:users"],
8+
licenses = ["notice"], # Apache 2.0
9+
)
10+
11+
cc_library_with_tflite(
12+
name = "bert_nl_classifier",
13+
srcs = [
14+
"bert_nl_classifier.cc",
15+
],
16+
hdrs = [
17+
"bert_nl_classifier.h",
18+
],
19+
tflite_deps = [
20+
"//tensorflow_lite_support/cc/task/text/nlclassifier:nl_classifier",
21+
"@org_tensorflow//tensorflow/lite/core/shims:builtin_ops",
22+
"//tensorflow_lite_support/cc/task/core:task_api_factory",
23+
],
24+
deps = [
25+
"//tensorflow_lite_support/cc:common",
26+
"//tensorflow_lite_support/cc/port:status_macros",
27+
"//tensorflow_lite_support/cc/task/core:category",
28+
"//tensorflow_lite_support/cc/task/core:task_utils",
29+
"//tensorflow_lite_support/cc/task/text/proto:bert_nl_classifier_options_proto_inc",
30+
"//tensorflow_lite_support/cc/text/tokenizers:tokenizer",
31+
"//tensorflow_lite_support/cc/text/tokenizers:tokenizer_utils",
32+
"//tensorflow_lite_support/metadata/cc:metadata_extractor",
33+
"@com_google_absl//absl/base:core_headers",
34+
"@com_google_absl//absl/status",
35+
"@com_google_absl//absl/strings",
36+
"@com_google_absl//absl/strings:str_format",
37+
"@org_tensorflow//tensorflow/lite:string",
38+
"@org_tensorflow//tensorflow/lite/c:common",
39+
"@org_tensorflow//tensorflow/lite/core/api",
40+
],
41+
)

tensorflow_lite_support/cc/task/text/nlclassifier/bert_nl_classifier.cc renamed to tensorflow_lite_support/cc/task/text/bert_nl_classifier.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#include "tensorflow_lite_support/cc/task/text/nlclassifier/bert_nl_classifier.h"
16+
#include "tensorflow_lite_support/cc/task/text/bert_nl_classifier.h"
1717

1818
#include <stddef.h>
1919

@@ -41,7 +41,6 @@ limitations under the License.
4141
namespace tflite {
4242
namespace task {
4343
namespace text {
44-
namespace nlclassifier {
4544

4645
using ::tflite::support::CreateStatusWithPayload;
4746
using ::tflite::support::StatusOr;
@@ -182,7 +181,6 @@ absl::Status BertNLClassifier::Initialize(
182181
return absl::OkStatus();
183182
}
184183

185-
} // namespace nlclassifier
186184
} // namespace text
187185
} // namespace task
188186
} // namespace tflite

tensorflow_lite_support/cc/task/text/nlclassifier/bert_nl_classifier.h renamed to tensorflow_lite_support/cc/task/text/bert_nl_classifier.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#ifndef TENSORFLOW_LITE_SUPPORT_CC_TASK_TEXT_NLCLASSIFIER_BERT_NL_CLASSIFIER_H_
17-
#define TENSORFLOW_LITE_SUPPORT_CC_TASK_TEXT_NLCLASSIFIER_BERT_NL_CLASSIFIER_H_
16+
#ifndef TENSORFLOW_LITE_SUPPORT_CC_TASK_NLCLASSIFIER_BERT_NL_CLASSIFIER_H_
17+
#define TENSORFLOW_LITE_SUPPORT_CC_TASK_NLCLASSIFIER_BERT_NL_CLASSIFIER_H_
1818

1919
#include <stddef.h>
2020

@@ -36,7 +36,6 @@ limitations under the License.
3636
namespace tflite {
3737
namespace task {
3838
namespace text {
39-
namespace nlclassifier {
4039

4140
// Classifier API for NLClassification tasks with Bert models, categorizes
4241
// string into different classes.
@@ -50,9 +49,9 @@ namespace nlclassifier {
5049
// with one label per line, the number of labels should match the number of
5150
// categories the model outputs.
5251

53-
class BertNLClassifier : public NLClassifier {
52+
class BertNLClassifier : public tflite::task::text::nlclassifier::NLClassifier {
5453
public:
55-
using NLClassifier::NLClassifier;
54+
using tflite::task::text::nlclassifier::NLClassifier::NLClassifier;
5655

5756
// Factory function to create a BertNLClassifier from BertNLClassifierOptions.
5857
static tflite::support::StatusOr<std::unique_ptr<BertNLClassifier>>
@@ -127,9 +126,8 @@ class BertNLClassifier : public NLClassifier {
127126
std::unique_ptr<BertNLClassifierOptions> options_;
128127
};
129128

130-
} // namespace nlclassifier
131129
} // namespace text
132130
} // namespace task
133131
} // namespace tflite
134132

135-
#endif // TENSORFLOW_LITE_SUPPORT_CC_TASK_TEXT_NLCLASSIFIER_BERT_NL_CLASSIFIER_H_
133+
#endif // TENSORFLOW_LITE_SUPPORT_CC_TASK_NLCLASSIFIER_BERT_NL_CLASSIFIER_H_

tensorflow_lite_support/cc/task/text/nlclassifier/BUILD

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,3 @@ cc_library_with_tflite(
4343
"@org_tensorflow//tensorflow/lite/kernels/internal:tensor",
4444
],
4545
)
46-
47-
cc_library_with_tflite(
48-
name = "bert_nl_classifier",
49-
srcs = [
50-
"bert_nl_classifier.cc",
51-
],
52-
hdrs = [
53-
"bert_nl_classifier.h",
54-
],
55-
tflite_deps = [
56-
":nl_classifier",
57-
"@org_tensorflow//tensorflow/lite/core/shims:builtin_ops",
58-
"//tensorflow_lite_support/cc/task/core:task_api_factory",
59-
],
60-
deps = [
61-
"//tensorflow_lite_support/cc:common",
62-
"//tensorflow_lite_support/cc/port:status_macros",
63-
"//tensorflow_lite_support/cc/task/core:category",
64-
"//tensorflow_lite_support/cc/task/core:task_utils",
65-
"//tensorflow_lite_support/cc/task/text/proto:bert_nl_classifier_options_proto_inc",
66-
"//tensorflow_lite_support/cc/text/tokenizers:tokenizer",
67-
"//tensorflow_lite_support/cc/text/tokenizers:tokenizer_utils",
68-
"//tensorflow_lite_support/metadata/cc:metadata_extractor",
69-
"@com_google_absl//absl/base:core_headers",
70-
"@com_google_absl//absl/status",
71-
"@com_google_absl//absl/strings",
72-
"@com_google_absl//absl/strings:str_format",
73-
"@org_tensorflow//tensorflow/lite:string",
74-
"@org_tensorflow//tensorflow/lite/c:common",
75-
"@org_tensorflow//tensorflow/lite/core/api",
76-
],
77-
)

tensorflow_lite_support/examples/task/text/desktop/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cc_binary(
4747
"@com_google_absl//absl/strings:str_format",
4848
"//tensorflow_lite_support/cc/port:statusor",
4949
"//tensorflow_lite_support/cc/task/core:category",
50-
"//tensorflow_lite_support/cc/task/text/nlclassifier:bert_nl_classifier",
50+
"//tensorflow_lite_support/cc/task/text:bert_nl_classifier",
5151
] + select({
5252
"//tensorflow_lite_support/examples/task:darwinn_portable": [
5353
"//tensorflow_lite_support/acceleration/configuration:edgetpu_coral_plugin",

tensorflow_lite_support/examples/task/text/desktop/bert_nl_classifier_demo.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ limitations under the License.
2121
#include "external/com_google_absl/absl/strings/str_format.h"
2222
#include "tensorflow_lite_support/cc/port/statusor.h"
2323
#include "tensorflow_lite_support/cc/task/core/category.h"
24-
#include "tensorflow_lite_support/cc/task/text/nlclassifier/bert_nl_classifier.h"
24+
#include "tensorflow_lite_support/cc/task/text/bert_nl_classifier.h"
2525

2626
ABSL_FLAG(std::string, model_path, "",
2727
"Absolute path to the '.tflite' bert classification model.");
@@ -33,7 +33,6 @@ ABSL_FLAG(bool, use_coral, false,
3333
namespace tflite {
3434
namespace task {
3535
namespace text {
36-
namespace nlclassifier {
3736

3837
namespace {
3938
using std::chrono::microseconds;
@@ -75,7 +74,6 @@ absl::Status Classify() {
7574
return absl::OkStatus();
7675
}
7776

78-
} // namespace nlclassifier
7977
} // namespace text
8078
} // namespace task
8179
} // namespace tflite
@@ -93,7 +91,7 @@ int main(int argc, char** argv) {
9391
}
9492

9593
// Run classification.
96-
absl::Status status = tflite::task::text::nlclassifier::Classify();
94+
absl::Status status = tflite::task::text::Classify();
9795
if (status.ok()) {
9896
return 0;
9997
} else {

tensorflow_lite_support/java/src/native/task/text/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jni_binary_with_tflite(
2323
linkscript = "//tensorflow_lite_support/java:default_version_script.lds",
2424
tflite_deps = [
2525
"//tensorflow_lite_support/cc/task/text/nlclassifier:nl_classifier",
26-
"//tensorflow_lite_support/cc/task/text/nlclassifier:bert_nl_classifier",
26+
"//tensorflow_lite_support/cc/task/text:bert_nl_classifier",
2727
"//tensorflow_lite_support/cc/task/text/qa:bert_question_answerer",
2828
"//tensorflow_lite_support/cc/utils:jni_utils",
2929
"//tensorflow_lite_support/java/src/native/task/text/nlclassifier:nl_classifier_jni_utils",

tensorflow_lite_support/java/src/native/task/text/nlclassifier/bert/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jni_binary_with_tflite(
2323
],
2424
linkscript = "//tensorflow_lite_support/java:default_version_script.lds",
2525
tflite_deps = [
26-
"//tensorflow_lite_support/cc/task/text/nlclassifier:bert_nl_classifier",
26+
"//tensorflow_lite_support/cc/task/text:bert_nl_classifier",
2727
"//tensorflow_lite_support/cc/utils:jni_utils",
2828
"//tensorflow_lite_support/java/src/native/task/text/nlclassifier:nl_classifier_jni_utils",
2929
],

0 commit comments

Comments
 (0)