-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Closed
Labels
Description
目前,有的Op
使用的输出的名字为Out
,比如:
ScaleOp: Out = scale * X
IdentityOp: Out = X
MulOp: Out = X * Y
AddOp: Out = X + Y
MinusOp: Out = X - Y
...
有的Op
使用的输出的名字为Y
,比如:
SigmoidOp: Y = 1 / (1 - exp(-X))
SoftmaxOp: Y[i, j] = exp(X[i, j]) / sum_j(exp(X[i, j]))
OnehotCrossEntropyOp: Y[i] = -log(X[i][j])
...
命名的不统一,使得一些组合Op写起来需要特别小心。比如FCOp
中需要调用激活函数Op
,支持identity
, sigmoid
, softmax
类型,现在代码必须写成:
auto activation = GetAttr<std::string>("activation");
if (activation == "identity") {
AppendOp(framework::OpRegistry::CreateOp(
activation, {{"X", {Output("add_out")}}}, {{"Out", {Output("Out")}}}, {}));
} else {
AppendOp(framework::OpRegistry::CreateOp(
activation, {{"X", {Output("add_out")}}}, {{"Y", {Output("Out")}}}, {}));
}
鉴于有些Op
会使用Y
作为输入,Op
的输出的名字是否需要统一为Out
?
luotao1, lcy-seso and hedaoyuan