       }
     }
     if(!no_gamma) {
-      gamma_grad[b * nchannel + l] += local_gamma_grad[0];
+      gamma_grad[l] += local_gamma_grad[0];
     }
     if(!no_beta) {
-      beta_grad[b * nchannel + l] += local_beta_grad[0];
+      beta_grad[l] += local_beta_grad[0];
     }
   }
 }

  DType local_beta_grad[LOAD_UNROLL];

  int l = LOAD_UNROLL * tid;
  for(; l + LOAD_UNROLL - 1 < nchannel; l += LOAD_UNROLL * nthread) {
    // Initialize the shared memory
#pragma unroll

      if(!no_gamma) {
        DType ele_gamma = gamma[l];
        data_grad[bid * nchannel + l] +=
          ele_out_grad * ele_gamma * invstd_eps - sum_val0 - (ele_x - mean) * invstd_eps * sum_val1;
      } else {
        data_grad[bid * nchannel + l] +=
          ele_out_grad * invstd_eps - sum_val0 - (ele_x - mean) * invstd_eps * sum_val1;
      }
    }
  }
