It is not hard to simply evaluate a graph. However, it is hard to determine which op should be run. Consider the following different situations.
```python
# Case 1: run foward pass.
cost_np=executor.run(target=cost)
# Case 2: run backward passing.
opts_np,_=executor.run(target=[cost,opt])
# Case 3: run checkpointing
_=executor.run(target=checkpoint)
```
We want to support the evaluation of both variables and operators.
## Solution
To support evaluation of operators, we add `is_target` field in the `OpDesc`.
```c++
messageOpDesc{
requiredstringtype=3;
repeatedVarinputs=1;
repeatedVaroutputs=2;
repeatedAttrattrs=4;
requiredboolis_target=5[default=false];// true if the op is target
};
```
To support evaluation of variables, we add [fetch_op](https://github.com/PaddlePaddle/Paddle/pull/4599). For each variable in the `target`, we insert a `fetch_op` into the `ProgramDesc`. (Also, a user may want to overwrite a variable, so we also added [feed_op](https://github.com/PaddlePaddle/Paddle/pull/4599). )