45 lines
2.1 KiB
C++
45 lines
2.1 KiB
C++
/**
|
||
* 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索引为1,deq_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
|