onnx-export-rs 0.1.1

Export canonical Rust machine-learning models to ONNX
Documentation
//! Minimal public ONNX protobuf bindings needed by the exporters.
//!
//! Field numbers follow ONNX's stable `onnx.proto3` wire format. Keeping the
//! subset here avoids exposing a build-time `protoc` dependency.

/// An ONNX model.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ModelProto {
    /// IR version.
    #[prost(int64, tag = "1")]
    pub ir_version: i64,
    /// Producer name.
    #[prost(string, tag = "2")]
    pub producer_name: String,
    /// Producer version.
    #[prost(string, tag = "3")]
    pub producer_version: String,
    /// Model domain.
    #[prost(string, tag = "4")]
    pub domain: String,
    /// User model version.
    #[prost(int64, tag = "5")]
    pub model_version: i64,
    /// Documentation.
    #[prost(string, tag = "6")]
    pub doc_string: String,
    /// Computation graph.
    #[prost(message, optional, tag = "7")]
    pub graph: Option<GraphProto>,
    /// Imported operator sets.
    #[prost(message, repeated, tag = "8")]
    pub opset_import: Vec<OperatorSetIdProto>,
}

/// An operator-set import.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OperatorSetIdProto {
    /// Empty for the core ONNX domain.
    #[prost(string, tag = "1")]
    pub domain: String,
    /// Operator-set version.
    #[prost(int64, tag = "2")]
    pub version: i64,
}

/// An ONNX graph.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GraphProto {
    /// Nodes in topological order.
    #[prost(message, repeated, tag = "1")]
    pub node: Vec<NodeProto>,
    /// Graph name.
    #[prost(string, tag = "2")]
    pub name: String,
    /// Constant tensors.
    #[prost(message, repeated, tag = "5")]
    pub initializer: Vec<TensorProto>,
    /// Documentation.
    #[prost(string, tag = "10")]
    pub doc_string: String,
    /// Graph inputs.
    #[prost(message, repeated, tag = "11")]
    pub input: Vec<ValueInfoProto>,
    /// Graph outputs.
    #[prost(message, repeated, tag = "12")]
    pub output: Vec<ValueInfoProto>,
    /// Intermediate value descriptions.
    #[prost(message, repeated, tag = "13")]
    pub value_info: Vec<ValueInfoProto>,
}

/// An ONNX graph node.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NodeProto {
    /// Input value names.
    #[prost(string, repeated, tag = "1")]
    pub input: Vec<String>,
    /// Output value names.
    #[prost(string, repeated, tag = "2")]
    pub output: Vec<String>,
    /// Optional node name.
    #[prost(string, tag = "3")]
    pub name: String,
    /// Operator type.
    #[prost(string, tag = "4")]
    pub op_type: String,
    /// Operator attributes.
    #[prost(message, repeated, tag = "5")]
    pub attribute: Vec<AttributeProto>,
    /// Documentation.
    #[prost(string, tag = "6")]
    pub doc_string: String,
    /// Operator domain.
    #[prost(string, tag = "7")]
    pub domain: String,
}

/// An ONNX node attribute.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AttributeProto {
    /// Attribute name.
    #[prost(string, tag = "1")]
    pub name: String,
    /// Float value.
    #[prost(float, tag = "2")]
    pub f: f32,
    /// Integer value.
    #[prost(int64, tag = "3")]
    pub i: i64,
    /// Byte-string value.
    #[prost(bytes = "vec", tag = "4")]
    pub s: Vec<u8>,
    /// Tensor value.
    #[prost(message, optional, tag = "5")]
    pub t: Option<TensorProto>,
    /// Repeated float values.
    #[prost(float, repeated, tag = "7")]
    pub floats: Vec<f32>,
    /// Repeated integer values.
    #[prost(int64, repeated, tag = "8")]
    pub ints: Vec<i64>,
    /// Repeated byte-string values.
    #[prost(bytes = "vec", repeated, tag = "9")]
    pub strings: Vec<Vec<u8>>,
    /// Attribute type enum.
    #[prost(int32, tag = "20")]
    pub r#type: i32,
}

/// An ONNX dense tensor.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TensorProto {
    /// Tensor dimensions.
    #[prost(int64, repeated, tag = "1")]
    pub dims: Vec<i64>,
    /// ONNX tensor element type enum.
    #[prost(int32, tag = "2")]
    pub data_type: i32,
    /// Inline float values.
    #[prost(float, repeated, tag = "4")]
    pub float_data: Vec<f32>,
    /// Inline 32-bit integer values.
    #[prost(int32, repeated, tag = "5")]
    pub int32_data: Vec<i32>,
    /// Inline 64-bit integer values.
    #[prost(int64, repeated, tag = "7")]
    pub int64_data: Vec<i64>,
    /// Tensor name.
    #[prost(string, tag = "8")]
    pub name: String,
    /// Packed little-endian tensor bytes.
    #[prost(bytes = "vec", tag = "9")]
    pub raw_data: Vec<u8>,
}

/// Type and shape information for a graph value.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ValueInfoProto {
    /// Value name.
    #[prost(string, tag = "1")]
    pub name: String,
    /// Value type.
    #[prost(message, optional, tag = "2")]
    pub r#type: Option<TypeProto>,
    /// Documentation.
    #[prost(string, tag = "3")]
    pub doc_string: String,
}

/// An ONNX value type.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TypeProto {
    /// Tensor type, when this value is a tensor.
    #[prost(message, optional, tag = "1")]
    pub tensor_type: Option<type_proto::Tensor>,
}

/// Nested type definitions.
pub mod type_proto {
    /// Tensor element type and shape.
    #[derive(Clone, PartialEq, ::prost::Message)]
    pub struct Tensor {
        /// ONNX tensor element type enum.
        #[prost(int32, tag = "1")]
        pub elem_type: i32,
        /// Tensor shape.
        #[prost(message, optional, tag = "2")]
        pub shape: Option<super::TensorShapeProto>,
    }
}

/// Tensor shape.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TensorShapeProto {
    /// Ordered dimensions.
    #[prost(message, repeated, tag = "1")]
    pub dim: Vec<tensor_shape_proto::Dimension>,
}

/// Nested tensor-shape definitions.
pub mod tensor_shape_proto {
    /// A concrete or symbolic tensor dimension.
    #[derive(Clone, PartialEq, ::prost::Message)]
    pub struct Dimension {
        /// Dimension value.
        #[prost(oneof = "dimension::Value", tags = "1, 2")]
        pub value: Option<dimension::Value>,
    }

    /// Nested dimension definitions.
    pub mod dimension {
        /// Concrete or symbolic dimension value.
        #[derive(Clone, PartialEq, ::prost::Oneof)]
        pub enum Value {
            /// Concrete size.
            #[prost(int64, tag = "1")]
            DimValue(i64),
            /// Symbolic size.
            #[prost(string, tag = "2")]
            DimParam(String),
        }
    }
}