/* Copyright 2017 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. ==============================================================================*/ // Op that looks up items from hashtable. // // Input: // Tensor[0]: Hash key to lookup, dim.size == 1, int32 // Tensor[1]: Key of hashtable, dim.size == 1, int32 // *MUST* be sorted in ascending order. // Tensor[2]: Value of hashtable, dim.size >= 1 // Tensor[1].Dim[0] == Tensor[2].Dim[0] // // Output: // Output[0].dim[0] == Tensor[0].dim[0], num of lookups // Each item in output is a raw bytes copy of corresponding item in input. // When key does not exist in hashtable, the returned bytes are all 0s. // // Output[1].dim = { Tensor[0].dim[0] }, num of lookups // Each item indicates whether the corresponding lookup has a returned value. // 0 for missing key, 1 for found key. #include <stdint.h> #include <cstdlib> #include <cstring> #include "tensorflow/lite/core/c/common.h" #include "tensorflow/lite/kernels/internal/compatibility.h" #include "tensorflow/lite/kernels/kernel_util.h" #include "tensorflow/lite/string_util.h" namespace tflite { namespace ops { namespace builtin { namespace { int greater(const void* a, const void* b) { … } TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { … } TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { … } } // namespace TfLiteRegistration* Register_HASHTABLE_LOOKUP() { … } } // namespace builtin } // namespace ops } // namespace tflite