1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef FRAMEWORKS_ML_NN_HASHTABLE_LOOKUP_H
18#define FRAMEWORKS_ML_NN_HASHTABLE_LOOKUP_H
19
20#include <vector>
21
22namespace android {
23namespace hardware {
24namespace neuralnetworks {
25namespace V1_0 {
26struct Operation;
27}
28}  // namespace neuralnetworks
29}  // namespace hardware
30}  // namespace android
31
32namespace android {
33namespace nn {
34
35struct RunTimeOperandInfo;
36
37class HashtableLookup {
38 public:
39  HashtableLookup(
40      const android::hardware::neuralnetworks::V1_0::Operation &operation,
41      std::vector<RunTimeOperandInfo> &operands);
42
43  bool Eval();
44
45  static constexpr int kLookupTensor = 0;
46  static constexpr int kKeyTensor = 1;
47  static constexpr int kValueTensor = 2;
48
49  static constexpr int kOutputTensor = 0;
50  static constexpr int kHitsTensor = 1;
51
52 private:
53  const RunTimeOperandInfo *lookup_;
54  const RunTimeOperandInfo *key_;
55  const RunTimeOperandInfo *value_;
56
57  RunTimeOperandInfo *output_;
58  RunTimeOperandInfo *hits_;
59};
60
61}  // namespace nn
62}  // namespace android
63
64#endif  // FRAMEWORKS_ML_NN_HASHTABLE_LOOKUP_H
65