@@ -83,8 +83,8 @@ static void CheckTensorNANOrInf(const std::string& name,
83
83
if (tensor.memory_size () == 0 ) {
84
84
return ;
85
85
}
86
- if (tensor.type ().hash_code () != typeid (float ).hash_code () &&
87
- tensor.type ().hash_code () != typeid (double ).hash_code ()) {
86
+ if (tensor.type ().hash_code () != typeid (float ).hash_code () && // NOLINT
87
+ tensor.type ().hash_code () != typeid (double ).hash_code ()) { // NOLINT
88
88
return ;
89
89
}
90
90
PADDLE_ENFORCE (!framework::TensorContainsInf (tensor),
@@ -145,12 +145,13 @@ void Executor::Run(const ProgramDesc& pdesc, Scope* scope, int block_id,
145
145
// Return true if the block has feed operators and holder of matching info.
146
146
static bool has_feed_operators (
147
147
const BlockDesc& block,
148
- std::map<std::string, const LoDTensor*>& feed_targets,
148
+ const std::map<std::string, const LoDTensor*>& feed_targets,
149
149
const std::string& feed_holder_name) {
150
150
size_t feed_count = 0 ;
151
151
for (auto * op : block.AllOps ()) {
152
152
if (op->Type () == kFeedOpType ) {
153
153
feed_count++;
154
+ // The input variable's name of feed_op should be feed_holder_name.
154
155
PADDLE_ENFORCE_EQ (op->Input (" X" )[0 ], feed_holder_name,
155
156
" Input to feed op should be '%s'" , feed_holder_name);
156
157
std::string feed_target_name = op->Output (" Out" )[0 ];
@@ -167,7 +168,7 @@ static bool has_feed_operators(
167
168
" The number of feed operators should match 'feed_targets'" );
168
169
169
170
if (!feed_holder_name.empty ()) {
170
- // When feed operator are present, so should be feed_holder
171
+ // When feed operator are present, so should be feed_holder.
171
172
auto var = block.FindVar (feed_holder_name);
172
173
PADDLE_ENFORCE_NOT_NULL (var, " Block should already have a '%s' variable" ,
173
174
feed_holder_name);
@@ -187,12 +188,14 @@ static bool has_feed_operators(
187
188
// and fetch_holder_name. Raise exception when any mismatch is found.
188
189
// Return true if the block has fetch operators and holder of matching info.
189
190
static bool has_fetch_operators (
190
- const BlockDesc& block, std::map<std::string, LoDTensor*>& fetch_targets,
191
+ const BlockDesc& block,
192
+ const std::map<std::string, LoDTensor*>& fetch_targets,
191
193
const std::string& fetch_holder_name) {
192
194
size_t fetch_count = 0 ;
193
195
for (auto * op : block.AllOps ()) {
194
196
if (op->Type () == kFetchOpType ) {
195
197
fetch_count++;
198
+ // The output variable's name of fetch_op should be fetch_holder_name.
196
199
PADDLE_ENFORCE_EQ (op->Output (" Out" )[0 ], fetch_holder_name,
197
200
" Output of fetch op should be '%s'" , fetch_holder_name);
198
201
std::string fetch_target_name = op->Input (" X" )[0 ];
@@ -209,7 +212,7 @@ static bool has_fetch_operators(
209
212
" The number of fetch operators should match 'fetch_targets'" );
210
213
211
214
if (!fetch_holder_name.empty ()) {
212
- // When fetch operator are present, so should be fetch_holder
215
+ // When fetch operator are present, so should be fetch_holder.
213
216
auto var = block.FindVar (fetch_holder_name);
214
217
PADDLE_ENFORCE_NOT_NULL (var, " Block should already have a '%s' variable" ,
215
218
fetch_holder_name);
@@ -287,8 +290,8 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
287
290
}
288
291
289
292
auto ctx = Prepare (*copy_program, 0 );
290
- RunPreparedContext (ctx.get (), scope, feed_targets, fetch_targets,
291
- feed_holder_name, fetch_holder_name, create_vars );
293
+ RunPreparedContext (ctx.get (), scope, feed_targets, fetch_targets, create_vars,
294
+ feed_holder_name, fetch_holder_name);
292
295
}
293
296
294
297
std::unique_ptr<ExecutorPrepareContext> Executor::Prepare (
0 commit comments