fix indexing in matmul_forward_kernel1

This commit is contained in:
patricxu 2024-04-20 15:38:12 +08:00
parent 2d3a0fbe50
commit d48b0d2b2b

View file

@ -72,11 +72,9 @@ __global__ void matmul_forward_kernel1(float* out,
int bt = blockIdx.x * blockDim.x + threadIdx.x;
int oc = blockIdx.y * blockDim.y + threadIdx.y;
if (bt < BT && oc < OC) {
int b = bt / BT;
int t = bt % BT;
float val = (bias != NULL) ? bias[oc] : 0.0f;
const float* wrow = weight + oc*C;
const float* inp_bt = inp + b * BT * C + t * C;
const float* wrow = weight + oc * C;
const float* inp_bt = inp + bt * C;
for (int i = 0; i < C; i++) {
val += inp_bt[i] * wrow[i];
}