Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Tensorflow Serving Saved Model Bundle Factory Test

From Leeroopedia
Revision as of 13:54, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Tensorflow_Serving_Saved_Model_Bundle_Factory_Test.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Testing, Model Loading
Last Updated 2026-02-13 00:00 GMT

Overview

Test suite validating the SavedModelBundleFactory which creates SavedModelBundle instances from model paths.

Description

This test file validates the SavedModelBundleFactory class, which is responsible for creating SavedModelBundle instances from exported model directories. The test is parameterized over multiple dimensions: CreationType (with/without metadata), ModelType (TF model vs TFLite model), and prefer_tflite_model flag. The fixture extends BundleFactoryTest which provides common test infrastructure for bundle creation and session validation.

Key areas tested include:

  • Basic bundle creation and session execution
  • MetaGraphDef field removal (unused fields optimization)
  • Batching configuration
  • Per-model batching parameters
  • Resource requirement estimation
  • RunOptions support and error handling
  • SavedModelConfig graph options propagation
  • Both TF and TFLite model types with metadata variants

Usage

Run these tests to validate changes to SavedModelBundle creation, metadata handling, batching configuration, or TFLite model support in the factory.

Code Reference

Source Location

  • Repository: Tensorflow_Serving
  • File: tensorflow_serving/servables/tensorflow/saved_model_bundle_factory_test.cc
  • Lines: 1-345

Test Fixture

struct SavedModelBundleFactoryTestParam {
  CreationType creation_type;
  ModelType model_type;
  bool prefer_tflite_model;
};

class SavedModelBundleFactoryTest
    : public test_util::BundleFactoryTest,
      public ::testing::WithParamInterface<SavedModelBundleFactoryTestParam> {
 public:
  SavedModelBundleFactoryTest()
      : test_util::BundleFactoryTest(
            GetParam().model_type == ModelType::kTfModel
                ? test_util::GetTestSavedModelPath()
                : test_util::GetTestTfLiteModelPath()) {}
 protected:
  absl::Status CreateSession(const SessionBundleConfig& config,
                             std::unique_ptr<Session>* session) const override;
  SessionBundleConfig GetSessionBundleConfig() const override;
};

Build Target

bazel test //tensorflow_serving/servables/tensorflow:saved_model_bundle_factory_test

Test Coverage

Key Test Cases

Test Name Category Description
Basic Integration Tests basic bundle creation and session execution
RemoveUnusedFieldsFromMetaGraphDefault Configuration Tests default behavior for unused MetaGraphDef field removal
RemoveUnusedFieldsFromMetaGraphEnabled Configuration Tests explicit enable of MetaGraphDef field removal
Batching Configuration Tests batching configuration support
PerModelBatchingParams Configuration Tests per-model batching parameter configuration
EstimateResourceRequirementWithGoodExport Resource Tests resource requirement estimation from model export
RunOptions Integration Tests RunOptions support in session execution
RunOptionsError Error Handling Tests error handling for RunOptions
SetGraphOptionsFromSavedModelConfig Configuration Tests graph options from SavedModelConfig

Usage Examples

Test Pattern

TEST_P(SavedModelBundleFactoryTest, Basic) { TestBasic(); }

// Parameterized across creation types, model types, and TFLite preference
INSTANTIATE_TEST_SUITE_P(
    CreationType, SavedModelBundleFactoryTest,
    ::testing::Values(
        SavedModelBundleFactoryTestParam{
            CreationType::kWithoutMetadata, ModelType::kTfModel, true},
        SavedModelBundleFactoryTestParam{
            CreationType::kWithMetadata, ModelType::kTfLiteModel, true},
        // ... more combinations
    ));

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment