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

Feature: Flops calculation #6

Open
innat opened this issue Sep 19, 2023 · 0 comments
Open

Feature: Flops calculation #6

innat opened this issue Sep 19, 2023 · 0 comments
Assignees

Comments

@innat
Copy link

innat commented Sep 19, 2023

Reopening from

Currently the adopted solutions (from community) using tf.

import tensorflow as tf
from tensorflow.python.profiler import model_analyzer, option_builder

model = tf.keras.applications.Xception(
    weights='imagenet',
    input_shape=(150, 150, 3),
    include_top=False
) 

input_signature = [
    tf.TensorSpec(
        shape=(1, *params.shape[1:]), 
        dtype=params.dtype, 
        name=params.name
    ) for params in model.inputs
]
forward_graph = tf.function(model, input_signature).get_concrete_function().graph
options = option_builder.ProfileOptionBuilder.float_operation()
graph_info = model_analyzer.profile(forward_graph, options=options)
flops = graph_info.total_float_ops // 2
flops # 1925897756 

And using official facebookresearch,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants