Skip to content

Commit 3c9a652

Browse files
committed
Update stride computation
1 parent 8abd765 commit 3c9a652

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

backends/qualcomm/runtime/QnnManager.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,14 @@ Error QnnManager::Execute(
426426
QNN_TENSOR_VER_PTR(output_tensor)->dimensions +
427427
QNN_TENSOR_VER_PTR(output_tensor)->rank);
428428

429-
std::vector<executorch::aten::StridesType> stride_size(sizes.size(), 0);
429+
// Compute contiguous strides from sizes (e.g. [2,3,4] -> [12,4,1]).
430+
std::vector<executorch::aten::StridesType> stride_size(sizes.size());
431+
if (!sizes.empty()) {
432+
stride_size.back() = 1;
433+
for (int i = sizes.size() - 2; i >= 0; --i) {
434+
stride_size[i] = stride_size[i + 1] * sizes[i + 1];
435+
}
436+
}
430437
// Avoid using from_blob as it significantly increases shared library
431438
// size.
432439
executorch::aten::TensorImpl tensor_impl(

0 commit comments

Comments
 (0)