Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c7e3f63
[QNN EP] Add Unit tests for LPBQ Fusions (#25592)
quic-tirupath Jul 31, 2025
2bd947a
[QNN-EP] Resolve VTCM buffer sharing bugs (#25622)
quic-calvnguy Aug 1, 2025
eb95592
Update QAIRT to 2.37.0 (#25688)
qti-kromero Aug 8, 2025
86c1eae
[QNN EP] Disable tests broken by QNN 2.37 (#25729)
qti-jkilpatrick Aug 12, 2025
c070271
Fix cleanup of Environment class. (#25743)
skottmckay Aug 15, 2025
c6a60ec
GatherBlockQuantized shape inference test (#25769)
jiafatom Aug 18, 2025
69dc281
[QNN-EP] Fix int64 graph output issue (#25745)
kuanyul-qti Aug 18, 2025
e7be54b
Expose GetOrtvalueInitializer via provider bridge (#25761)
yuslepukhin Aug 18, 2025
d8effa6
[QNN EP] Upgrade QNN to 2.37.1 (#25751)
qti-jkilpatrick Aug 18, 2025
2cca5c9
Fix bug for same option provided multiple times in perf test (#25716)
chilo-ms Aug 19, 2025
392627e
Add some device discovery support for non-Windows platforms (#25228)
edgchen1 Aug 19, 2025
9cac54b
[EP ABI] support `Graph_GetModelMetadata` (#25768)
wcy123 Aug 21, 2025
381d19f
[QNN EP] Fix Pool builder assert in Debug build. (#25788)
minfhong-qti Aug 20, 2025
5731750
[TRT RTX EP] EP context changes (#25747)
thevishalagarwal Aug 21, 2025
106cbcb
[NV TRT RTX EP] Reconfigure memory arena to grow with power of 2 (#25…
gedoensmax Aug 22, 2025
d156d0d
Add patch file for cpuinfo's vcpkg port (#25818)
snnn Aug 22, 2025
8c2266e
Introduce new C++ API for C interfaces (#25762)
yuslepukhin Aug 22, 2025
3cb441f
Add support for generating and validating compiled model compatibilit…
adrastogi Aug 22, 2025
dbf253e
Disable cpuinfo for ARM64EC builds. (#25831)
edgchen1 Aug 22, 2025
9190140
Update mac.yml iphone_simulator job - use Xcode 16.4 and simulator ru…
edgchen1 Aug 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[QNN EP] Fix Pool builder assert in Debug build. (#25788)
### Description
In PoolOpBuilder, 
- Revise the check to exploit ORT macros.
- Fix invoking the function for 5D cases.

### Motivation and Context
Refer to #25778.
Pool builder incorrectly invokes a function calculating 4D shape in 5D input, which originally expects 3D cases only. However, the check used assert to validate the shape, which did not work in Release nor RelWithDebInfo builds.
  • Loading branch information
minfhong-qti authored and adrianlizarraga committed Aug 22, 2025
commit 381d19f1a9207246418ea16fc3a28e892783d5cc
44 changes: 25 additions & 19 deletions onnxruntime/core/providers/qnn/builder/opbuilder/pool_op_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ Status PoolOpBuilder::IsOpSupported(QnnModelWrapper& qnn_model_wrapper,
return Status::OK();
}

static std::vector<uint32_t> AmendOutputShapeForRank3Pool(
Status AmendOutputShapeForRank3Pool(
gsl::span<const uint32_t> input_shape, // {N, H, W, C}
gsl::span<const uint32_t> kernel_shape, // {k_h, k_w}
gsl::span<const uint32_t> strides, // {s_h, s_w}
gsl::span<const uint32_t> pads) {
assert(input_shape.size() == 4 &&
kernel_shape.size() == 2 &&
strides.size() == 2 &&
pads.size() == 4);
gsl::span<const uint32_t> pads,
std::vector<uint32_t>& output_shape) {
ORT_RETURN_IF_NOT(input_shape.size() == 4, "Expecting input rank 4 for amending 1D Pool output shape.");
ORT_RETURN_IF_NOT(kernel_shape.size() == 2, "Expecting kernel size 2 for amending 1D Pool output shape.");
ORT_RETURN_IF_NOT(strides.size() == 2, "Expecting strides size 2 for amending 1D Pool output shape.");
ORT_RETURN_IF_NOT(pads.size() == 4, "Expecting pad size 4 for amending 1D Pool output shape.");

const uint32_t N = input_shape[0];
const uint32_t H = input_shape[1];
Expand All @@ -120,7 +121,13 @@ static std::vector<uint32_t> AmendOutputShapeForRank3Pool(
? 0
: (padded_W - kernel_shape[1]) / strides[1] + 1;

return {N, out_H, out_W, C};
output_shape.resize(4);
output_shape[0] = N;
output_shape[1] = out_H;
output_shape[2] = out_W;
output_shape[3] = C;

return Status::OK();
}

Status PoolOpBuilder::SetCommonPoolParams(const NodeAttrHelper& node_helper,
Expand Down Expand Up @@ -177,10 +184,7 @@ Status PoolOpBuilder::SetCommonPoolParams(const NodeAttrHelper& node_helper,
if (auto_pad.compare("NOTSET") != 0) {
if (output_shape.size() == 3) {
// Calculate rank-4 output shape for rank-3 input.
output_shape = AmendOutputShapeForRank3Pool(input_shape,
filter_size,
stride,
pad_amount);
ORT_RETURN_IF_ERROR(AmendOutputShapeForRank3Pool(input_shape, filter_size, stride, pad_amount, output_shape));
}

for (size_t axis = 0; axis < rank - 2; ++axis) {
Expand Down Expand Up @@ -365,14 +369,6 @@ Status PoolOpBuilder::ProcessAttributesAndOutputs(QnnModelWrapper& qnn_model_wra
std::move(output_shape)));
}

// Calculate rank-4 output shape for rank-3 input.
std::vector<uint32_t> onnx_in_shape;
ORT_RETURN_IF_NOT(qnn_model_wrapper.GetOnnxShape(inputs[0].node_arg, onnx_in_shape), "Cannot get shape");
if (onnx_in_shape.size() == 3) {
onnx_in_shape = {onnx_in_shape[0], 1, onnx_in_shape[1], onnx_in_shape[2]};
}
auto pooled_shape = AmendOutputShapeForRank3Pool(onnx_in_shape, filter_size, stride, pad_amount);

// Construct param wrappers.
ORT_RETURN_IF_NOT(SetPoolParam(node_unit,
param_filter_size,
Expand Down Expand Up @@ -443,6 +439,16 @@ Status PoolOpBuilder::ProcessAttributesAndOutputs(QnnModelWrapper& qnn_model_wra

return Status::OK();
}

// Calculate rank-4 output shape for rank-3 input.
std::vector<uint32_t> onnx_in_shape;
ORT_RETURN_IF_NOT(qnn_model_wrapper.GetOnnxShape(inputs[0].node_arg, onnx_in_shape), "Cannot get shape");
if (onnx_in_shape.size() == 3) {
onnx_in_shape = {onnx_in_shape[0], 1, onnx_in_shape[1], onnx_in_shape[2]};
}
std::vector<uint32_t> pooled_shape;
ORT_RETURN_IF_ERROR(AmendOutputShapeForRank3Pool(onnx_in_shape, filter_size, stride, pad_amount, pooled_shape));

const auto& outputs = node_unit.Outputs();
const std::string real_out = outputs[0].node_arg.Name();
const std::string pool_out = real_out + "_reshape_after";
Expand Down