Skip to content

Enhance tf2onnx conversion test validation in ROCm TensorFlow test notebook #1268

Open
@coderabbitai

Description

@coderabbitai

Problem Description

The current tf2onnx conversion test in jupyter/rocm/tensorflow/ubi9-python-3.12/test/test_notebook.ipynb provides insufficient validation of the ONNX model conversion process. The test only checks that the conversion result is not None, which doesn't validate the actual functionality or structure of the converted ONNX model.

Current Implementation

def test_tf2onnx_conversion(self):
    model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=(10,))])
    onnx_model = tf2onnx.convert.from_keras(model)
    
    self.assertTrue(onnx_model is not None)

Expected Enhancement

The test should include comprehensive validation of the ONNX model structure and properties:

def test_tf2onnx_conversion(self):
    model = tf.keras.Sequential([tf.keras.layers.Dense(1, input_shape=(10,))])
    onnx_model, _ = tf2onnx.convert.from_keras(model)
    
    self.assertTrue(onnx_model is not None)
    # Verify ONNX model has expected structure
    self.assertTrue(hasattr(onnx_model, 'graph'), "ONNX model should have a graph")
    self.assertTrue(len(onnx_model.graph.node) > 0, "ONNX model should have nodes")

Acceptance Criteria

  • Update the test_tf2onnx_conversion method to properly handle the tuple return value from tf2onnx.convert.from_keras()
  • Add validation that the ONNX model has a graph attribute
  • Add validation that the ONNX model graph contains nodes (not empty)
  • Consider adding additional validations such as:
    • Input/output tensor shape validation
    • Model op type verification
    • Basic inference test with sample data

Context

This enhancement improves test robustness by ensuring that the tf2onnx conversion actually produces a valid, structured ONNX model rather than just a non-null result. This is particularly important for ROCm environments where conversion compatibility may vary.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions