Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
06c3cce9
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
06c3cce9
编写于
12月 01, 2021
作者:
Z
Zhanlue Yang
提交者:
GitHub
12月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handled dispensable tensors in AutoCodeGen for Eager Dygraph (#37723)
上级
f91e2331
变更
3
展开全部
显示空白变更内容
内联
并排
Showing
3 changed file
with
314 addition
and
175 deletion
+314
-175
paddle/fluid/eager/auto_code_generator/eager_generator.cc
paddle/fluid/eager/auto_code_generator/eager_generator.cc
+191
-73
paddle/fluid/pybind/op_function_generator.cc
paddle/fluid/pybind/op_function_generator.cc
+2
-102
paddle/fluid/pybind/op_function_generator.h
paddle/fluid/pybind/op_function_generator.h
+121
-0
未找到文件。
paddle/fluid/eager/auto_code_generator/eager_generator.cc
浏览文件 @
06c3cce9
此差异已折叠。
点击以展开。
paddle/fluid/pybind/op_function_generator.cc
浏览文件 @
06c3cce9
...
...
@@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/pybind/op_function_generator.h"
#include <algorithm>
#include <fstream>
#include <iostream>
...
...
@@ -30,108 +32,6 @@
#include "paddle/fluid/framework/fleet/ascend_wrapper.h"
#endif
// NOTE(zhiqiu): Commonly, the inputs in auto-generated OP function are
// determined by the OP`s proto automatically, i.e., all the inputs registered
// in OpMaker.
// However, some OPs have dispensable inputs, which means the input can
// be none for some conditions. It is discovered that most dispensable inputs
// is not used in imperative mode, so we drop those inputs when generating OP
// functions. While, for very few OPs, the dispensable inputs are used, we
// need to manually specify them in this map.
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>>
op_ins_map
=
{
{
"layer_norm"
,
{
"X"
,
"Scale"
,
"Bias"
}},
{
"bincount"
,
{
"X"
,
"Weights"
}},
{
"fused_attention"
,
{
"X"
,
"LnScale"
,
"LnBias"
,
"QKVW"
,
"QKVBias"
,
"SrcMask"
,
"OutLinearW"
,
"OutLinearBias"
,
"Ln2Scale"
,
"Ln2Bias"
}},
{
"instance_norm"
,
{
"X"
,
"Scale"
,
"Bias"
}},
{
"gru_unit"
,
{
"Input"
,
"HiddenPrev"
,
"Weight"
,
"Bias"
}},
{
"label_smooth"
,
{
"X"
,
"PriorDist"
}},
{
"assign"
,
{
"X"
}},
{
"reshape2"
,
{
"X"
,
"Shape"
}},
{
"expand"
,
{
"X"
,
"ExpandTimes"
}},
{
"slice"
,
{
"Input"
,
"StartsTensor"
,
"EndsTensor"
}},
{
"fake_quantize_dequantize_moving_average_abs_max"
,
{
"X"
,
"InScale"
,
"InAccum"
,
"InState"
}},
{
"nll_loss"
,
{
"X"
,
"Label"
,
"Weight"
}},
{
"bilinear_tensor_product"
,
{
"X"
,
"Y"
,
"Weight"
,
"Bias"
}},
{
"gather"
,
{
"X"
,
"Index"
,
"Axis"
}},
{
"roi_pool"
,
{
"X"
,
"ROIs"
,
"RoisNum"
}},
{
"roi_align"
,
{
"X"
,
"ROIs"
,
"RoisNum"
}},
{
"psroi_pool"
,
{
"X"
,
"ROIs"
,
"RoisNum"
}},
{
"collect_fpn_proposals"
,
{
"MultiLevelRois"
,
"MultiLevelScores"
,
"MultiLevelRoIsNum"
}},
{
"distribute_fpn_proposals"
,
{
"FpnRois"
,
"RoisNum"
}},
{
"warpctc"
,
{
"Logits"
,
"Label"
,
"LogitsLength"
,
"LabelLength"
}},
{
"hierarchical_sigmoid"
,
{
"X"
,
"W"
,
"Label"
,
"PathTable"
,
"PathCode"
,
"Bias"
}},
{
"moving_average_abs_max_scale"
,
{
"X"
,
"InAccum"
,
"InState"
}},
{
"multiclass_nms3"
,
{
"BBoxes"
,
"Scores"
,
"RoisNum"
}},
{
"box_coder"
,
{
"PriorBox"
,
"PriorBoxVar"
,
"TargetBox"
}},
{
"momentum"
,
{
"Param"
,
"Grad"
,
"Velocity"
,
"LearningRate"
,
"MasterParam"
}},
{
"sparse_momentum"
,
{
"Param"
,
"Grad"
,
"Velocity"
,
"Index"
,
"LearningRate"
}},
{
"rnn"
,
{
"Input"
,
"PreState"
,
"WeightList"
,
"SequenceLength"
}},
{
"run_program"
,
{
"X"
,
"Params"
}},
{
"fused_feedforward"
,
{
"Dropout1Seed"
,
"Dropout2Seed"
,
"Linear1Bias"
,
"Linear2Bias"
,
"Ln1Scale"
,
"Ln1Bias"
,
"Ln2Scale"
,
"Ln2Bias"
}},
{
"faster_tokenizer"
,
{
"Text"
,
"Vocab"
,
"TextPair"
}},
{
"matrix_rank"
,
{
"X"
,
"TolTensor"
}},
{
"adam"
,
{
"Param"
,
"Grad"
,
"LearningRate"
,
"Moment1"
,
"Moment2"
,
"Beta1Pow"
,
"Beta2Pow"
,
"MasterParam"
}},
{
"adamw"
,
{
"Param"
,
"Grad"
,
"LearningRate"
,
"Moment1"
,
"Moment2"
,
"Beta1Pow"
,
"Beta2Pow"
,
"MasterParam"
}},
};
// NOTE(zhiqiu): Like op_ins_map.
// Commonly, the outputs in auto-generated OP function are determined by the
// OP`s proto automatically, i.e., all the outputs registered in OpMaker.
// However, some OPs have dispensable outputs, which means the output can
// be none for some conditions. It is discovered that most dispensable outputs
// is not used in imperative mode, so we drop those outputs when generating OP
// functions. While, for very few OPs, the dispensable outputs are used, we
// need to manually specify them in this map.
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>>
op_outs_map
=
{
{
"fake_quantize_dequantize_moving_average_abs_max"
,
{
"Out"
,
"OutScale"
,
"OutAccum"
,
"OutState"
}},
{
"batch_norm"
,
{
"Y"
,
"MeanOut"
,
"VarianceOut"
,
"SavedMean"
,
"SavedVariance"
,
"ReserveSpace"
}},
{
"fused_attention"
,
{
"LnMean"
,
"LnVariance"
,
"LnOut"
,
"QKVOut"
,
"QKVBiasOut"
,
"TransposeOut2"
,
"QKOut"
,
"QKTVOut"
,
"SoftmaxOut"
,
"AttnDropoutMaskOut"
,
"AttnDropoutOut"
,
"SrcMaskOut"
,
"FMHAOut"
,
"OutLinearOut"
,
"DropoutMaskOut"
,
"Ln2Mean"
,
"Ln2Variance"
,
"BiasDropoutResidualOut"
,
"Y"
}},
{
"sync_batch_norm"
,
{
"Y"
,
"MeanOut"
,
"VarianceOut"
,
"SavedMean"
,
"SavedVariance"
,
"ReserveSpace"
}},
{
"unique"
,
{
"Out"
,
"Index"
,
"Indices"
,
"Counts"
}},
{
"unique_consecutive"
,
{
"Out"
,
"Index"
,
"Counts"
}},
{
"generate_proposals"
,
{
"RpnRois"
,
"RpnRoiProbs"
,
"RpnRoisNum"
}},
{
"collect_fpn_proposals"
,
{
"FpnRois"
,
"RoisNum"
}},
{
"matrix_nms"
,
{
"Out"
,
"Index"
,
"RoisNum"
}},
{
"distribute_fpn_proposals"
,
{
"MultiFpnRois"
,
"RestoreIndex"
,
"MultiLevelRoIsNum"
}},
{
"moving_average_abs_max_scale"
,
{
"Out"
,
"OutScale"
,
"OutAccum"
,
"OutState"
}},
{
"multiclass_nms3"
,
{
"Out"
,
"NmsRoisNum"
}},
{
"generate_proposals_v2"
,
{
"RpnRois"
,
"RpnRoiProbs"
,
"RpnRoisNum"
}},
{
"momentum"
,
{
"ParamOut"
,
"VelocityOut"
,
"MasterParamOut"
}},
{
"sparse_momentum"
,
{
"ParamOut"
,
"VelocityOut"
}},
{
"rnn"
,
{
"DropoutState"
,
"Reserve"
,
"Out"
,
"State"
}},
{
"lamb"
,
{
"ParamOut"
,
"Moment1Out"
,
"Moment2Out"
,
"Beta1PowOut"
,
"Beta2PowOut"
}},
{
"run_program"
,
{
"DOut"
}},
{
"adam"
,
{
"ParamOut"
,
"Moment1Out"
,
"Moment2Out"
,
"Beta1PowOut"
,
"Beta2PowOut"
,
"MasterParamOut"
}},
{
"adamw"
,
{
"ParamOut"
,
"Moment1Out"
,
"Moment2Out"
,
"Beta1PowOut"
,
"Beta2PowOut"
,
"MasterParamOut"
}},
};
// NOTE(zhiqiu): Commonly, the outputs in auto-generated OP function are
// generated in C++ automatically.
// However, some OPs need to pass the outputs from Python instead of generating
...
...
paddle/fluid/pybind/op_function_generator.h
0 → 100644
浏览文件 @
06c3cce9
// Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
//
// 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.
#pragma once
#include <map>
#include <set>
#include <string>
// NOTE(zhiqiu): Commonly, the inputs in auto-generated OP function are
// determined by the OP`s proto automatically, i.e., all the inputs registered
// in OpMaker.
// However, some OPs have dispensable inputs, which means the input can
// be none for some conditions. It is discovered that most dispensable inputs
// is not used in imperative mode, so we drop those inputs when generating OP
// functions. While, for very few OPs, the dispensable inputs are used, we
// need to manually specify them in this map.
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>>
op_ins_map
=
{
{
"layer_norm"
,
{
"X"
,
"Scale"
,
"Bias"
}},
{
"bincount"
,
{
"X"
,
"Weights"
}},
{
"fused_attention"
,
{
"X"
,
"LnScale"
,
"LnBias"
,
"QKVW"
,
"QKVBias"
,
"SrcMask"
,
"OutLinearW"
,
"OutLinearBias"
,
"Ln2Scale"
,
"Ln2Bias"
}},
{
"instance_norm"
,
{
"X"
,
"Scale"
,
"Bias"
}},
{
"gru_unit"
,
{
"Input"
,
"HiddenPrev"
,
"Weight"
,
"Bias"
}},
{
"label_smooth"
,
{
"X"
,
"PriorDist"
}},
{
"assign"
,
{
"X"
}},
{
"reshape2"
,
{
"X"
,
"Shape"
}},
{
"expand"
,
{
"X"
,
"ExpandTimes"
}},
{
"slice"
,
{
"Input"
,
"StartsTensor"
,
"EndsTensor"
}},
{
"fake_quantize_dequantize_moving_average_abs_max"
,
{
"X"
,
"InScale"
,
"InAccum"
,
"InState"
}},
{
"nll_loss"
,
{
"X"
,
"Label"
,
"Weight"
}},
{
"bilinear_tensor_product"
,
{
"X"
,
"Y"
,
"Weight"
,
"Bias"
}},
{
"gather"
,
{
"X"
,
"Index"
,
"Axis"
}},
{
"roi_pool"
,
{
"X"
,
"ROIs"
,
"RoisNum"
}},
{
"roi_align"
,
{
"X"
,
"ROIs"
,
"RoisNum"
}},
{
"psroi_pool"
,
{
"X"
,
"ROIs"
,
"RoisNum"
}},
{
"collect_fpn_proposals"
,
{
"MultiLevelRois"
,
"MultiLevelScores"
,
"MultiLevelRoIsNum"
}},
{
"distribute_fpn_proposals"
,
{
"FpnRois"
,
"RoisNum"
}},
{
"warpctc"
,
{
"Logits"
,
"Label"
,
"LogitsLength"
,
"LabelLength"
}},
{
"hierarchical_sigmoid"
,
{
"X"
,
"W"
,
"Label"
,
"PathTable"
,
"PathCode"
,
"Bias"
}},
{
"moving_average_abs_max_scale"
,
{
"X"
,
"InAccum"
,
"InState"
}},
{
"multiclass_nms3"
,
{
"BBoxes"
,
"Scores"
,
"RoisNum"
}},
{
"box_coder"
,
{
"PriorBox"
,
"PriorBoxVar"
,
"TargetBox"
}},
{
"momentum"
,
{
"Param"
,
"Grad"
,
"Velocity"
,
"LearningRate"
,
"MasterParam"
}},
{
"sparse_momentum"
,
{
"Param"
,
"Grad"
,
"Velocity"
,
"Index"
,
"LearningRate"
}},
{
"rnn"
,
{
"Input"
,
"PreState"
,
"WeightList"
,
"SequenceLength"
}},
{
"run_program"
,
{
"X"
,
"Params"
}},
{
"fused_feedforward"
,
{
"Dropout1Seed"
,
"Dropout2Seed"
,
"Linear1Bias"
,
"Linear2Bias"
,
"Ln1Scale"
,
"Ln1Bias"
,
"Ln2Scale"
,
"Ln2Bias"
}},
{
"faster_tokenizer"
,
{
"Text"
,
"Vocab"
,
"TextPair"
}},
{
"matrix_rank"
,
{
"X"
,
"TolTensor"
}},
{
"adam"
,
{
"Param"
,
"Grad"
,
"LearningRate"
,
"Moment1"
,
"Moment2"
,
"Beta1Pow"
,
"Beta2Pow"
,
"MasterParam"
}},
{
"adamw"
,
{
"Param"
,
"Grad"
,
"LearningRate"
,
"Moment1"
,
"Moment2"
,
"Beta1Pow"
,
"Beta2Pow"
,
"MasterParam"
}},
};
// NOTE(zhiqiu): Like op_ins_map.
// Commonly, the outputs in auto-generated OP function are determined by the
// OP`s proto automatically, i.e., all the outputs registered in OpMaker.
// However, some OPs have dispensable outputs, which means the output can
// be none for some conditions. It is discovered that most dispensable outputs
// is not used in imperative mode, so we drop those outputs when generating OP
// functions. While, for very few OPs, the dispensable outputs are used, we
// need to manually specify them in this map.
std
::
map
<
std
::
string
,
std
::
set
<
std
::
string
>>
op_outs_map
=
{
{
"fake_quantize_dequantize_moving_average_abs_max"
,
{
"Out"
,
"OutScale"
,
"OutAccum"
,
"OutState"
}},
{
"batch_norm"
,
{
"Y"
,
"MeanOut"
,
"VarianceOut"
,
"SavedMean"
,
"SavedVariance"
,
"ReserveSpace"
}},
{
"fused_attention"
,
{
"LnMean"
,
"LnVariance"
,
"LnOut"
,
"QKVOut"
,
"QKVBiasOut"
,
"TransposeOut2"
,
"QKOut"
,
"QKTVOut"
,
"SoftmaxOut"
,
"AttnDropoutMaskOut"
,
"AttnDropoutOut"
,
"SrcMaskOut"
,
"FMHAOut"
,
"OutLinearOut"
,
"DropoutMaskOut"
,
"Ln2Mean"
,
"Ln2Variance"
,
"BiasDropoutResidualOut"
,
"Y"
}},
{
"sync_batch_norm"
,
{
"Y"
,
"MeanOut"
,
"VarianceOut"
,
"SavedMean"
,
"SavedVariance"
,
"ReserveSpace"
}},
{
"unique"
,
{
"Out"
,
"Index"
,
"Indices"
,
"Counts"
}},
{
"unique_consecutive"
,
{
"Out"
,
"Index"
,
"Counts"
}},
{
"generate_proposals"
,
{
"RpnRois"
,
"RpnRoiProbs"
,
"RpnRoisNum"
}},
{
"collect_fpn_proposals"
,
{
"FpnRois"
,
"RoisNum"
}},
{
"matrix_nms"
,
{
"Out"
,
"Index"
,
"RoisNum"
}},
{
"distribute_fpn_proposals"
,
{
"MultiFpnRois"
,
"RestoreIndex"
,
"MultiLevelRoIsNum"
}},
{
"moving_average_abs_max_scale"
,
{
"Out"
,
"OutScale"
,
"OutAccum"
,
"OutState"
}},
{
"multiclass_nms3"
,
{
"Out"
,
"NmsRoisNum"
}},
{
"generate_proposals_v2"
,
{
"RpnRois"
,
"RpnRoiProbs"
,
"RpnRoisNum"
}},
{
"momentum"
,
{
"ParamOut"
,
"VelocityOut"
,
"MasterParamOut"
}},
{
"sparse_momentum"
,
{
"ParamOut"
,
"VelocityOut"
}},
{
"rnn"
,
{
"DropoutState"
,
"Reserve"
,
"Out"
,
"State"
}},
{
"lamb"
,
{
"ParamOut"
,
"Moment1Out"
,
"Moment2Out"
,
"Beta1PowOut"
,
"Beta2PowOut"
}},
{
"run_program"
,
{
"DOut"
}},
{
"adam"
,
{
"ParamOut"
,
"Moment1Out"
,
"Moment2Out"
,
"Beta1PowOut"
,
"Beta2PowOut"
,
"MasterParamOut"
}},
{
"adamw"
,
{
"ParamOut"
,
"Moment1Out"
,
"Moment2Out"
,
"Beta1PowOut"
,
"Beta2PowOut"
,
"MasterParamOut"
}},
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录