Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] analyze_model.py #3404

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tools/model/analyze_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import os
import sys

import paddle
import numpy as np
import paddle
from paddle.hapi.dynamic_flops import (count_io_info, count_parameters,
register_hooks)
from paddle.hapi.static_flops import Table

from paddleseg.cvlibs import Config
from paddleseg.cvlibs import Config, SegBuilder
from paddleseg.utils import get_sys_env, logger, op_flops_funs
from paddle.hapi.dynamic_flops import (count_parameters, register_hooks,
count_io_info)
from paddle.hapi.static_flops import Table


def parse_args():
Expand Down Expand Up @@ -140,10 +140,11 @@ def analyze(args):
paddle.set_device('cpu')

cfg = Config(args.config)
builder = SegBuilder(cfg)

custom_ops = {paddle.nn.SyncBatchNorm: op_flops_funs.count_syncbn}
inputs = paddle.randn(args.input_shape)
_dynamic_flops(cfg.model, inputs, custom_ops=custom_ops, print_detail=True)
_dynamic_flops(builder.model, inputs, custom_ops=custom_ops, print_detail=True)


if __name__ == '__main__':
Expand Down