From ee1a7d020c8d22b658405f81e89ceda1ea2a8227 Mon Sep 17 00:00:00 2001 From: yukavio <67678385+yukavio@users.noreply.github.com> Date: Mon, 14 Dec 2020 20:37:37 +0800 Subject: [PATCH] add some feature for paddle.flops (#29572) --- python/paddle/hapi/dynamic_flops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/paddle/hapi/dynamic_flops.py b/python/paddle/hapi/dynamic_flops.py index 382227ea832..9e2f78b559f 100644 --- a/python/paddle/hapi/dynamic_flops.py +++ b/python/paddle/hapi/dynamic_flops.py @@ -229,7 +229,7 @@ def dynamic_flops(model, inputs, custom_ops=None, print_detail=False): else: if m_type not in types_collection: print( - "Cannot find suitable count function for {}. Treat it as zero Macs.". + "Cannot find suitable count function for {}. Treat it as zero FLOPs.". format(m_type)) if flops_fn is not None: @@ -256,9 +256,9 @@ def dynamic_flops(model, inputs, custom_ops=None, print_detail=False): continue total_ops += m.total_ops total_params += m.total_params - - total_ops = int(total_ops) - total_params = int(total_params) + if hasattr(m, 'total_ops') and hasattr(m, 'total_params'): + total_ops = int(total_ops) + total_params = int(total_params) if training: model.train() -- GitLab