diff options
author | Cedric Nugteren <web@cedricnugteren.nl> | 2019-01-23 19:52:01 +0100 |
---|---|---|
committer | Cedric Nugteren <web@cedricnugteren.nl> | 2019-01-23 19:52:01 +0100 |
commit | e0541c41a17bd500ab3f03bbb9a934d9cc3b0a75 (patch) | |
tree | eff8b433e24ebfa23dd0a2c4207381059373b81c /src/pyclblast/samples/haxpy.py | |
parent | 347f0df32f0ddcc673e1e62f299090ac60b240a4 (diff) |
Added fp32 to fp16 conversion function in Python to make haxpy example work
Diffstat (limited to 'src/pyclblast/samples/haxpy.py')
-rw-r--r-- | src/pyclblast/samples/haxpy.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/pyclblast/samples/haxpy.py b/src/pyclblast/samples/haxpy.py index d6c1fef0..3db87a34 100644 --- a/src/pyclblast/samples/haxpy.py +++ b/src/pyclblast/samples/haxpy.py @@ -13,7 +13,8 @@ import pyclblast # Settings for this sample dtype = 'float16' -alpha = np.array(1.0).astype(dtype=dtype).item() +alpha = 1.5 +alpha_fp16 = pyclblast.float32_to_float16(alpha) n = 4 print("# Setting up OpenCL") @@ -31,7 +32,7 @@ clx.set(x) cly.set(y) print("# Example level-1 operation: AXPY") -pyclblast.axpy(queue, n, clx, cly, alpha=alpha) +pyclblast.axpy(queue, n, clx, cly, alpha=alpha_fp16) queue.finish() print("# Result for vector y: %s" % cly.get()) print("# Expected result: %s" % (alpha * x + y)) |