Skip to content

Commit 6ce6ed7

Browse files
Fix vectorization with powf (#981)
1 parent 691064f commit 6ce6ed7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

crates/cubecl-wgpu/src/compiler/wgsl/extension.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,16 @@ pub fn call_powf(
121121
rhs: &Variable,
122122
out: &Variable,
123123
) -> core::fmt::Result {
124-
let (rhs, base_name) = if should_use_scalar_powf(rhs) {
124+
let (lhs, rhs, base_name) = if should_use_scalar_powf(rhs) {
125125
let rhs = rhs.fmt_cast_to(Item::Scalar(lhs.elem()));
126-
(rhs, POWF_SCALAR)
126+
let lhs = lhs.to_string();
127+
(lhs, rhs, POWF_SCALAR)
127128
} else {
128-
let rhs = rhs.fmt_cast_to(lhs.item());
129-
(rhs, POWF)
129+
// When vecotized, we make sure the function inputs shared the same vectorization factor as
130+
// the output.
131+
let rhs = rhs.fmt_cast_to(out.item());
132+
let lhs = lhs.fmt_cast_to(out.item());
133+
(lhs, rhs, POWF)
130134
};
131135
let function_name = construct_vectorized_name(base_name, out.item());
132136

0 commit comments

Comments
 (0)