提交 22aacbfd 编写于 作者: Y Yu Yang

Add const to GradientMachine::eval

上级 2965df51
......@@ -186,7 +186,7 @@ public:
/**
* evaluate using the given evaluator
*/
virtual void eval(Evaluator* evaluator) = 0;
virtual void eval(Evaluator* evaluator) const = 0;
std::vector<ParameterPtr>& getParameters() { return parameters_; }
......
......@@ -331,7 +331,7 @@ Evaluator* MultiGradientMachine::makeEvaluator() {
return threads_[0]->getGradientMachine()->makeEvaluator();
}
void MultiGradientMachine::eval(Evaluator* evaluator) {
void MultiGradientMachine::eval(Evaluator* evaluator) const {
for (auto& thread : threads_) {
SetDevice device(thread->getDeviceId());
thread->getGradientMachine()->eval(evaluator);
......
......@@ -195,7 +195,7 @@ public:
virtual Evaluator* makeEvaluator();
virtual void eval(Evaluator* evaluator);
virtual void eval(Evaluator* evaluator) const;
bool useGpu() const { return useGpu_; }
......
......@@ -181,6 +181,6 @@ Evaluator* MultiNetwork::makeEvaluator() {
return multiCombinedEvaluator;
}
void MultiNetwork::eval(Evaluator* evaluator) { evaluator->eval(*this); }
void MultiNetwork::eval(Evaluator* evaluator) const { evaluator->eval(*this); }
} // namespace paddle
......@@ -48,7 +48,7 @@ public:
virtual Evaluator* makeEvaluator();
virtual void eval(Evaluator* evaluator);
virtual void eval(Evaluator* evaluator) const;
const std::vector<std::unique_ptr<NeuralNetwork>>& getSubNetworks() const {
return subNetworks_;
......
......@@ -383,7 +383,7 @@ Evaluator* NeuralNetwork::makeEvaluator() {
return combinedEvaluator;
}
void NeuralNetwork::eval(Evaluator* evaluator) { evaluator->eval(*this); }
void NeuralNetwork::eval(Evaluator* evaluator) const { evaluator->eval(*this); }
void NeuralNetwork::setOutputGrad(const std::vector<Argument>& args) {
CHECK_GE(outputLayers_.size(), args.size());
......
......@@ -98,7 +98,7 @@ public:
virtual Evaluator* makeEvaluator();
virtual void eval(Evaluator* evaluator);
virtual void eval(Evaluator* evaluator) const;
virtual void resetState();
virtual void setOutputGrad(const std::vector<Argument>& args);
......
......@@ -593,7 +593,7 @@ void RecurrentGradientMachine::forwardBackward(
LOG(FATAL) << "should not use this function";
}
void RecurrentGradientMachine::eval(Evaluator* evaluator) {
void RecurrentGradientMachine::eval(Evaluator* evaluator) const {
// call printers frame by frame
for (int i = 0; i < maxSequenceLength_; ++i) {
LOG(INFO) << "Recurrent Layer Group eval frame " << i << " begin";
......
......@@ -63,7 +63,7 @@ public:
const UpdateCallback& callback);
virtual void resetState() {}
virtual void eval(Evaluator* evaluator);
virtual void eval(Evaluator* evaluator) const;
const std::vector<int>& getParameterIds() { return parameterIds_; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册