MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CreateBlockedMemDescHelper

Function CreateBlockedMemDescHelper

tensorflow/core/util/mkl_util.h:1202–1229  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1200/// @return: Status indicating whether the blocked memory descriptor
1201/// was successfully created.
1202inline 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
1231inline void CreateAndExecuteReorder(const ReorderPd& reorder_desc,
1232 const memory& src_mem,

Callers 2

GetTfLayoutMethod · 0.85
CreateBlockedMemDescMethod · 0.85

Calls 3

StatusClass · 0.50
StrCatFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected