onnxruntime/core/framework/utils.cc
// copies inputs across devices only if required and save copy_info
copies inputs across devices only if required and save copy_info
copies inputs across devices only if required and save copy_info
static common::Status CopyInputsAcrossDevices(const SessionState& session_state,
                                              const std::vector<std::string>& feed_names,
                                              const std::vector<MLValue>& orig_feeds,
                                              std::vector<MLValue>& new_feeds,
                                              bool& needed_copy,
                                              std::vector<FeedsFetchesManager::MLValueCopyInfo>* copy_info) {
  bool copied = false;
  size_t num_feeds = orig_feeds.size();
  ORT_ENFORCE(feed_names.size() == num_feeds);
  new_feeds.resize(num_feeds);
  if (copy_info) {
    copy_info->resize(num_feeds);
  }
  for (size_t idx = 0; idx < num_feeds; ++idx) {
    bool copied_this_input = false;
    FeedsFetchesManager::MLValueCopyInfo current_copy_info = {};  
    ORT_RETURN_IF_ERROR(CopyOneInputAcrossDevices(session_state, feed_names[idx], orig_feeds[idx], new_feeds[idx],
                                                  copied_this_input, current_copy_info));
    if (copied_this_input) {
      copied = true;
      if (copy_info) {
        (*copy_info)[idx] = std::move(current_copy_info);
      }
    }
  }
  needed_copy = copied;
  return Status::OK();
}
static common :: Status CopyInputsAcrossDevices ( const SessionState & session_state , const std :: vector < std :: string > & feed_names , const std :: vector < MLValue > & orig_feeds , std :: vector < MLValue > & new_feeds , bool & needed_copy , std :: vector < FeedsFetchesManager :: MLValueCopyInfo > * copy_info ) { bool copied = false ; size_t num_feeds = orig_feeds . size ( ) ; ORT_ENFORCE ( feed_names . size ( ) == num_feeds ) ; new_feeds . resize ( num_feeds ) ; if ( copy_info ) { copy_info -> resize ( num_feeds ) ; } for ( size_t idx = 0 ; idx < num_feeds ; ++ idx ) { bool copied_this_input = false ; FeedsFetchesManager :: MLValueCopyInfo current_copy_info = { } ; ORT_RETURN_IF_ERROR ( CopyOneInputAcrossDevices ( session_state , feed_names [ idx ] , orig_feeds [ idx ] , new_feeds [ idx ] , copied_this_input , current_copy_info ) ) ; if ( copied_this_input ) { copied = true ; if ( copy_info ) { ( * copy_info ) [ idx ] = std :: move ( current_copy_info ) ; } } } needed_copy = copied ; return Status :: OK ( ) ; }
copies inputs across devices only if required and save copy_info
copies inputs across devices only if required and save copy_info
// init for each call