From 8b63ea8d94225c4acf96b1bb7773a3104a1d519a Mon Sep 17 00:00:00 2001 From: Jorge Pineda Date: Thu, 5 Sep 2024 15:44:59 -0700 Subject: [PATCH] [ET-VK] Fix negative dim in `normalize_to_dim_index` Our `cat` implementation currently fails for negative dim. Differential Revision: [D62270925](https://our.internmc.facebook.com/intern/diff/D62270925/) [ghstack-poisoned] --- backends/vulkan/runtime/graph/ops/impl/utils/DimUtils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backends/vulkan/runtime/graph/ops/impl/utils/DimUtils.h b/backends/vulkan/runtime/graph/ops/impl/utils/DimUtils.h index 45dfceb3f0d..4bd8e9b900b 100644 --- a/backends/vulkan/runtime/graph/ops/impl/utils/DimUtils.h +++ b/backends/vulkan/runtime/graph/ops/impl/utils/DimUtils.h @@ -32,7 +32,8 @@ constexpr DimIndex kChannel4D = DimIndex::DIM_3RD_LAST; constexpr DimIndex kBatch4D = DimIndex::DIM_4TH_LAST; inline DimIndex normalize_to_dim_index(const api::vTensor& v_in, int32_t dim) { - return static_cast(dim - v_in.dim()); + return dim < 0 ? static_cast(dim) + : static_cast(dim - v_in.dim()); } /*