paddle/fluid/framework/executor.cc
static bool has_feed_operators(
    const BlockDesc& block,
    std::map<std::string, const LoDTensor*>& feed_targets,
    const std::string& feed_holder_name) {
  size_t feed_count = 0;
  for (auto* op : block.AllOps()) {
    if (op->Type() == kFeedOpType) {
      feed_count++;
      PADDLE_ENFORCE_EQ(op->Input("X")[0], feed_holder_name,
                        "Input to feed op should be '%s'", feed_holder_name);
      std::string feed_target_name = op->Output("Out")[0];
      PADDLE_ENFORCE(
          feed_targets.find(feed_target_name) != feed_targets.end(),
          "Feed operator output name '%s' cannot be found in 'feed_targets'",
          feed_target_name);
    }
  }

  if (feed_count > 0) {
    PADDLE_ENFORCE_EQ(
        feed_count, feed_targets.size(),
        "The number of feed operators should match 'feed_targets'");

    // When feed operator are present, so should be feed_holder
    auto var = block.FindVar(feed_holder_name);
    PADDLE_ENFORCE_NOT_NULL(var, "Block should already have a '%s' variable",
                            feed_holder_name);
    PADDLE_ENFORCE_EQ(var->GetType(), proto::VarType::FEED_MINIBATCH,
                      "'%s' variable should be 'FEED_MINIBATCH' type",
                      feed_holder_name);
  }

  return feed_count > 0;
}
// Check whether the block already has feed operators and feed_holder.
// Return false if the block does not have any feed operators.
// If some feed operators have been prepended to the block, check that
// the info contained in these feed operators matches the feed_targets
// and feed_holder_name. Raise exception when any mismatch is found.
// Return true if the block has feed operators and holder of matching info.
Check whether the block already has feed operators and feed_holder.
Return false if the block does not have any feed operators.
If some feed operators have been prepended to the block, check that
the info contained in these feed operators matches the feed_targets
and feed_holder_name. Raise exception when any mismatch is found.
Return true if the block has feed operators and holder of matching info.
Check whether the block already has feed operators and feed_holder . Return false if the block does not have any feed operators . If some feed operators have been prepended to the block check that the info contained in these feed operators matches the feed_targets and feed_holder_name . Raise exception when any mismatch is found . Return true if the block has feed operators and holder of matching info .
static bool has_feed_operators(
    const BlockDesc& block,
    std::map<std::string, const LoDTensor*>& feed_targets,
    const std::string& feed_holder_name) {
  size_t feed_count = 0;
  for (auto* op : block.AllOps()) {
    if (op->Type() == kFeedOpType) {
      feed_count++;
      PADDLE_ENFORCE_EQ(op->Input("X")[0], feed_holder_name,
                        "Input to feed op should be '%s'", feed_holder_name);
      std::string feed_target_name = op->Output("Out")[0];
      PADDLE_ENFORCE(
          feed_targets.find(feed_target_name) != feed_targets.end(),
          "Feed operator output name '%s' cannot be found in 'feed_targets'",
          feed_target_name);
    }
  }
  if (feed_count > 0) {
    PADDLE_ENFORCE_EQ(
        feed_count, feed_targets.size(),
        "The number of feed operators should match 'feed_targets'");
    auto var = block.FindVar(feed_holder_name);
    PADDLE_ENFORCE_NOT_NULL(var, "Block should already have a '%s' variable",
                            feed_holder_name);
    PADDLE_ENFORCE_EQ(var->GetType(), proto::VarType::FEED_MINIBATCH,
                      "'%s' variable should be 'FEED_MINIBATCH' type",
                      feed_holder_name);
  }
  return feed_count > 0;
}
static bool has_feed_operators ( const BlockDesc & block , std :: map < std :: string , const LoDTensor * > & feed_targets , const std :: string & feed_holder_name ) { size_t feed_count = 0 ; for ( auto * op : block . AllOps ( ) ) { if ( op -> Type ( ) == kFeedOpType ) { feed_count ++ ; PADDLE_ENFORCE_EQ ( op -> Input ( " " ) [ 0 ] , feed_holder_name , " " , feed_holder_name ) ; std :: string feed_target_name = op -> Output ( " " ) [ 0 ] ; PADDLE_ENFORCE ( feed_targets . find ( feed_target_name ) != feed_targets . end ( ) , " " , feed_target_name ) ; } } if ( feed_count > 0 ) { PADDLE_ENFORCE_EQ ( feed_count , feed_targets . size ( ) , " " ) ; auto var = block . FindVar ( feed_holder_name ) ; PADDLE_ENFORCE_NOT_NULL ( var , " " , feed_holder_name ) ; PADDLE_ENFORCE_EQ ( var -> GetType ( ) , proto :: VarType :: FEED_MINIBATCH , " " , feed_holder_name ) ; } return feed_count > 0 ; }
Check whether the block already has feed operators and feed_holder.
Check whether the block already has feed operators and feed_holder .
// When feed operator are present, so should be feed_holder