Release 18.08
[platform/upstream/armnn.git] / src / armnnOnnxParser / test / DepthConv.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
4 //
5
6 #include <boost/test/unit_test.hpp>
7 #include "armnnOnnxParser/IOnnxParser.hpp"
8 #include  "ParserPrototxtFixture.hpp"
9
10 BOOST_AUTO_TEST_SUITE(OnnxParser)
11
12 struct SimpleDepthConv2DFixture : public armnnUtils::ParserPrototxtFixture<armnnOnnxParser::IOnnxParser>
13 {
14     SimpleDepthConv2DFixture()
15     {
16         m_Prototext = R"(
17                    ir_version: 3
18                    producer_name:  "CNTK"
19                    producer_version:  "2.5.1"
20                    domain:  "ai.cntk"
21                    model_version: 1
22                    graph {
23                      name:  "CNTKGraph"
24                      input {
25                         name: "Input"
26                         type {
27                           tensor_type {
28                             elem_type: FLOAT
29                             shape {
30                               dim {
31                                 dim_value: 1
32                               }
33                               dim {
34                                 dim_value: 3
35                               }
36                               dim {
37                                 dim_value: 2
38                               }
39                               dim {
40                                 dim_value: 2
41                               }
42                             }
43                           }
44                         }
45                       }
46                       input {
47                         name: "Weight"
48                         type {
49                           tensor_type {
50                             elem_type: FLOAT
51                             shape {
52                               dim {
53                                 dim_value: 3
54                               }
55                               dim {
56                                 dim_value: 1
57                               }
58                               dim {
59                                 dim_value: 2
60                               }
61                               dim {
62                                 dim_value: 2
63                               }
64                             }
65                           }
66                         }
67                       }
68                       initializer {
69                           dims: 3
70                           dims: 1
71                           dims: 2
72                           dims: 2
73                           data_type: FLOAT
74                           float_data: 1
75                           float_data: 1
76                           float_data: 1
77                           float_data: 1
78                           float_data: 2
79                           float_data: 2
80                           float_data: 2
81                           float_data: 2
82                           float_data: 3
83                           float_data: 3
84                           float_data: 3
85                           float_data: 3
86                           name: "Weight"
87                         }
88                       node {
89                          input: "Input"
90                          input: "Weight"
91                          output: "Output"
92                          name: "Convolution"
93                          op_type: "Conv"
94                          attribute {
95                            name: "kernel_shape"
96                            ints: 2
97                            ints: 2
98                            type: INTS
99                          }
100                          attribute {
101                            name: "strides"
102                            ints: 1
103                            ints: 1
104                            type: INTS
105                          }
106                          attribute {
107                            name: "auto_pad"
108                            s: "VALID"
109                            type: STRING
110                          }
111                          attribute {
112                            name: "group"
113                            i: 3
114                            type: INT
115                          }
116                          attribute {
117                            name: "dilations"
118                            ints: 1
119                            ints: 1
120                            type: INTS
121                          }
122                          doc_string: ""
123                          domain: ""
124                        }
125                       output {
126                           name: "Output"
127                           type {
128                              tensor_type {
129                                elem_type: FLOAT
130                                shape {
131                                    dim {
132                                        dim_value: 1
133                                    }
134                                    dim {
135                                        dim_value: 3
136                                    }
137                                    dim {
138                                        dim_value: 1
139                                    }
140                                    dim {
141                                        dim_value: 1
142                                    }
143                                }
144                             }
145                         }
146                         }
147                     }
148                    opset_import {
149                       version: 7
150                     })";
151         Setup();
152     }
153 };
154
155
156 BOOST_FIXTURE_TEST_CASE(ValidDepthConvTest, SimpleDepthConv2DFixture)
157 {
158     RunTest<4>({{"Input", { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}}},
159                {{"Output", { 10, 52, 126 }}});
160 }
161
162 BOOST_AUTO_TEST_SUITE_END()