Remove OperatorBase::Init
Created by: wangkuiyi
After a grep, I noticed two classes that overrides OperatorBase::Init:
-
RecurrentOp::Init():
void RecurrentOp::Init() { OperatorBase::Init(); std::unique_ptr<rnn::Argument> arg(new rnn::Argument()); rnn::InitArgument(kArgName, arg.get(), *this); alg_.Init(std::move(arg)); }
-
FullyConnectedOp::Init():
void Init() override { AddOp(OpRegistry::CreateOp("mul", { Input("X"), Input("W"), }, {Output("before_act")}, {})); auto b = Input("b"); if (b != EMPTY_VAR_NAME()) { AddOp(OpRegistry::CreateOp("rowwise_add", {Output("before_act"), Input("b")}, {Output("before_act")}, {})); } auto activation = GetAttr<std::string>("activation"); AddOp(OpRegistry::CreateOp( activation, {Output("before_act")}, {Output("Y")}, {})); CompleteAddOp(false); }
It seems both code snippets can be moved into class constructors. Indeed, given that OperatorBase::Init()
doesn't have any parameters, it doesn't provide any extra context than the constructor.