How to list all used operations in Tensorflow SavedModel?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Listing operations inside a TensorFlow SavedModel is useful for deployment checks, converter compatibility, and regression debugging. Many runtimes support only a subset of TensorFlow ops, so knowing exact op usage early prevents late-stage failures. You can inspect ops from command line tools or programmatically with TensorFlow APIs.
Quick Inspection with saved_model_cli
For a fast structural view, use the built-in CLI.
This prints signatures, input-output tensors, and graph details. It is a good first diagnostic step in CI and release reviews.
Programmatic Operation Listing in Python
For automation, load the model and inspect operations from each concrete signature graph.
This gives signature-specific operation usage instead of one flattened list.
Build a Unique Operation Inventory
For compatibility auditing, you usually need distinct operation types across all signatures.
Persisting this list makes model-to-model diffs easy.
Compare Operation Sets Across Versions
To catch unexpected graph changes after retraining or exporter updates, compare op inventories between two model versions.
This is especially useful as a pre-deploy guard.
Inspect Signature Contracts Alongside Ops
Operation inventory alone is not enough. A model can keep the same ops while changing serving interface.
Include contract checks to avoid interface drift between model and service layers.
GraphDef-Level Analysis for Advanced Tooling
For deeper analysis tools, inspect GraphDef node definitions directly.
Node-level metadata can support custom linting, op whitelists, or converter preprocessing.
CI Integration Pattern
A practical CI gate:
- export op inventory from candidate model.
- compare against approved op allowlist.
- fail build on unsupported operations.
- attach diff artifact for review.
This catches incompatibilities before runtime rollout.
Version and Runtime Considerations
TensorFlow internal graph rewrites can vary by version, so op inventories may differ even when model semantics are equivalent. Compare models under consistent exporter/runtime versions whenever possible.
When comparing across versions, treat differences as signals for review, not automatic failures, unless strict runtime constraints require exact matching.
Common Pitfalls
- Inspecting only one signature and assuming all call paths are covered.
- Confusing tensor names with operation types during compatibility checks.
- Comparing inventories from different TensorFlow versions without context.
- Skipping signature interface checks while focusing only on ops.
- Running manual checks once and missing later regression drift.
Summary
- Use
saved_model_clifor quick structural inspection. - Use Python APIs for scriptable, repeatable op extraction.
- Build unique op inventories for compatibility and compliance checks.
- Diff operation sets between model versions before deployment.
- Validate signatures and ops together for safer serving integration. Keep TensorFlow exporter versions consistent when running automated comparison gates.
Related reading
- How to load a graph with tensorflow.so and c_api.h in c language?
- How to load a keras model saved as .pb
- How to load a keras model saved as .pb
- How to load a model from an HDF5 file in Keras?
- How to load a tflite model in script?
- How to load an image and show the image using keras?
- How to load a trained model''s weights, which were saved with tf.keras.models.save_model?
- How to load a trained TF1 protobuf model into TF2?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.