chromium/third_party/tflite_support/src/tensorflow_lite_support/cc/task/text/nlclassifier/nl_classifier.cc

/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow_lite_support/cc/task/text/nlclassifier/nl_classifier.h"

#include <cstddef>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "absl/algorithm/container.h"  // from @com_google_absl
#include "absl/status/status.h"  // from @com_google_absl
#include "absl/strings/str_cat.h"  // from @com_google_absl
#include "absl/strings/string_view.h"  // from @com_google_absl
#include "flatbuffers/flatbuffers.h"  // from @flatbuffers
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/core/api/op_resolver.h"
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
#include "tensorflow_lite_support/cc/common.h"
#include "tensorflow_lite_support/cc/port/status_macros.h"
#include "tensorflow_lite_support/cc/port/statusor.h"
#include "tensorflow_lite_support/cc/task/core/category.h"
#include "tensorflow_lite_support/cc/task/core/task_api_factory.h"
#include "tensorflow_lite_support/cc/task/core/task_utils.h"
#include "tensorflow_lite_support/cc/utils/common_utils.h"

namespace tflite {
namespace task {
namespace text {
namespace nlclassifier {

StatusCode;
Offset;
Vector;
TensorMetadata;
CreateStatusWithPayload;
StatusOr;
TfLiteSupportStatus;
LoadVocabFromBuffer;
Category;
Dequantize;
GetStringAtIndex;
TaskAPIFactory;
// To differenciate it with the struct option,
// tflite::task::text::nl_classifier::NLClassifierOptions.
NLClassifierProtoOptions;

namespace {

absl::Status SanityCheckOptions(const NLClassifierProtoOptions& options) {}

}  // namespace

const NLClassifierOptions& NLClassifier::GetOptions() const {}

absl::Status NLClassifier::TrySetLabelFromMetadata(
    const TensorMetadata* metadata) {}

std::vector<Category> NLClassifier::Classify(const std::string& text) {}

StatusOr<std::vector<Category>> NLClassifier::ClassifyText(
    const std::string& text) {}

absl::Status NLClassifier::Preprocess(
    const std::vector<TfLiteTensor*>& input_tensors, const std::string& input) {}

StatusOr<std::vector<Category>> NLClassifier::Postprocess(
    const std::vector<const TfLiteTensor*>& output_tensors,
    const std::string& /*input*/) {}

std::vector<Category> NLClassifier::BuildResults(const TfLiteTensor* scores,
                                                 const TfLiteTensor* labels) {}

absl::Status NLClassifier::Initialize(
    std::unique_ptr<tflite::task::text::NLClassifierOptions> options) {}

absl::Status NLClassifier::Initialize(const NLClassifierOptions& options) {}

/* static */
StatusOr<std::unique_ptr<NLClassifier>> NLClassifier::CreateFromOptions(
    const NLClassifierProtoOptions& options,
    std::unique_ptr<tflite::OpResolver> resolver) {}

StatusOr<std::unique_ptr<NLClassifier>>
NLClassifier::CreateFromBufferAndOptions(
    const char* model_buffer_data, size_t model_buffer_size,
    const NLClassifierOptions& options,
    std::unique_ptr<tflite::OpResolver> resolver) {}

StatusOr<std::unique_ptr<NLClassifier>> NLClassifier::CreateFromFileAndOptions(
    const std::string& path_to_model, const NLClassifierOptions& options,
    std::unique_ptr<tflite::OpResolver> resolver) {}

StatusOr<std::unique_ptr<NLClassifier>> NLClassifier::CreateFromFdAndOptions(
    int fd, const NLClassifierOptions& options,
    std::unique_ptr<tflite::OpResolver> resolver) {}

}  // namespace nlclassifier
}  // namespace text
}  // namespace task
}  // namespace tflite