From 4dbe6c98ca9be6654910b58c39cde47a056de587 Mon Sep 17 00:00:00 2001 From: Jeff Bloomfield <38966965+jeffbloo@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:49:43 -0800 Subject: [PATCH] Fix crash in PadFusion transform (#18544) This makes a minimal change to address a crash caused by the PadFusion pass. This pass assumed that the "pads" attribute of a child node existed, and it now skips when it's missing. --- onnxruntime/core/optimizer/pad_fusion.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/onnxruntime/core/optimizer/pad_fusion.cc b/onnxruntime/core/optimizer/pad_fusion.cc index b25e7618802dd..a1c7f8de9e6fe 100644 --- a/onnxruntime/core/optimizer/pad_fusion.cc +++ b/onnxruntime/core/optimizer/pad_fusion.cc @@ -48,6 +48,11 @@ bool PadFusion::SatisfyCondition(const Graph& graph, const Node& node, const log return false; } + // This pass currently assumed that this attribute already exists on the child node + if (child_node.GetAttributes().find("pads") == child_node.GetAttributes().end()) { + return false; + } + const NodeAttributes& pad_attributes = node.GetAttributes(); if (pad_attributes.find("mode") != pad_attributes.end() && pad_attributes.at("mode").s() != "constant") {