You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
graphengine/third_party/fwkacllib/inc/ops/lookup_ops.h

309 lines
11 KiB

5 years ago
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
5 years ago
*
* 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.
*/
/*!
* \file lookup_ops.h
* \brief
*/
#ifndef OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_
#define OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_
5 years ago
#include "graph/operator_reg.h"
namespace ge {
/**
*@brief Replaces the contents of the table with the specified keys and values . \n
*@par Inputs:
*The dtype of input handle must be resource. Inputs include:
*@li handle: A Tensor of type resource. Handle to the table.
*@li keys: A Tensor. Any shape. Keys to look up.
*@li values: A Tensor. Values to associate with keys . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow LookupTableImport operator.
*/
5 years ago
REG_OP(LookupTableImport)
.INPUT(handle, TensorType({DT_RESOURCE}))
.INPUT(keys, TensorType({DT_STRING, DT_INT32, DT_INT64}))
5 years ago
.INPUT(values, TensorType({DT_BOOL, DT_DOUBLE, \
DT_FLOAT, DT_INT32, DT_INT64, DT_STRING}))
5 years ago
.OP_END_FACTORY_REG(LookupTableImport)
/**
*@brief Updates the table to associates keys with values . \n
*@par Inputs:
*The dtype of input handle must be resource. Inputs include:
*@li handle: A Tensor of type resource. Handle to the table.
*@li keys: A Tensor. Any shape. Keys to look up.
*@li values: A Tensor. Values to associate with keys . \n
*@attention Constraints:
*@li The tensor keys must be of the same type as the keys of the table.
*@li The tensor values must be of the type of the table values.
*@par Third-party framework compatibility.
*Compatible with tensorflow LookupTableInsert operator.
*/
5 years ago
REG_OP(LookupTableInsert)
.INPUT(handle, TensorType({DT_RESOURCE}))
.INPUT(keys, TensorType({DT_STRING, DT_INT32, DT_INT64}))
5 years ago
.INPUT(values, TensorType({DT_BOOL, DT_DOUBLE, DT_FLOAT, \
DT_INT32, DT_INT64, DT_STRING}))
5 years ago
.OP_END_FACTORY_REG(LookupTableInsert)
/**
*@brief Outputs all keys and values in the table . \n
*@par Inputs:
*The dtype of input handle must be resource. Inputs include:
*handle: A Tensor of type resource. Handle to the table . \n
*@par Attributes:
*@li Tkeys: A DType.
*@li Tvalues: A DType . \n
*@par Outputs:
*@li keys: A Tensor of type Tkeys.
*@li values: A Tensor of type Tvalues . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow LookupTableExport operator.
*/
5 years ago
REG_OP(LookupTableExport)
.INPUT(handle, TensorType({DT_RESOURCE}))
.OUTPUT(keys, TensorType({DT_INT32, DT_INT64, DT_STRING}))
5 years ago
.OUTPUT(values, TensorType({DT_BOOL, DT_DOUBLE, DT_FLOAT, \
DT_INT32, DT_INT64, DT_STRING}))
5 years ago
.REQUIRED_ATTR(Tkeys, Type)
.REQUIRED_ATTR(Tvalues, Type)
.OP_END_FACTORY_REG(LookupTableExport)
/**
*@brief Computes the number of elements in the given table . \n
*@par Inputs:
*The dtype of input handle must be resource. Inputs include:
*handle: A Tensor of type resource. Handle to the table . \n
*@par Outputs:
*size: A Tensor of type int64 . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow LookupTableSize operator.
*/
5 years ago
REG_OP(LookupTableSize)
.INPUT(handle, TensorType({DT_RESOURCE}))
.OUTPUT(size, TensorType({DT_INT64}))
.OP_END_FACTORY_REG(LookupTableSize)
/**
*@brief Looks up keys in a table, outputs the corresponding values . \n
*@par Inputs:
*The dtype of input handle must be resource. Inputs include:
*@li handle: A Tensor of type resource. Handle to the table.
*@li keys: A Tensor. Any shape. Keys to look up.
*@li default_value: A Tensor . \n
*@par Attributes:
*Tout: Specified type of ouput values . \n
*@par Outputs:
*values: A Tensor. Has the same type as default_value . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow LookupTableFind operator.
*/
5 years ago
REG_OP(LookupTableFind)
.INPUT(handle, TensorType({DT_RESOURCE}))
.INPUT(keys, TensorType({DT_INT32, DT_INT64, DT_STRING}))
5 years ago
.INPUT(default_value, TensorType({DT_DOUBLE, DT_FLOAT, \
DT_INT32, DT_INT64, DT_STRING, DT_BOOL}))
5 years ago
.OUTPUT(values, TensorType({DT_DOUBLE, DT_FLOAT, DT_INT32, \
DT_INT64, DT_STRING, DT_BOOL}))
5 years ago
.REQUIRED_ATTR(Tout, Type)
.OP_END_FACTORY_REG(LookupTableFind)
/**
*@brief Creates a non-initialized hash table . \n
*@par Attributes:
*@li container: An optional string. Defaults to "". If non-empty, this table
is placed in the given container. Otherwise, a default container is used.
*@li shared_name: An optional string. Defaults to "". If non-empty, this
table is shared under the given name across multiple sessions.
*@li use_node_name_sharing: An optional bool. Defaults to False. If true and
shared_name is empty, the table is shared using the node name.
*@li key_dtype: A DType. Type of the table keys.
*@li value_dtype: A DType. Type of the table values . \n
*@par Outputs:
*handle: A Tensor of type resource. Handle to the table . \n
*@attention Constraints:
*The implementation for HashTable on Ascend uses ai cpu, with bad performance.
*@par Third-party framework compatibility.
*Compatible with tensorflow HashTable operator.
*/
5 years ago
REG_OP(HashTable)
.OUTPUT(handle, TensorType({DT_RESOURCE}))
.ATTR(container, String, "")
.ATTR(shared_name, String, "")
.ATTR(use_node_name_sharing, Bool, false)
.REQUIRED_ATTR(key_dtype, Type)
.REQUIRED_ATTR(value_dtype, Type)
.OP_END_FACTORY_REG(HashTable)
/**
*@brief Table initializer that takes two tensors for keys and values
respectively . \n
*@par Inputs:
*The dtype of input handle must be resource. Inputs include:
*@li handle: A Tensor of type resource. Handle to a table which will be
initialized.
*@li keys: A Tensor. Keys of type Tkey.
*@li values: A Tensor. Values of type Tval . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow InitializeTable operator.
*/
5 years ago
REG_OP(InitializeTable)
.INPUT(handle, TensorType({DT_RESOURCE}))
.INPUT(keys, TensorType({DT_INT32, DT_INT64, DT_STRING}))
.INPUT(values, TensorType({DT_INT32, DT_INT64, DT_FLOAT, \
DT_DOUBLE, DT_BOOL, DT_STRING}))
5 years ago
.OP_END_FACTORY_REG(InitializeTable)
/**
*@brief Creates an empty hash table that uses tensors as the backing store . \n
*@par Inputs:
*The input deleted_key must have the same type as empty_key. Inputs include:
*@li empty_key: A Tensor. The key used to represent empty key buckets
internally. Must not be used in insert or lookup operations.
*@li deleted_key: A Tensor. Must have the same type as empty_key . \n
*@par Attributes:
*@li container: An optional string. Defaults to "". If non-empty, this table
is placed in the given container. Otherwise, a default container is used.
*@li shared_name: An optional string. Defaults to "". If non-empty, this
table is shared under the given name across multiple sessions.
*@li use_node_name_sharing: An optional bool. Defaults to False. If true and
shared_name is empty, the table is shared using the node name.
*@li value_dtype: A DType. Type of the table values.
*@li value_shape: An optional TensorShape or list of ints. Defaults to [].
The shape of each value.
*@li initial_num_buckets: An optional int. Defaults to 131072. The initial
number of hash table buckets. Must be a power to 2.
*@li max_load_factor: An optional float. Defaults to 0.8. The maximum ratio
between number of entries and number of buckets before growing the table.
Must be between 0 and 1 . \n
*@par Outputs:
*handle: A Tensor of type resource. Handle to the table . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow MutableDenseHashTable operator.
*/
5 years ago
REG_OP(MutableDenseHashTable)
.INPUT(empty_key, TensorType({DT_INT32, DT_INT64, DT_STRING}))
.INPUT(deleted_key, TensorType({DT_INT32, DT_INT64, DT_STRING}))
.OUTPUT(handle, TensorType({DT_RESOURCE}))
5 years ago
.ATTR(container, String, "")
.ATTR(shared_name, String, "")
.ATTR(use_node_name_sharing, Bool, false)
.REQUIRED_ATTR(value_dtype, Type)
.ATTR(value_shape, ListInt, {})
.ATTR(initial_num_buckets, Int, 131072)
.ATTR(max_load_factor, Float, 0.8)
.OP_END_FACTORY_REG(MutableDenseHashTable)
/**
*@brief Creates an empty hash table . \n
*@par Attributes:
*@li container: An optional string. Defaults to "". If non-empty, this table
is placed in the given container. Otherwise, a default container is used.
*@li shared_name: An optional string. Defaults to "". If non-empty, this
table is shared under the given name across multiple sessions.
*@li use_node_name_sharing: An optional bool. Defaults to False. If true and
shared_name is empty, the table is shared using the node name.
*@li key_dtype: A DType. Type of the table keys.
*@li value_dtype: A DType. Type of the table values.
*@li value_shape: An optional TensorShape or list of ints. Defaults to [] . \n
*@par Outputs:
*handle: A Tensor of type resource. Handle to the table . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow MutableHashTableOfTensors operator.
*/
5 years ago
REG_OP(MutableHashTableOfTensors)
.OUTPUT(handle, TensorType({DT_RESOURCE}))
5 years ago
.ATTR(container, String, "")
.ATTR(shared_name, String, "")
.ATTR(use_node_name_sharing, Bool, false)
.REQUIRED_ATTR(key_dtype, Type)
.REQUIRED_ATTR(value_dtype, Type)
.ATTR(value_shape, ListInt, {})
.OP_END_FACTORY_REG(MutableHashTableOfTensors)
/**
*@brief Creates an empty hash table . \n
*@par Attributes:
*@li container: An optional string. Defaults to "". If non-empty, this table
is placed in the given container. Otherwise, a default container is used.
*@li shared_name: An optional string. Defaults to "". If non-empty, this
table is shared under the given name across multiple sessions.
*@li use_node_name_sharing: An optional bool. Defaults to False. If true and
shared_name is empty, the table is shared using the node name.
*@li key_dtype: A DType. Type of the table keys.
*@li value_dtype: A DType. Type of the table values . \n
*@par Outputs:
*handle: A Tensor of type resource. Handle to the table . \n
*@par Third-party framework compatibility.
*Compatible with tensorflow MutableHashTable operator.
*/
5 years ago
REG_OP(MutableHashTable)
.OUTPUT(handle, TensorType({DT_RESOURCE}))
5 years ago
.ATTR(container, String, "")
.ATTR(shared_name, String, "")
.ATTR(use_node_name_sharing, Bool, false)
.REQUIRED_ATTR(key_dtype, Type)
.REQUIRED_ATTR(value_dtype, Type)
.OP_END_FACTORY_REG(MutableHashTable)
} // namespace ge
#endif // OPS_BUILT_IN_OP_PROTO_INC_LOOKUP_OPS_H_