Skip to content

Commit 830c91c

Browse files
daijhguschmue
authored andcommitted
[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 <jianhui.j.dai@intel.com>
1 parent f9e6609 commit 830c91c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

onnxruntime/core/providers/webgpu/shader_variable.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@ void ShaderIndicesHelper::Impl(std::ostream& ss) const {
159159
SS_APPEND(ss, " var current = offset;\n");
160160
for (int i = 0; i < rank_ - 1; i++) {
161161
auto current_stride = GetElementAt(stride, i, rank_ - 1);
162-
SS_APPEND(ss, " let dim", i, " = current / ", current_stride, ";\n");
163-
SS_APPEND(ss, " let rest", i, " = current % ", current_stride, ";\n");
164-
SS_APPEND(ss, " indices[", i, "] = dim", i, ";\n");
165-
SS_APPEND(ss, " current = rest", i, ";\n");
162+
SS_APPEND(ss, " indices[", i, "] = current / ", current_stride, ";\n");
163+
SS_APPEND(ss, " current = current % ", current_stride, ";\n");
166164
}
167165
SS_APPEND(ss, " indices[", rank_ - 1, "] = current;\n");
168166
SS_APPEND(ss, " return indices;\n");

0 commit comments

Comments
 (0)