forked from ccf-ai-infra/GPUCodeForces
fixed softmarginloss
This commit is contained in:
parent
6649703ece
commit
6a74bdaa2e
|
|
@ -27,6 +27,7 @@ The goal is to create a single, highly-efficient CUDA kernel pass that addresses
|
|||
This strategy transforms a multi-stage, memory-bound operation into a single-pass, compute-efficient, and numerically stable kernel, yielding substantial performance improvements.
|
||||
|
||||
You are given the following architecture:
|
||||
|
||||
import torch
|
||||
import torch.nn as nn
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ def run_benchmark():
|
|||
torch_model.eval()
|
||||
cuda_model.eval()
|
||||
|
||||
|
||||
print("-------------------- 精度对齐验证 --------------------")
|
||||
with torch.no_grad():
|
||||
# 预热GPU
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ __global__ void soft_margin_loss_reduce_kernel_stage1(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
torch::Tensor soft_margin_loss_cuda_forward(
|
||||
const torch::Tensor& input,
|
||||
const torch::Tensor& target,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class Model(nn.Module):
|
|||
return self.loss_fn(input_tensor, target_tensor)
|
||||
|
||||
def get_inputs():
|
||||
|
||||
"""
|
||||
生成用于测试的输入张量。
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue