liveBook · Manning

Floating-point operation count

As explained in Graph Neural Networks in Action

A floating-point operation is a numerical operation on floating-point values, with FLOPs denoting the count required by a computation.

Floating-point operation count, commonly written as FLOPs, measures the numerical operations required by a computation. It serves as a scalability metric alongside memory usage, time per epoch, and convergence speed. section 7.2.3

Profiling a model

Use THOP to profile a PyTorch model with a representative input, then inspect the reported operation count alongside other resource measurements. section 7.2.3

from thop import profile   #1

input = torch.randn(1, 3, 224, 224) 
macs, params = profile(model, inputs=(input, )) 
print(f"FLOPs: {macs}")

A compact THOP example creates an input tensor, profiles the model, and prints the returned operation count. section 7.2.3

How Graph Neural Networks in Action covers it

How deep it goes
Defines the metric and demonstrates model profiling, but does not derive operation counts internally.
Examples
Uses a PyTorch model, a random input tensor, and THOP's profile function.
What you can do after
Apply via THOP's profile function to estimate a model's reported operation count.
How it connects
Connects FLOPs with memory usage, time per epoch, convergence speed, and model profiling.

Also explained in

Compare how 2 books explain floating-point operation count →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Neural Networks in Action. The section links point to the parts of the book it draws on.