Skip to content

Commit

Permalink
Fixes after rebase onto new oneDNN version.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnick committed Jan 29, 2021
1 parent ed7bdb6 commit 007851c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
9 changes: 5 additions & 4 deletions inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,13 @@ void MKLDNNGraph::ExecuteConstantNodesOnly() {
}

static bool isReorderAvailable(const TensorDesc& parentDesc, const TensorDesc& childDesc, const mkldnn::engine& eng) {
memory::primitive_desc dstPrimitiveDesc(MKLDNNMemoryDesc(childDesc), eng);
memory::primitive_desc srcPrimitiveDesc(MKLDNNMemoryDesc(parentDesc), eng);
memory::desc dstMemDesc = MKLDNNMemoryDesc(childDesc);
memory::desc srcMemDesc = MKLDNNMemoryDesc(parentDesc);
mkldnn::primitive_attr attr;

mkldnn_primitive_desc_t result = nullptr;
auto status = mkldnn_reorder_primitive_desc_create_v2(&result, srcPrimitiveDesc.get(), dstPrimitiveDesc.get(), attr.get());
dnnl_primitive_desc_t result = nullptr;
auto status = dnnl_reorder_primitive_desc_create(&result, &srcMemDesc.data, eng.get(), &dstMemDesc.data, eng.get(),
attr.get());
if (result) {
mkldnn_primitive_desc_destroy(result);
}
Expand Down
9 changes: 5 additions & 4 deletions inference-engine/src/mkldnn_plugin/mkldnn_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void MKLDNNMemory::reorderData(const MKLDNNMemory &input, const MKLDNNMemory &ou
} else {
std::unique_ptr<mkldnn::reorder> pReorder;
std::shared_ptr<memory> srcMemoryPtr;
std::vector<uint8_t> tmpBuff;

try {
pReorder = std::unique_ptr<mkldnn::reorder>(new mkldnn::reorder(input.GetPrimitive(), output.GetPrimitive()));
Expand All @@ -110,14 +111,14 @@ void MKLDNNMemory::reorderData(const MKLDNNMemory &input, const MKLDNNMemory &ou
if (mkldnn_unimplemented == err.status && output.GetDataType() != input.GetDataType()) {
//we probably could not make the reorder because there is no one supporting this precision conversion
//lets try to convert data first using cpu_convert
std::vector<uint8_t> tmpBuff(input.GetSize());
auto data = static_cast<const uint8_t *>(input.GetPtr());
tmpBuff.resize(input.GetSize());

cpu_convert(data, tmpBuff.data(), MKLDNNExtensionUtils::DataTypeToIEPrecision(input.GetDataType()),
MKLDNNExtensionUtils::DataTypeToIEPrecision(output.GetDataType()), input.GetElementsCount());

MKLDNNMemory tmpMem(output.eng);
tmpMem.Create(input.GetDims(), input.GetDataType(), input.GetFormat(), data);
tmpMem.Create(input.GetDims(), output.GetDataType(), input.GetDesc().getFormat(), tmpBuff.data());

pReorder = std::unique_ptr<mkldnn::reorder>(new mkldnn::reorder(tmpMem.GetPrimitive(), output.GetPrimitive()));
srcMemoryPtr = tmpMem.prim;
Expand All @@ -126,8 +127,8 @@ void MKLDNNMemory::reorderData(const MKLDNNMemory &input, const MKLDNNMemory &ou
}
}
if (pReorder) {
mkldnn::stream loc_stream(this->eng, stream::flags::default_order);
pReorder->execute(loc_stream, *srcMemoryPtr, *this->prim);
mkldnn::stream loc_stream(output.eng, stream::flags::default_order);
pReorder->execute(loc_stream, *srcMemoryPtr, *output.prim);
} else {
THROW_IE_EXCEPTION << "Could not make mkldnn reorder.";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,14 @@ void MKLDNNConvertNode::createPrimitive() {
THROW_ERROR << "Preferable primitive descriptor is not set.";
}

static inline uint8_t* getDataPtr(const MKLDNNMemory& memoryPtr) {
return reinterpret_cast<uint8_t*>(memoryPtr.GetData()) + memoryPtr.GetDescriptor().data.layout_desc.blocking.offset_padding *
MKLDNNExtensionUtils::sizeOfDataType(mkldnn::memory::data_type(memoryPtr.GetDescriptor().data.data_type));
}

void MKLDNNConvertNode::execute(mkldnn::stream strm) {
auto& parentMem = getParentEdgeAt(0)->getMemory();
auto& childMem = getChildEdgeAt(0)->getMemory();
if (parentMem.GetElementsCount() != childMem.GetElementsCount())
THROW_ERROR << "Input and output buffers have different elements count";

void* srcPtr = getDataPtr(parentMem);
void* dstPtr = getDataPtr(childMem);
void* srcPtr = parentMem.GetPtr();
void* dstPtr = childMem.GetPtr();
cpu_convert(srcPtr, dstPtr, getParentEdgeAt(0)->getDesc().getPrecision(), getChildEdgeAt(0)->getDesc().getPrecision(), parentMem.GetElementsCount());
}

Expand Down

0 comments on commit 007851c

Please sign in to comment.