validate

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrShapeInference indicates a failure during shape propagation,
	// used to wrap shape-related validation errors.
	ErrShapeInference = errors.New("validate: shape inference failed")
)

Sentinel errors returned by the validate package.

Functions

This section is empty.

Types

type Option

type Option func(*config)

Option configures validation behavior. It follows the same functional-options pattern used by engine.Option.

func WithGPUOps

func WithGPUOps(ops []string) Option

WithGPUOps overrides the default GPU-supported op list for GPU coverage calculation.

func WithInputShapes

func WithInputShapes(shapes map[string][]int) Option

WithInputShapes overrides the declared input shapes from the model. This is needed when model inputs have dynamic or symbolic dimensions.

type ShapeError

type ShapeError struct {
	NodeName   string
	OpType     string
	InputIndex int
	Expected   string
	Actual     string
}

ShapeError records a shape mismatch detected during shape propagation.

type UnsupportedOp

type UnsupportedOp struct {
	OpType    string
	NodeNames []string
}

UnsupportedOp groups all nodes that reference an unregistered operator type.

type ValidationReport

type ValidationReport struct {
	ModelPath       string
	TotalNodes      int
	OpCounts        map[string]int
	UnsupportedOps  []UnsupportedOp
	ShapeErrors     []ShapeError
	PeakMemoryBytes int64
	GPUCoverage     float64
	Valid           bool
}

ValidationReport contains the results of a pre-execution model analysis. Valid is true only when both UnsupportedOps and ShapeErrors are empty.

func Validate

func Validate(modelPath string, opts ...Option) (*ValidationReport, error)

Validate loads an ONNX model from modelPath, builds the graph, and runs all four validation passes (operator check, shape propagation, memory estimation, GPU coverage). It returns a complete ValidationReport or an error if loading or graph construction fails.

func ValidateGraph

func ValidateGraph(g *graph.Graph, opts ...Option) *ValidationReport

ValidateGraph runs all four validation passes on an already-built graph and assembles a ValidationReport. This entry point is used by the engine integration (WithValidation option) where the graph is already available.

func (*ValidationReport) Summary

func (r *ValidationReport) Summary() string

Summary returns a human-readable multi-line diagnostic string including node count, per-op breakdown, unsupported ops, shape errors, memory estimate, and GPU coverage percentage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL