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

Update get_flops() to accept kwargs and pass them to tf.compat.v1.profiler.ProfileOptionBuilder.float_operation() #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion keras_flops/flops_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import keras_flops.flops_registory


def get_flops(model: Union[Model, Sequential], batch_size: Optional[int] = None) -> int:
def get_flops(model: Union[Model, Sequential], batch_size: Optional[int] = None, **kwargs) -> int:
"""
Calculate FLOPS for tf.keras.Model or tf.keras.Sequential .
Ignore operations used in only training mode such as Initialization.
Expand All @@ -34,6 +34,7 @@ def get_flops(model: Union[Model, Sequential], batch_size: Optional[int] = None)
# Calculate FLOPS with tf.profiler
run_meta = tf.compat.v1.RunMetadata()
opts = tf.compat.v1.profiler.ProfileOptionBuilder.float_operation()
opts.update(kwargs)
flops = tf.compat.v1.profiler.profile(
graph=frozen_func.graph, run_meta=run_meta, cmd="scope", options=opts
)
Expand Down