From 41f46000b899bfb8625183f1d239a5d2f6545436 Mon Sep 17 00:00:00 2001 From: Dengrx Date: Sun, 27 Aug 2023 15:13:39 +0800 Subject: [PATCH] ADD file via upload --- quantize_ops_declare.cc | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 quantize_ops_declare.cc diff --git a/quantize_ops_declare.cc b/quantize_ops_declare.cc new file mode 100644 index 0000000..8023ebd --- /dev/null +++ b/quantize_ops_declare.cc @@ -0,0 +1,44 @@ +/** + * Copyright 2019 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. + */ + +#include "transform/graph_ir/op_declare/quantize_ops_declare.h" + +namespace mindspore::transform { +// AscendQuant +INPUT_MAP(AscendQuant) = {{1, INPUT_DESC(x)}}; +//输入映射,x索引为1 +ATTR_MAP(AscendQuant) = {{"scale", ATTR_DESC(scale, AnyTraits())}, + {"offset", ATTR_DESC(offset, AnyTraits())}, + {"sqrt_mode", ATTR_DESC(sqrt_mode, AnyTraits())}, + {"round_mode", ATTR_DESC(round_mode, AnyTraits())}}; +// 属性映射,列出了四个属性,"scale""offset"类型为float,"sqrt_mode"类型为bool,"round_mode"类型为std::string +OUTPUT_MAP(AscendQuant) = {{0, OUTPUT_DESC(y)}}; +//输出映射,y索引为0 +REG_ADPT_DESC(AscendQuant, kNameAscendQuant, ADPT_DESC(AscendQuant)) +// 注册AscendQuant操作的适配器描述kNameAscendQuant + +// AscendDequant +INPUT_MAP(AscendDequant) = {{1, INPUT_DESC(x)}, {2, INPUT_DESC(deq_scale)}}; +// 输入映射,x索引为1,deq_scale索引为2 +ATTR_MAP(AscendDequant) = {{"sqrt_mode", ATTR_DESC(sqrt_mode, AnyTraits())}, + {"relu_flag", ATTR_DESC(relu_flag, AnyTraits())}, + {"dtype", ATTR_DESC(dtype, AnyTraits())}}; +// 属性映射,列出了四个属性,"sqrt_mode""relu_flag"类型为bool,"dtype"类型为GEType +OUTPUT_MAP(AscendDequant) = {{0, OUTPUT_DESC(y)}}; +//输出映射,y索引为0 +REG_ADPT_DESC(AscendDequant, kNameAscendDequant, ADPT_DESC(AscendDequant)) +//注册AscendDequant操作的适配器描述kNameAscendDequant +} // namespace mindspore::transform