Rate This Document
Findability
Accuracy
Completeness
Readability

Find

Function

Search for the elements of the input tensor in the lookup table and return the corresponding values.

Prototype

1
int Find(const TableInfo &info, const int64_t *keys, float *values, const float *defaultValue, int64_t length);
  • keys and length are of the int64_t type.
  • values and default_value are of the float type.
  • The valid length of the pointer is determined by the user.
  • Ensure that the valid spaces of the input pointers, including the internal pointers of the structure, do not overlap.

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

Constraint

info

Input

Stores structures used to search for necessary fields. Structures include:

  • numBuckets: Number of hash buckets.
  • valueSize: Length of the embedding layer.
  • emptyKey: Value of the empty key.
  • deletedKey: Value of the deleted key.
  • keyBucket: Key stored in the hash table.
  • valueBucket: Value stored in the hash table.
  • keyBucket and valueBucket are not null pointers.
  • The value of numBuckets is the exponential power of 2 and is greater than 0.
  • valueSize is greater than or equal to 0.
  • The TableInfo.emptyKey value is different from the TableInfo.deletedKey value.
  • keyBucket restrictions:
    • Initially, each key in keyBucket is an emptyKey, which must be checked by the user to ensure the normal running of the API.
    • At any time, at least one key in keyBucket is an emptyKey (an empty bucket is always available), which must be checked by the user to ensure the normal running of the API.
    • If a key exists in keyBucket, use key%numBuckets to obtain its index in keyBucket and use the secondary detection method to find the key before an emptyKey is encountered. This constraint must be checked by the user to ensure the normal running of the API.
    • The data stored in keyBucket complies with the arrangement rule of MutableDenseHashTable in TensorFlow 1.15.
    • The space to which keyBucket points must contain at least numBuckets*sizeof(int64_t) bytes, which must be checked by the user to ensure the normal running of the API.
  • valueBucket restriction:

    The space to which valueBucket points must contain at least numBuckets*valueSize*sizeof(float) bytes, which must be checked by the user to ensure the normal running of the API.

keys

Input

Key used for search.

The pointer is not null, and the array does not contain emptyKey or deletedKey.

values

Input

Value used for search, with the found value as the output.

This pointer is not null.

defaultValue

Input

Value inserted in case the value is not found.

This pointer is not null.

length

Input

Number of keys to be queried.

The value range is (0, 2^63 – 1]. The length of length is the same as that of keys, which must be checked by the user to prevent security issues such as buffer overflow.