From 4a0269a5d446c71480fa5f5d1d8ea23ee7877251 Mon Sep 17 00:00:00 2001 From: Jianhui Dai Date: Wed, 15 Jan 2025 03:06:42 +0800 Subject: [PATCH] [webgpu] Simplify o2i_output implementation (#23351) ### Description This change simplifies the o2i_output implementation by reducing unnecessary intermediate variables, with no change in functionality. ### Motivation and Context As above. Signed-off-by: Jianhui Dai --- onnxruntime/core/providers/webgpu/shader_variable.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/onnxruntime/core/providers/webgpu/shader_variable.cc b/onnxruntime/core/providers/webgpu/shader_variable.cc index 15020b801c..5e5920f582 100644 --- a/onnxruntime/core/providers/webgpu/shader_variable.cc +++ b/onnxruntime/core/providers/webgpu/shader_variable.cc @@ -159,10 +159,8 @@ void ShaderIndicesHelper::Impl(std::ostream& ss) const { SS_APPEND(ss, " var current = offset;\n"); for (int i = 0; i < rank_ - 1; i++) { auto current_stride = GetElementAt(stride, i, rank_ - 1); - SS_APPEND(ss, " let dim", i, " = current / ", current_stride, ";\n"); - SS_APPEND(ss, " let rest", i, " = current % ", current_stride, ";\n"); - SS_APPEND(ss, " indices[", i, "] = dim", i, ";\n"); - SS_APPEND(ss, " current = rest", i, ";\n"); + SS_APPEND(ss, " indices[", i, "] = current / ", current_stride, ";\n"); + SS_APPEND(ss, " current = current % ", current_stride, ";\n"); } SS_APPEND(ss, " indices[", rank_ - 1, "] = current;\n"); SS_APPEND(ss, " return indices;\n");