ADD file via upload

This commit is contained in:
Dengrx 2023-08-27 15:13:39 +08:00
parent 1bbbad8c6d
commit 41f46000b8
1 changed files with 44 additions and 0 deletions

44
quantize_ops_declare.cc Normal file
View File

@ -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<float>())},
{"offset", ATTR_DESC(offset, AnyTraits<float>())},
{"sqrt_mode", ATTR_DESC(sqrt_mode, AnyTraits<bool>())},
{"round_mode", ATTR_DESC(round_mode, AnyTraits<std::string>())}};
// 属性映射,列出了四个属性,"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索引为1deq_scale索引为2
ATTR_MAP(AscendDequant) = {{"sqrt_mode", ATTR_DESC(sqrt_mode, AnyTraits<bool>())},
{"relu_flag", ATTR_DESC(relu_flag, AnyTraits<bool>())},
{"dtype", ATTR_DESC(dtype, AnyTraits<GEType>())}};
// 属性映射,列出了四个属性,"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