Helper function to create memory descriptor in Blocked format @input: Tensor dimensions @input: strides corresponding to dimensions. One can use utility function such as CalculateTFStrides to compute strides for given dimensions. @output: dnnl_memory_desc_t object corresponding to blocked memory format for given dimensions and strides. @return: Status indicating whether the blocked memory descrip
| 1200 | /// @return: Status indicating whether the blocked memory descriptor |
| 1201 | /// was successfully created. |
| 1202 | inline Status CreateBlockedMemDescHelper(const memory::dims& dim, |
| 1203 | const memory::dims& strides, |
| 1204 | memory::data_type dtype, |
| 1205 | dnnl_memory_desc_t* blocked_md) { |
| 1206 | DCHECK_EQ(dim.size(), strides.size()); |
| 1207 | const int kNumDims = dim.size(); |
| 1208 | dnnl_dim_t* input_dims = new dnnl_dim_t[kNumDims]; |
| 1209 | dnnl_dim_t* input_strides = new dnnl_dim_t[kNumDims]; |
| 1210 | for (int i = 0; i < kNumDims; ++i) { |
| 1211 | input_dims[i] = dim[i]; |
| 1212 | input_strides[i] = strides[i]; |
| 1213 | } |
| 1214 | try { |
| 1215 | dnnl_memory_desc_init_by_strides(blocked_md, kNumDims, input_dims, |
| 1216 | memory::convert_to_c(dtype), |
| 1217 | input_strides); |
| 1218 | delete[] input_dims; |
| 1219 | delete[] input_strides; |
| 1220 | } catch (dnnl::error& e) { |
| 1221 | delete[] input_dims; |
| 1222 | delete[] input_strides; |
| 1223 | return Status(error::Code::INTERNAL, |
| 1224 | tensorflow::strings::StrCat( |
| 1225 | "Failed to create blocked memory descriptor.", |
| 1226 | "Status: ", e.status, ", message: ", e.message)); |
| 1227 | } |
| 1228 | return Status::OK(); |
| 1229 | } |
| 1230 | |
| 1231 | inline void CreateAndExecuteReorder(const ReorderPd& reorder_desc, |
| 1232 | const memory& src_mem, |
no test coverage detected