10std::ostream &operator<<(std::ostream &os,
const onnx::GraphProto &graph) {
11 return os <<
"GraphProto(" << graph.name() <<
")";
14std::ostream &operator<<(std::ostream &os,
const onnx::TensorProto &tensor) {
16 if (tensor.has_data_type()) os <<
"data_type: " << tensor.data_type() <<
", ";
17 if (tensor.has_doc_string()) os <<
"doc_string: " << tensor.doc_string() <<
", ";
18 if (tensor.has_name()) os <<
"name: " << tensor.name() <<
", ";
19 if (tensor.has_segment()) os <<
"segment: " << tensor.segment() <<
", ";
20 return os <<
"dims: " << tensor.dims() <<
")";
23std::ostream &operator<<(std::ostream &os,
const google::protobuf::RepeatedField<int64_t> &int64s) {
25 std::copy(int64s.begin(), std::prev(int64s.end()), std::ostream_iterator<int64_t>(os,
", "));
26 return os << *(int64s.rbegin()) <<
"]";
29std::ostream &operator<<(std::ostream &os,
const onnx::TensorProto_Segment &tensor_segment) {
30 os <<
"TensorProto_Segment(";
31 if (tensor_segment.has_begin()) os <<
"begin: " << tensor_segment.begin() <<
", ";
32 if (tensor_segment.has_end()) os <<
"end: " << tensor_segment.end() <<
", ";
36std::ostream &operator<<(std::ostream &os,
const onnx::SparseTensorProto &tensor) {
37 os <<
"SparseTensorProto(";
38 if (tensor.has_indices()) os <<
"indices: " << tensor.indices() <<
", ";
39 if (tensor.has_values()) os <<
"values: " << tensor.values() <<
", ";
40 std::cout <<
"dims: " << tensor.dims();
44std::ostream &operator<<(std::ostream &os,
const onnx::AttributeProto &attribute) {
45 os <<
"AttributeProto(";
46 if (attribute.has_name()) os <<
"name: " << attribute.name() <<
", ";
47 if (attribute.has_type()) os <<
"type: " << attribute.type() <<
", ";
48 if (attribute.has_doc_string()) os <<
"doc_string: " << attribute.doc_string() <<
", ";
49 if (attribute.has_f()) os <<
"f: " << attribute.f() <<
", ";
50 if (attribute.has_i()) os <<
"i: " << attribute.i() <<
", ";
51 if (attribute.has_s()) os <<
"s: " << attribute.s() <<
", ";
52 if (attribute.has_t()) os <<
"t: " << attribute.t() <<
", ";
53 if (attribute.has_g()) os <<
"g: " << attribute.g() <<
", ";
54 if (attribute.has_sparse_tensor()) os <<
"sparse_tensor: " << attribute.sparse_tensor() <<
", ";
55 if (attribute.floats_size() > 0) {
57 std::copy(attribute.floats().begin(), std::prev(attribute.floats().end()), std::ostream_iterator<float>(os,
", "));
58 os << attribute.floats().rbegin()[0] <<
"], ";
60 if (attribute.ints_size() > 0) {
62 std::copy(attribute.ints().begin(), std::prev(attribute.ints().end()), std::ostream_iterator<int64_t>(os,
", "));
63 os << attribute.ints().rbegin()[0] <<
"], ";
65 if (attribute.strings_size() > 0) {
67 std::copy(attribute.strings().begin(), std::prev(attribute.strings().end()),
68 std::ostream_iterator<std::string>(os,
", "));
69 os << attribute.strings().rbegin()[0] <<
"], ";
71 if (attribute.tensors_size() > 0) {
73 for (
const auto &tensor : attribute.tensors()) os << tensor <<
", ";
85std::ostream &operator<<(std::ostream &os,
const onnx::NodeProto &node) {
87 if (node.has_name()) os <<
"name: " << node.name() <<
", ";
88 if (node.has_op_type()) os <<
"op_type: " << node.op_type() <<
", ";
89 if (node.has_domain()) os <<
"domain: " << node.domain() <<
", ";
90 if (node.has_doc_string()) os <<
"doc_string: " << node.doc_string() <<
", ";
91 if (node.input_size() > 0) {
93 std::copy(node.input().begin(), std::prev(node.input().end()), std::ostream_iterator<std::string>(os,
", "));
94 os << node.input().rbegin()[0] <<
"], ";
96 if (node.output_size() > 0) {
98 std::copy(node.output().begin(), std::prev(node.output().end()), std::ostream_iterator<std::string>(os,
", "));
99 os << node.output().rbegin()[0] <<
"], ";
101 if (node.attribute_size() > 0) {
102 os <<
"attributes: [";
103 for (
const auto &attr : node.attribute()) os << attr <<
", ";
109std::ostream &operator<<(std::ostream &os,
const onnx::ValueInfoProto &value_info) {
110 os <<
"ValueInfoProto(";
111 if (value_info.has_name()) os <<
"name: " << value_info.name() <<
", ";
112 if (value_info.has_type()) os <<
"type: " << value_info.type() <<
", ";
113 if (value_info.has_doc_string()) os <<
"doc_string: " << value_info.doc_string() <<
", ";
117std::ostream &operator<<(std::ostream &os,
const onnx::TypeProto &type) {
119 if (type.has_tensor_type()) os <<
"tensor_type: " << type.tensor_type() <<
", ";
120 if (type.has_sequence_type()) os <<
"sequence_type: " << type.sequence_type() <<
", ";
121 if (type.has_map_type()) os <<
"map_type: " << type.map_type() <<
", ";
122 if (type.has_opaque_type()) os <<
"opaque_type: " << type.opaque_type() <<
", ";
126std::ostream &operator<<(std::ostream &os,
const onnx::TypeProto_Sequence &type_sequence) {
127 os <<
"TypeProto_Sequence(";
128 if (type_sequence.has_elem_type()) os <<
"elem_type: " << type_sequence.elem_type() <<
", ";
132std::ostream &operator<<(std::ostream &os,
const onnx::TypeProto_Map &type_map) {
133 os <<
"TypeProto_Map(";
134 if (type_map.has_key_type()) os <<
"key_type: " << type_map.key_type() <<
", ";
135 if (type_map.has_value_type()) os <<
"value_type: " << type_map.value_type() <<
", ";
139std::ostream &operator<<(std::ostream &os,
const onnx::TypeProto_Tensor &type_tensor) {
140 os <<
"TypeProto_Tensor(";
141 if (type_tensor.has_elem_type()) os <<
"elem_type: " << type_tensor.elem_type() <<
", ";
142 if (type_tensor.has_shape()) os <<
"shape: " << type_tensor.shape() <<
", ";
146std::ostream &operator<<(std::ostream &os,
const onnx::TypeProto_Opaque &type_opaque) {
147 os <<
"TypeProto_Opaque(";
148 if (type_opaque.has_domain()) os <<
"domain: " << type_opaque.domain() <<
", ";
149 if (type_opaque.has_name()) os <<
"name: " << type_opaque.name() <<
", ";
153std::ostream &operator<<(std::ostream &os,
const onnx::TensorShapeProto &tensor_shape) {
154 os <<
"TensorShapeProto(";
155 for (
const auto &dim : tensor_shape.dim()) os <<
"dim: " << dim <<
", ";
159std::ostream &operator<<(std::ostream &os,
const onnx::TensorShapeProto_Dimension &tensor_shape_dim) {
160 os <<
"TensorShapeProto_Dimension(";
161 if (tensor_shape_dim.has_denotation()) os <<
"denotation: " << tensor_shape_dim.denotation() <<
", ";
162 if (tensor_shape_dim.has_dim_value()) os <<
"dim_value: " << tensor_shape_dim.dim_value() <<
", ";
163 if (tensor_shape_dim.has_dim_param()) os <<
"dim_param: " << tensor_shape_dim.dim_param() <<
", ";
167std::ostream &operator<<(std::ostream &os,
168 const google::protobuf::RepeatedPtrField<onnx::ValueInfoProto> &value_infos) {
169 os <<
"ValueInfoProto[";
170 for (
const auto &value_info : value_infos) os << value_info <<
", ";
173std::ostream &operator<<(std::ostream &os,
const google::protobuf::RepeatedPtrField<onnx::TensorProto> &tensors) {
174 os <<
"TensorProto[";
175 for (
const auto &tensor : tensors) os << tensor <<
", ";
Global namespace for the dlinear library.