| 133 | }; |
| 134 | |
| 135 | class handles { |
| 136 | public: |
| 137 | libxsmm_dnn_layer* find(const libxsmm_dnn_conv_desc_wrap& w) { |
| 138 | std::unordered_map<libxsmm_dnn_conv_desc_wrap, libxsmm_dnn_layer*, |
| 139 | HashFunction>::iterator i = libxsmm_handles.find(w); |
| 140 | if (i == libxsmm_handles.end()) { |
| 141 | libxsmm_dnn_err_t status; |
| 142 | libxsmm_dnn_layer* libxsmm_handle = |
| 143 | libxsmm_dnn_create_conv_layer(w.d, &status); |
| 144 | chk_libxsmm_err(status, "Create handle"); |
| 145 | libxsmm_handles.insert(std::make_pair(w, libxsmm_handle)); |
| 146 | return libxsmm_handle; |
| 147 | } else { |
| 148 | return i->second; |
| 149 | } |
| 150 | } |
| 151 | ~handles() { |
| 152 | std::unordered_map<libxsmm_dnn_conv_desc_wrap, libxsmm_dnn_layer*, |
| 153 | HashFunction>::iterator i; |
| 154 | for (i = libxsmm_handles.begin(); i != libxsmm_handles.end(); i++) |
| 155 | chk_libxsmm_err(libxsmm_dnn_destroy_conv_layer(i->second), |
| 156 | "Destroy handle"); |
| 157 | } |
| 158 | |
| 159 | private: |
| 160 | std::unordered_map<libxsmm_dnn_conv_desc_wrap, libxsmm_dnn_layer*, |
| 161 | HashFunction> |
| 162 | libxsmm_handles; |
| 163 | }; |
| 164 | |
| 165 | static handles libxsmm_handles; |
| 166 |
no outgoing calls
no test coverage detected