#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/language_detection/core/embedding_lookup.h"
#include "base/check_op.h"
#include "components/language_detection/core/quantization_utils.h"
#include "third_party/flatbuffers/src/include/flatbuffers/flexbuffers.h"
#include "third_party/tflite/src/tensorflow/lite/kernels/internal/tensor_ctypes.h"
#include "third_party/tflite/src/tensorflow/lite/kernels/kernel_util.h"
namespace language_detection {
namespace {
GetRoot;
Map;
constexpr int kInputMessage = …;
constexpr int kEmbeddingTable = …;
constexpr int kMinVal = …;
constexpr int kMaxVal = …;
constexpr int kOutputLabel = …;
constexpr int kNumFloatBits = …;
class EmbeddingLookupOpParams { … };
int GetOutputEmbeddingSize(const int input_embedding_size,
const bool is_quantized,
const int num_precision_bits) { … }
void* Init(TfLiteContext* context, const char* buffer, size_t length) { … }
void Free(TfLiteContext* context, void* buffer) { … }
TfLiteStatus Resize(TfLiteContext* context, TfLiteNode* node) { … }
void GetEmbedding(const TfLiteTensor* input,
const TfLiteTensor* embedding_table,
const float min_val,
const float max_val,
float* data,
const EmbeddingLookupOpParams* params) { … }
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { … }
}
TfLiteRegistration* Register_EMBEDDING_LOOKUP() { … }
}