Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【PaddlePaddle Hackathon 2】9、为 Paddle 新增 logspace API #41261

Merged
merged 21 commits into from
Apr 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update logspace_kernel.cu
BrilliantYuKaimin committed Apr 2, 2022
commit efe557724a6352bfa6b1fc93e0578b7337fc8885
11 changes: 8 additions & 3 deletions paddle/phi/kernels/gpu/logspace_kernel.cu
Original file line number Diff line number Diff line change
@@ -29,16 +29,21 @@ __global__ void LogspaceKernelInner(

for (; index < size; index += blockDim.x * gridDim.x) {
if (index < size / 2) {
out[index] = static_cast<T>(pow(base, start + step * index));
out[index] = static_cast<T>(pow(
static_cast<double>(base),
static_cast<double>(start + step * index)));
} else {
out[index] = static_cast<T>(pow(base, stop - step * (size - index - 1)));
out[index] = static_cast<T>(pow(
static_cast<double>(base),
static_cast<double>(stop - step * (size - index - 1))));
}
}
}

template <typename T>
__global__ void LogspaceSpecialKernel(T start, T base, T* out) {
out[0] = static_cast<T>(pow(base, start));
out[0] = static_cast<T>(pow(
static_cast<double>(base), static_cast<double>(start)));
}

template <typename T, typename Context>