fixed softmarginloss

This commit is contained in:
hli28146 2025-11-12 14:06:06 +08:00
parent 6649703ece
commit 6a74bdaa2e
4 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -21,6 +21,7 @@ def run_benchmark():
torch_model.eval()
cuda_model.eval()
print("-------------------- 精度对齐验证 --------------------")
with torch.no_grad():
# 预热GPU

View File

@ -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,

View File

@ -18,6 +18,7 @@ class Model(nn.Module):
return self.loss_fn(input_tensor, target_tensor)
def get_inputs():
"""
生成用于测试的输入张量
"""