diff options
author | Meng Mengmeng <mengmeng.meng@intel.com> | 2015-07-29 03:51:08 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2015-08-10 12:23:43 +0800 |
commit | fc693bc2e1fa9a48d126a612544b14af63211562 (patch) | |
tree | 0fd3a08551350d89b2644b226054eb43a1a7f8ec /utests/utest_math_gen.py | |
parent | 2d2d74a055eebf26a88607704a9b811885131c60 (diff) | |
download | beignet-fc693bc2e1fa9a48d126a612544b14af63211562.tar.gz |
fix a powr function issue in cpu compiler math
In OpenCL spec, gentype powr(gentype x, gentype y). In the meantime,
added edge tests for powr.
Signed-off-by: Mengmeng meng <mengmeng.meng@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'utests/utest_math_gen.py')
-rwxr-xr-x | utests/utest_math_gen.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/utests/utest_math_gen.py b/utests/utest_math_gen.py index 83edcc3e..424af416 100755 --- a/utests/utest_math_gen.py +++ b/utests/utest_math_gen.py @@ -467,14 +467,30 @@ static float pown(float x, int y){ pownUtests = func('pown','pown',[pown_input_type1,pown_input_type2],pown_output_type,[pown_input_values1,pown_input_values2],'16 * FLT_ULP', pown_cpu_func) ##### gentype powr(gentype x, gentype y) - powr_input_values1 = [80, -80, 3.14, -3.14, 0.5, 1, -1, 0.0,6,1500.24,-1500.24] - powr_input_values2 = [5,6,7,8,10,11,12,13,14,0,12] + powr_input_values1 = [80, -80, 3.14, 1, 1.257, +0.0, -0.0, +0.0, -0.0, +0.0, -0.0, +1, +1, -80, +0.0, -0.0, +0.0, -0.0, 'INFINITY','INFINITY', +1, +1, +0.0, 2.5,' NAN', 'NAN', 'NAN'] + powr_input_values2 = [5.5, 6,7, +0.0, -0.0, -1, -15.67, '-INFINITY', '-INFINITY', 1, -2.7, 10.5, 3.1415, 3.5, -0.0, -0.0, +0.0, +0.0, +0.0, -0.0, 'INFINITY', '-INFINITY', 'NAN', 'NAN', -1.5, +0.0, 1.5] powr_input_type1 = ['float','float2','float4','float8','float16'] powr_input_type2 = ['float','float2','float4','float8','float16'] powr_output_type = ['float','float2','float4','float8','float16'] powr_cpu_func=''' -static float powr(float x, int y){ - if (x<0) +static float powr(float x, float y){ + if (((x > 0) && (x != +INFINITY)) && (y == 0.0f)) + return 1; + else if ((x == 0.0f) && ((y < 0 ) || (y == -INFINITY))) + return +INFINITY; + else if ((x == 0.0f) && (y > 0)) + return +0; + else if ((x == 0.0f) && (y == 0.0f)) + return NAN; + else if ((x == +1) && ((y == +INFINITY) || (y == -INFINITY))) + return NAN; + else if ((x == +1) && ((y != +INFINITY) && (y != -INFINITY))) + return 1; + else if ((x == +INFINITY) && (y == 0.0f)) + return NAN; + else if (isnan(x) || (x < 0)) + return NAN; + else if ((x >= 0) && (isnan(y))) return NAN; else return powf(x,y); |