|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- /**
- * Copyright 2019-2020 Huawei Technologies Co., Ltd
- *
- * 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.
- */
-
- #ifndef GE_OP_MATRIX_CALCULATION_OPS_H
- #define GE_OP_MATRIX_CALCULATION_OPS_H
-
- #include "../graph/operator_reg.h"
-
- namespace ge {
-
- /**
- *@brief Multiplies matrix "a" by matrix "b", producing "a * b".
-
- *@par Inputs:
- *Two inputs, including:
- * @li x1: A matrix Tensor. 2D. Must be one of the following types: float16,
- * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
- * @li x2: A matrix Tensor. 2D. Must be one of the following types: float16,
- * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
- * @li bias: A 1D Tensor. Must be one of the following types: float16,
- * float32, int32. Has format [ND, NHWC].
-
- *@par Attributes:
- *@li transpose_a: A bool. If True, changes the shape of "x1" from [M, K] to [K, M].
- *@li transpose_b: A bool. If True, changes the shape of "x2" from [M, K] to [K, M].
-
- *@par Outputs:
- *y: The result matrix Tensor. 2D. Must be one of the following types: float16,
- * float32, int32. Has format [ND, NHWC, FRACTAL_NZ].
- */
- REG_OP(MatMul)
- .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .OPTIONAL_INPUT(bias, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .ATTR(transpose_x1, Bool, false)
- .ATTR(transpose_x2, Bool, false)
- .OP_END_FACTORY_REG(MatMul)
-
- /**
- *@brief Performs Matrix-to-matrix Multiply, producing c=alpha[0]*a*b+beta[0]*c.
-
- *@par Inputs:
- *Five inputs, including:
- *@li a: A matrix Tensor. 4D. Must be one of the following types:\n float16, int8. Has format [FRACTAL_NZ].
- *@li b: A matrix Tensor. 4D. Must be one of the following types:\n float16, int8. When type is int8, has format [FRACTAL_Z], \n otherwise has format [FRACTAL_NZ].
- *@li c: A matrix Tensor. 2D or higher. Must be one of the following types: \n float16, int32, float32. When type is int32, has format [ND], \n otherwise has format [FRACTAL_NZ].
- *@li alpha: A 1D Tensor. The shape of alpha is [1].\n Must be one of the following types: float16, int32, float32. Has format [ND].
- *@li beta: A 1D Tensor. The shape of beta is [1].\n Must be one of the following types: float16, int32, float32. Has format [ND].
-
- *@par Attributes:
- *Two attributes, including:
- *@li transpose_a: Optional. A bool.\n If True, changes the shape of "a" from [M, K] to [K, M].\n Reserved parameters, not used for now.
- *@li transpose_b: Optional. A bool.\n If True, changes the shape of "b" from [M, K] to [K, M].\n Reserved parameters, not used for now.
-
- *@par Outputs:
- *@out: The result matrix Tensor. 4D. Must be one of the following types:\n float16, float32, int32. Has format [FRACTAL_NZ].
- */
-
- REG_OP(Gemm)
- .INPUT(a, TensorType({DT_FLOAT16, DT_INT8}))
- .INPUT(b, TensorType({DT_FLOAT16, DT_INT8}))
- .INPUT(c, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .INPUT(alpha, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .INPUT(beta, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .OUTPUT(out, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .ATTR(transpose_a, Bool, false)
- .ATTR(transpose_b, Bool, false)
- .OP_END_FACTORY_REG(Gemm)
-
- /**
- *@brief Multiplies matrix "a" by matrix "b", producing "a * b".
-
- *@par Inputs:
- *Three inputs, including:
- * @li x1: A matrix Tensor. Must be one of the following types: float16,
- * float32, int32. 2D or higher. Has format [ND, NHWC, FRACTAL_NZ].
- * @li x2: A matrix Tensor. Must be one of the following types: float16,
- * float32, int32. 2D or higher. Has format [ND, NHWC, FRACTAL_NZ].
-
- *@par Attributes:
- *@li adj_x: A bool. If True, changes the shape of "x1" from [B, M, K] to [B, K, M].
- *@li adj_y: A bool. If True, changes the shape of "x2" from [B, M, K] to [B, K, M].
-
- *@par Outputs:
- *y: The result matrix Tensor. 2D or higher. Must be one of the following types: float16,
- * float32, int32. 2D or higher. Has format [ND, NHWC, FRACTAL_NZ]. Has the same shape length as "x1" and "x2".
- */
-
- REG_OP(BatchMatMul)
- .INPUT(x1, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .INPUT(x2, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .ATTR(adj_x1, Bool, false)
- .ATTR(adj_x2, Bool, false)
- .OP_END_FACTORY_REG(BatchMatMul)
-
- REG_OP(MeanCCE)
- .INPUT(x, TensorType::ALL())
- .INPUT(indices, TensorType::ALL())
- .OUTPUT(y, TensorType::ALL())
- .ATTR(keep_dims, Bool, false)
- .ATTR(value1, ListInt, {})
- .ATTR(mode, Int, 3) // 0:max pooling or 1:avg pooling
- .ATTR(pad_mode, Int, 0)
- .ATTR(global_pooling, Bool, true)
- .ATTR(window, ListInt, {1,1}) // kernel size
- .ATTR(pad, ListInt, {0,0,0,0}) // pad size
- .ATTR(stride, ListInt, {1,1}) // stride size
- .ATTR(ceil_mode, Int, 0)
- .ATTR(data_mode, Int, 1)
- .ATTR(nan_opt, Int, 0)
- .ATTR(fomart, Int, 0)
- .OP_END_FACTORY_REG(MeanCCE)
-
- REG_OP(MeanGrad)
- .INPUT(x, TensorType::ALL())
- .OUTPUT(y, TensorType::ALL())
- .ATTR(mode, Int, 1) // 0:max pooling or 1:avg pooling
- .ATTR(pad_mode, Int, 0)
- .ATTR(global_pooling, Bool, false)
- .ATTR(window, ListInt, {1,1}) // kernel size
- .ATTR(pad, ListInt, {0,0,0,0}) // pad size
- .ATTR(stride, ListInt, {1,1}) // stride size
- .ATTR(ceil_mode, Int, 0)
- .ATTR(data_mode, Int, 1)
- .ATTR(nan_opt, Int, 0)
- .ATTR(mean_grad_output_shape_value, ListInt, {1,1,1,1})
- .ATTR(mean_grad_output_shape_format, Int, 1) //must be NHWC
- .OP_END_FACTORY_REG(MeanGrad)
-
- REG_OP(MatMulCCE)
- .INPUT(x1, TensorType({DT_FLOAT}))
- .INPUT(x2, TensorType({DT_FLOAT}))
- .OPTIONAL_INPUT(x3, TensorType({DT_FLOAT}))
- .OUTPUT(y, TensorType({DT_FLOAT}))
- .ATTR(transpose_a, Bool, false)
- .ATTR(transpose_b, Bool, false)
- .ATTR(has_bias, Bool, false)
- .OP_END_FACTORY_REG(MatMulCCE)
-
- /**
- *@brief Computes half the L2 norm of a tensor without the sqrt.
-
- *@par Inputs:
-
- * x: A Tensor.
- * TensorType::FloatingDataType().
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
- */
- REG_OP(L2Loss)
- .INPUT(x, TensorType::FloatingDataType())
- .OUTPUT(y, TensorType::FloatingDataType())
- .OP_END_FACTORY_REG(L2Loss)
-
- /**
- *@brief: Returns a batched diagonal tensor with a given batched diagonal values.
-
- *@par Inputs:
- *x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(MatrixDiag)
- .INPUT(x, TensorType::BasicType())
- .OUTPUT(y, TensorType::BasicType())
- .OP_END_FACTORY_REG(MatrixDiag)
-
- /**
- *@brief: Returns a batched diagonal tensor with a given batched diagonal values.
-
- *@par Inputs:
- * Two inputs, including:
- *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
- *@li assist: A Tensor of the same type as "x".
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(MatrixDiagD)
- .INPUT(x, TensorType::BasicType())
- .INPUT(assist, TensorType::BasicType())
- .OUTPUT(y, TensorType::BasicType())
- .OP_END_FACTORY_REG(MatrixDiagD)
-
- /**
- *@brief: Returns the batched diagonal part of a batched tensor.
-
- *@par Inputs:
- *x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(MatrixDiagPart)
- .INPUT(x, TensorType::BasicType())
- .OUTPUT(y, TensorType::BasicType())
- .OP_END_FACTORY_REG(MatrixDiagPart)
-
- /**
- *@brief: Returns the batched diagonal part of a batched tensor.
-
- *@par Inputs:
- * Two inputs, including:
- *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
- *@li assist: A Tensor of the same type as "x".
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(MatrixDiagPartD)
- .INPUT(x, TensorType::BasicType())
- .INPUT(assist, TensorType::BasicType())
- .OUTPUT(y, TensorType::BasicType())
- .OP_END_FACTORY_REG(MatrixDiagPartD)
-
- /**
- *@brief: Returns a batched matrix tensor with new batched diagonal values.
-
- *@par Inputs:
- * Two inputs, including:
- *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
- *@li diagonal: A Tensor of the same type as "x".
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(MatrixSetDiag)
- .INPUT(x, TensorType::BasicType())
- .INPUT(diagonal, TensorType::BasicType())
- .OUTPUT(y, TensorType::BasicType())
- .OP_END_FACTORY_REG(MatrixSetDiag)
-
- /**
- *@brief: Returns a batched matrix tensor with new batched diagonal values.
-
- *@par Inputs:
- * Three inputs, including:
- *@li x: A Tensor. Must be one of the following types: float16, float32, int32, int8, uint8.
- *@li diagonal: A Tensor of the same type as "x".
- *@li assist: A Tensor of the same type as "x".
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(MatrixSetDiagD)
- .INPUT(x, TensorType::BasicType())
- .INPUT(diagonal, TensorType::BasicType())
- .INPUT(assist, TensorType::BasicType())
- .OUTPUT(y, TensorType::BasicType())
- .OP_END_FACTORY_REG(MatrixSetDiagD)
-
- /**
- *@brief Applies sparse "updates" to individual values or slices in a Variable.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int8, uint8, bool
- *@li indices: An ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int8, uint8, bool
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterNdUpdate)
- .INPUT(var, TensorType::BasicType())
- .INPUT(indices, TensorType::IndexNumberType())
- .INPUT(updates, TensorType::BasicType())
- .OUTPUT(var, TensorType::BasicType())
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterNdUpdate)
-
- /**
- *@brief Adds sparse "updates" to a variable reference.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An ND Tensor of type int32.
-
-
- *@li updates: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterAdd)
- .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType::IndexNumberType())
- .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterAdd)
-
- /**
- *@brief Divides a variable reference by sparse updates.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *@li use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
- *@li isRef: An optional bool. Defaults to "True"
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterDiv)
- .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType({DT_INT32}))
- .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterDiv)
-
- /**
- *@brief Applies sparse addition to individual values or slices in a Variable.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterNdAdd)
- .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType::IndexNumberType())
- .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterNdAdd)
-
- /**
- *@brief Applies sparse subtraction to individual values or slices in a Variable.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterNdSub)
- .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType::IndexNumberType())
- .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterNdSub)
-
- /**
- *@brief Subtracts sparse updates to a variable reference.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterSub)
- .INPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType::IndexNumberType())
- .INPUT(updates, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16, DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterSub)
-
- /**
- *@brief: Returns the batched diagonal part of a batched tensor with "assist".
-
- *@par Inputs:
- * Two inputs, including:
- * @li x: A Tensor of type float16, float32, or int32.
- * @li assist: A Tensor of the same type as "x".
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(DiagPartD)
- .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .INPUT(assist, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32}))
- .OP_END_FACTORY_REG(DiagPartD)
-
- /**
- *@brief: Returns the batched diagonal part of a batched tensor.
-
- *@par Inputs:\n
- *x: A Tensor. Must be one of the following types: float16, float32, int32, int64, double, complex64, complex128.
-
- *@par Outputs:
- *y: A Tensor. Has the same type as "x".
-
- */
- REG_OP(DiagPart)
- .INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT64, DT_DOUBLE,
- DT_COMPLEX64, DT_COMPLEX128}))
- .OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT32, DT_INT64, DT_DOUBLE,
- DT_COMPLEX64, DT_COMPLEX128}))
- .OP_END_FACTORY_REG(DiagPart)
-
- /**
- *@brief Also known as a "fully-connected" layer, computes an inner product with a set of learned weights, and (optionally) adds biases.
-
- *@par Inputs:
- * Two inputs, including:
- *@li x: A Tensor of type float16, int8.
- *@li w: A weight matrix of type float16, int8.
- *@li b: A Tensor of type float16, int32.
- *@li offset_w: A Tensor of type int8.
-
- *@par Attributes:
- *@li num_output: Reserved.
- *@li transpose: A bool, specifying whether to transpose, either "true" or "false". Defaults to "false".
- *@li bias_term: A bool, specifying whether to learn and apply a set of additive biases to the filter outputs, either "true" or "false". Defaults to "true".
- *@li axis: only support axis is 1. Defaults to "1".
- *@li offset_a: A type of Int, Defaults to "1".
-
- *@par Outputs:
- *y: The result tensor of type float16, int8.
- */
- REG_OP(InnerProduct)
- .INPUT(x, TensorType({DT_FLOAT16, DT_INT8}))
- .INPUT(w, TensorType({DT_FLOAT16, DT_INT8}))
- .OPTIONAL_INPUT(b, TensorType({DT_FLOAT16, DT_INT32}))
- .OPTIONAL_INPUT(offset_w, TensorType({DT_INT8}))
- .OUTPUT(y, TensorType({DT_FLOAT16, DT_INT32}))
- .REQUIRED_ATTR(num_output, Int)
- .ATTR(transpose, Bool, false)
- .ATTR(bias_term, Bool, true)
- .ATTR(axis, Int, 1)
- .ATTR(offset_a, Int, 0)
- .OP_END_FACTORY_REG(InnerProduct)
-
- /**
- *@brief Computes the confusion matrix from predictions and labels.
-
- *@par Inputs:
- * Three inputs, including:
- *@li labels: A Tensor. Must be one of the following types: float16, float32, int32, int8.
- *@li predictions: A Tensor. Must be one of the following types: float16, float32, int32, int8.
- *@li weights: A Tensor. Must be one of the following types: float16, float32, int32, int8.
-
- *@par Attributes:
- *@li num_classes: An integer for the shape of the output matrix. No default value.
- *@li dtype: Data type of the confusion matrix. No default value.
-
- *@par Outputs:
- *y: A Tensor. Has the same type and format as input "labels"
-
- *@attention Constraints:
- *@li "weights", "labels", and "predictions" are 1D tensors.
- *@li The output is with shape (num_classes, num_classes), where, 1 <= num_classes <= 4096.
-
- *@see Region()
-
- */
- REG_OP(ConfusionMatrix)
- .INPUT(labels, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
- .INPUT(predictions, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
- .OPTIONAL_INPUT(weights, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
- .OUTPUT(y, TensorType({DT_FLOAT, DT_INT32, DT_FLOAT16, DT_INT8, DT_UINT8}))
- .REQUIRED_ATTR(num_classes, Int)
- .REQUIRED_ATTR(dtype, String)
- .OP_END_FACTORY_REG(ConfusionMatrix)
-
- /**
- *@brief Multiplies sparse updates into a variable reference.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterMul)
- .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType({DT_INT32}))
- .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterMul)
-
- /**
- *@brief Reduces sparse updates into a variable reference using the "min" operation.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32
- *@li indices: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterMin)
- .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
- .INPUT(indices, TensorType({DT_INT32}))
- .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
- .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterMin)
-
- /**
- *@brief Reduces sparse updates into a variable reference using the "max" operation.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32
- *@li indices: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterMax)
- .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
- .INPUT(indices, TensorType({DT_INT32}))
- .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
- .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT32}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterMax)
-
- /**
- *@brief Applies sparse updates to a variable reference.
-
- *@par Inputs:
- * Three inputs, including:
- *@li var: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
- *@li indices: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: int32
- *@li updates: An NCHW, NHWC, or ND Tensor. \n
-
- *Must be one of the following types: float16, float32, int32, int8, uint8
-
- *@par Attributes:
- *use_locking: An optional bool. Defaults to "False". If "True", the operation will be protected by a lock.
-
- *@par Outputs:
- *var: A Tensor. Has the same type and format as input "var".
-
- */
- REG_OP(ScatterUpdate)
- .INPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8}))
- .INPUT(indices, TensorType({DT_INT32}))
- .INPUT(updates, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8}))
- .OUTPUT(var, TensorType({DT_FLOAT16,DT_FLOAT,DT_INT8,DT_UINT8}))
- .ATTR(use_locking, Bool, false)
- .OP_END_FACTORY_REG(ScatterUpdate)
-
- } // namespace ge
-
- #endif // GE_OP_MATRIX_CALCULATION_OPS_H
|