Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paddle/phi/kernels/gpu/margin_cross_entropy_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void MarginCrossEntropyGradKernel(const Context& dev_ctx,
logits_grad->ShareDataWith(softmax);
}

int blocks = NumBlocks(N * D);
int64_t blocks = NumBlocks(N * D);
int threads = kNumCUDAThreads;
const auto& label_type = label.dtype();

Expand Down
10 changes: 6 additions & 4 deletions paddle/phi/kernels/gpu/margin_cross_entropy_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ __global__ void ScaleLogitKernel(T* logits,
const float scale,
const int64_t N,
const int64_t D) {
CUDA_KERNEL_LOOP(i, N * D) { logits[i] *= static_cast<T>(scale); }
CUDA_KERNEL_LOOP_TYPE(i, N * D, int64_t) {
logits[i] *= static_cast<T>(scale);
}
}

template <typename T>
__global__ void LogitsMinusMaxKernel(T* logits,
const T* logits_max_per_row,
const int64_t N,
const int64_t D) {
CUDA_KERNEL_LOOP(i, N * D) {
CUDA_KERNEL_LOOP_TYPE(i, N * D, int64_t) {
auto row = i / D;
logits[i] -= logits_max_per_row[row];
}
Expand All @@ -86,7 +88,7 @@ __global__ void LogitsMinusLogSumKernel(T* logits,
const T* logits_sum_per_row,
const int64_t N,
const int64_t D) {
CUDA_KERNEL_LOOP(i, N * D) {
CUDA_KERNEL_LOOP_TYPE(i, N * D, int64_t) {
auto row = i / D;
logits[i] -= phi::kps::details::Log(logits_sum_per_row[row]);
}
Expand All @@ -102,7 +104,7 @@ __global__ void HardLabelSoftmaxWithCrossEntropyKernel(
const int64_t D,
const int* class_interval_ptr) {
int start_index = class_interval_ptr[rank];
CUDA_KERNEL_LOOP(i, N * D) {
CUDA_KERNEL_LOOP_TYPE(i, N * D, int64_t) {
auto row = i / D;
auto col = i % D;
if ((col + start_index) == labels[row]) {
Expand Down