diff --git a/xla/stream_executor/plugin_registry.cc b/xla/stream_executor/plugin_registry.cc index c915ff90523a5..77d489b5f8cbb 100644 --- a/xla/stream_executor/plugin_registry.cc +++ b/xla/stream_executor/plugin_registry.cc @@ -75,17 +75,19 @@ absl::Status PluginRegistry::RegisterFactoryInternal( bool PluginRegistry::HasFactory(Platform::Id platform_id, PluginKind plugin_kind) const { auto iter = factories_.find(platform_id); - if (iter != factories_.end()) { - switch (plugin_kind) { - case PluginKind::kBlas: - return iter->second.blas.has_value(); - case PluginKind::kDnn: - return iter->second.dnn.has_value(); - case PluginKind::kFft: - return iter->second.fft.has_value(); - default: - break; - } + if (iter == factories_.end()) { + return false; + } + + switch (plugin_kind) { + case PluginKind::kBlas: + return iter->second.blas.has_value(); + case PluginKind::kDnn: + return iter->second.dnn.has_value(); + case PluginKind::kFft: + return iter->second.fft.has_value(); + default: + break; } LOG(ERROR) << "Invalid plugin kind specified: "