onnxruntime/core/framework/utils.cc
// check if all the execution providers use the same allocator. if so, no copies between devices should be required,
// and the overall status for DeviceCopyChecks can be set to NoCopy
check if all the execution providers use the same allocator. if so, no copies between devices should be required,
and the overall status for DeviceCopyChecks can be set to NoCopy
check if all the execution providers use the same allocator . if so no copies between devices should be required and the overall status for DeviceCopyChecks can be set to NoCopy
static DeviceCopyCheck CheckExecutionProviders(const ExecutionProviders& execution_providers) {
  bool all_cpu = true;
  for (const auto& execution_provider : execution_providers) {
    const auto& allocators = execution_provider->GetAllocators();
    if (!std::all_of(allocators.cbegin(), allocators.cend(),
                     [](const gsl::not_null<const IAllocator*>& allocator) {
                       return strcmp(allocator->Info().name, CPU) == 0;
                     })) {
      all_cpu = false;
      break;
    }
  }
  return all_cpu ? DeviceCopyCheck::NoCopy : DeviceCopyCheck::Unknown;
}
static DeviceCopyCheck CheckExecutionProviders ( const ExecutionProviders & execution_providers ) { bool all_cpu = true ; for ( const auto & execution_provider : execution_providers ) { const auto & allocators = execution_provider -> GetAllocators ( ) ; if ( ! std :: all_of ( allocators . cbegin ( ) , allocators . cend ( ) , [ ] ( const gsl :: not_null < const IAllocator * > & allocator ) { return strcmp ( allocator -> Info ( ) . name , CPU ) == 0 ; } ) ) { all_cpu = false ; break ; } } return all_cpu ? DeviceCopyCheck :: NoCopy : DeviceCopyCheck :: Unknown ; }
check if all the execution providers use the same allocator.
check if all the execution providers use the same allocator .
// this won't work as desired until multiple providers can share the CPU Allocator and the logic here is updated // to detect that.. // it will currently handle the scenario when only the CPUExecutionProvider is registered though