Handle grappler failure in savedmodel importer properly
PiperOrigin-RevId: 351914138 Change-Id: I94db8b279385ea91483ef9f47bb43b7fe23180ed
This commit is contained in:
parent
571c19440d
commit
aebcab97df
@ -3368,7 +3368,7 @@ class SavedModelSignatureDefImporterLite {
|
||||
const GraphDebugInfo& debug_info() const { return debug_info_; }
|
||||
|
||||
private:
|
||||
const MetaGraphDef& meta_graph_def_;
|
||||
MetaGraphDef meta_graph_def_;
|
||||
const GraphDebugInfo& debug_info_;
|
||||
std::unique_ptr<Graph> graph_;
|
||||
absl::Span<std::string> exported_names_;
|
||||
@ -3379,10 +3379,11 @@ class SavedModelSignatureDefImporterLite {
|
||||
|
||||
Status SavedModelSignatureDefImporterLite::InitializeGraph(
|
||||
MLIRImportOptions import_options) {
|
||||
// TODO(jpienaar): Remove need to const_cast.
|
||||
if (import_options.enable_grappler)
|
||||
TF_RETURN_IF_ERROR(
|
||||
RunGrappler(const_cast<MetaGraphDef*>(&meta_graph_def_)));
|
||||
if (import_options.enable_grappler) {
|
||||
// Grappler is best-effort.
|
||||
auto status = RunGrappler(&meta_graph_def_);
|
||||
if (!status.ok()) LOG(WARNING) << status;
|
||||
}
|
||||
|
||||
GraphDef graph_def = meta_graph_def_.graph_def();
|
||||
if (import_options.upgrade_legacy) {
|
||||
|
||||
@ -130,6 +130,10 @@ Status RunGrappler(MetaGraphDef* meta_graph_def) {
|
||||
std::unique_ptr<grappler::GrapplerItem> item =
|
||||
grappler::GrapplerItemFromMetaGraphDef("graph", *meta_graph_def,
|
||||
grappler::ItemConfig());
|
||||
if (!item) {
|
||||
return tensorflow::errors::Internal(
|
||||
"Failed to create grappler item from MetaGraphDef.");
|
||||
}
|
||||
|
||||
grappler::VirtualCluster cluster(&dev_set);
|
||||
return grappler::RunMetaOptimizer(std::move(*item), config_proto, cpu_device,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user