+
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions src/tensor_ops/utilities/cuda_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,15 @@ __device__ void chunk_sum(
}
}

extern "C" __global__ void fill_with_f16(__half *buf, __half value, const size_t numel) {
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= numel) {
return;
}
buf[i] = value;
}

extern "C" __global__ void fill_with_f32(float *buf, float value, const size_t numel) {
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= numel) {
return;
}
buf[i] = value;
}

extern "C" __global__ void fill_with_f64(double *buf, double value, const size_t numel) {
unsigned int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i >= numel) {
return;
template<typename T>
__device__ void fill_with(T *buf, T value, const size_t numel) {
for (unsigned int i = blockIdx.x * blockDim.x + threadIdx.x; i < numel; i += blockDim.x * gridDim.x) {
buf[i] = value;
}
buf[i] = value;
}

extern "C" __global__ void fill_with_f16(__half *buf, __half value, const size_t numel) { fill_with(buf, value, numel); }
extern "C" __global__ void fill_with_f32(float *buf, float value, const size_t numel) { fill_with(buf, value, numel); }
extern "C" __global__ void fill_with_f64(double *buf, double value, const size_t numel) { fill_with(buf, value, numel); }

__device__ __forceinline__ bool isnang(float a) { return isnan(a); }
__device__ __forceinline__ bool isnang(double a) { return isnan(a); }
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载