Skip to content

Commit bfbd79b

Browse files
Daniel Holanda NoronhaDaniel Holanda Noronha
Daniel Holanda Noronha
authored and
Daniel Holanda Noronha
committed
Ready for PR - Fixing float
1 parent 1b8ca0b commit bfbd79b

File tree

2 files changed

+2
-16
lines changed

2 files changed

+2
-16
lines changed

qtorch/quant/quant_cuda/float_kernel.cu

-12
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ __global__ void float_kernel_stochastic(float* __restrict__ a,
1010
int exp_bits) {
1111
int index = blockIdx.x * blockDim.x + threadIdx.x;
1212
if (index < size) {
13-
//unsigned int old_num = FLOAT_TO_BITS(&a[index]);
14-
//unsigned int rand_prob = (unsigned int) r[index];
15-
//unsigned int quantize = round_bitwise_stochastic(old_num, rand_prob, man_bits);
16-
//quantize = clip_exponent(exp_bits, man_bits, old_num, quantize);
17-
//float quantize_float = BITS_TO_FLOAT(&quantize);
18-
//o[index] = quantize_float;
1913
unsigned int rand_prob = (unsigned int) r[index];
2014
unsigned int target,quantize_bits;
2115
target = FLOAT_TO_BITS(&a[index]);
@@ -50,12 +44,6 @@ __global__ void float_kernel_nearest(float* __restrict__ a,
5044
int exp_bits) {
5145
int index = blockIdx.x * blockDim.x + threadIdx.x;
5246
if (index < size) {
53-
54-
//unsigned int old_num = FLOAT_TO_BITS(&a[index]);
55-
//unsigned int quantize = round_bitwise_nearest(old_num, man_bits);
56-
//quantize = clip_exponent(exp_bits, man_bits, old_num, quantize);
57-
//float quantize_float = BITS_TO_FLOAT(&quantize);
58-
//o[index] = quantize_float;
5947
unsigned int target,quantize_bits;
6048
target = FLOAT_TO_BITS(&a[index]);
6149
float quantized;

test/test_clamp.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class TestStochastic(unittest.TestCase):
1515

1616
def test_fixed(self):
1717
"""test fixed point clamping"""
18-
#for d in ["cpu", "cuda"]:
19-
for d in ["cpu"]:
18+
for d in ["cpu", "cuda"]:
2019
for r in ["stochastic", "nearest"]:
2120
wl = 5
2221
fl = 4
@@ -37,8 +36,7 @@ def test_float(self):
3736
formats = [(2,2),(2,3),(3,2)]
3837

3938
for exp, man in formats:
40-
#for d in ["cpu", "cuda"]:
41-
for d in ["cpu"]:
39+
for d in ["cpu", "cuda"]:
4240
for r in ["stochastic", "nearest"]:
4341
a_max = 2 ** (2 ** (exp - 1)) * (1 - 2 ** (-man - 1))
4442
a_min = 2 ** (-(2 ** (exp - 1)) + 1)

0 commit comments

Comments
 (0)