From 5d57d67cb3f49fe9c6ff673044ed6caf4c55ec3a Mon Sep 17 00:00:00 2001 From: dzambare Date: Wed, 3 Jun 2020 09:58:55 +0530 Subject: [PATCH] Checking for zero dimension is moved to bli_gemm_xx call. This will ensure early return in case full gemm processing is not needed. Based on dimension which is found to be zero following actions will be taken: If 'c' has zero dimension, no further processing is requried If alpha is zero or if 'a' or 'b' has zero diemension, we perform scalm operation instead of gemm. (c = alpha*a + beta*b) Change-Id: Icc031944fc4e80138adf991974547f2d57ab570b AMD-Internal: [CPUPL-904] --- frame/3/bli_l3_oapi.c | 13 +++++++++++++ frame/3/gemm/bli_gemm_front.c | 10 +--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/frame/3/bli_l3_oapi.c b/frame/3/bli_l3_oapi.c index 29eca1bf1..d09053fe7 100644 --- a/frame/3/bli_l3_oapi.c +++ b/frame/3/bli_l3_oapi.c @@ -57,6 +57,19 @@ void PASTEMAC(opname,EX_SUF) \ bli_init_once(); \ \ BLIS_OAPI_EX_DECLS \ +\ + /* If C has a zero dimension, return early. */ \ + if ( bli_obj_has_zero_dim( c ) ) return; \ +\ + /* if alpha or A or B has a zero dimension, \ + scale C by beta and return early. */ \ + if ( bli_obj_equals( alpha, &BLIS_ZERO ) || \ + bli_obj_has_zero_dim( a ) || \ + bli_obj_has_zero_dim( b ) ) \ + {\ + bli_scalm( beta, c ); \ + return;\ + }\ \ /* If the rntm is non-NULL, it may indicate that we should forgo sup handling altogether. */ \ diff --git a/frame/3/gemm/bli_gemm_front.c b/frame/3/gemm/bli_gemm_front.c index f274d51e5..6ac1755f4 100644 --- a/frame/3/gemm/bli_gemm_front.c +++ b/frame/3/gemm/bli_gemm_front.c @@ -56,15 +56,7 @@ void bli_gemm_front // Check parameters. if ( bli_error_checking_is_enabled() ) bli_gemm_check( alpha, a, b, beta, c, cntx ); - - // If alpha is zero, scale by beta and return. - if ( bli_obj_equals( alpha, &BLIS_ZERO ) ) - { - bli_scalm( beta, c ); - return; - } - - + #ifdef BLIS_ENABLE_SMALL_MATRIX // Only handle small problems separately for homogeneous datatypes. if ( bli_obj_dt( a ) == bli_obj_dt( b ) &&