diff --git a/onnxruntime/core/framework/session_state.cc b/onnxruntime/core/framework/session_state.cc index 1f19fd86a37b0..731fe2ebf32df 100644 --- a/onnxruntime/core/framework/session_state.cc +++ b/onnxruntime/core/framework/session_state.cc @@ -423,11 +423,8 @@ Status SessionState::PrepackConstantInitializedTensors(InlinedHashMap(); - auto iter = initializers_to_share_map.find(input_name); - bool is_shared_initializer = (iter != initializers_to_share_map.end()); - // Caching pre-packed weights is limited to shared initializers associated with the CPU EP for now - if (is_shared_initializer && should_cache_prepacked_weights_for_shared_initializers && + if (should_cache_prepacked_weights_for_shared_initializers && node.GetExecutionProviderType() == kCpuExecutionProvider) { // caching of pre-packed weights' turned ON AllocatorPtr allocator_for_caching = prepacked_weights_container_->GetOrCreateAllocator(CPU);