Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7fcfaa7

Browse files
committed
Bring back the optimization of integer.pow({2.0, 3.0})
They were accidentally removed in#26020[ghstack-poisoned]
1 parent755b7e4 commit7fcfaa7

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎aten/src/ATen/native/cpu/PowKernel.cpp‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,19 @@ void pow_tensor_scalar_kernel(TensorIterator& iter, Scalar exp_scalar) {
130130
// tensors to float exponent e.g. tensor([4]).pow(0.5) will be tensor([2])
131131
constauto exp = exp_scalar.to<double>();
132132
AT_DISPATCH_INTEGRAL_TYPES(iter.dtype(),"pow", [&]() {
133-
if (exp ==0.5) {
133+
if (exp ==2) {
134+
cpu_kernel(iter,
135+
[](scalar_t base) ->scalar_t {
136+
return base * base;
137+
}
138+
);
139+
}elseif (exp ==3) {
140+
cpu_kernel(iter,
141+
[](scalar_t base) ->scalar_t {
142+
return base * base * base;
143+
}
144+
);
145+
}elseif (exp ==0.5) {
134146
cpu_kernel(iter,
135147
[](scalar_t base) ->scalar_t {
136148
returnstd::sqrt(static_cast<longdouble>(base));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp