Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions qtorch/quant/quant_cuda/bit_helper.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#define FLOAT_TO_BITS(x) (*reinterpret_cast<unsigned int*>(x))
#define BITS_TO_FLOAT(x) (*reinterpret_cast<float*>(x))

#ifdef __HIP__
#ifndef __forceinline__
#define __forceinline__ inline __attribute__((always_inline))
#endif
#endif

__device__ __forceinline__ unsigned int extract_exponent(float *a) {
unsigned int temp = *(reinterpret_cast<unsigned int*>(a));
temp = (temp << 1 >> 24); // single preciision, 1 sign bit, 23 mantissa bits
Expand Down
5 changes: 5 additions & 0 deletions qtorch/quant/quant_cuda/fixed_point_kernel.cu
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include "quant_kernel.h"
#include "sim_helper.cu"

#ifdef __HIP__
#ifndef __forceinline__
#define __forceinline__ inline __attribute__((always_inline))
#endif
#endif

template <typename T>
__device__ __forceinline__ T clamp_helper(T a, T min, T max) {
Expand Down
1 change: 1 addition & 0 deletions qtorch/quant/quant_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
os.path.join(current_path, "quant_cuda/fixed_point_kernel.cu"),
os.path.join(current_path, "quant_cuda/quant.cu"),
],
extra_include_paths=[os.path.join(current_path, "quant_cuda")],
)
else:
quant_cuda = quant_cpu
Expand Down