|
|
|
@ -14,6 +14,7 @@ limitations under the License. */
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <mkldnn.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "paddle/fluid/framework/operator.h"
|
|
|
|
|
#include "paddle/fluid/platform/place.h"
|
|
|
|
@ -182,10 +183,11 @@ class MKLDNNHandler {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<mkldnn::memory> AcquireMemory(
|
|
|
|
|
mkldnn::memory::primitive_desc& mpd,
|
|
|
|
|
mkldnn::memory::primitive_desc& user_mpd,
|
|
|
|
|
mkldnn::memory::primitive_desc& mpd, // NOLINT
|
|
|
|
|
mkldnn::memory::primitive_desc& user_mpd, // NOLINT
|
|
|
|
|
const std::shared_ptr<mkldnn::memory> user_memory_p,
|
|
|
|
|
const std::string& suffix, std::vector<mkldnn::primitive>& pipeline) {
|
|
|
|
|
const std::string& suffix,
|
|
|
|
|
std::vector<mkldnn::primitive>& pipeline) { // NOLINT
|
|
|
|
|
// create reorder primitive if the input format is not the preferred one
|
|
|
|
|
auto local_key = key_ + suffix;
|
|
|
|
|
auto key_reorder_p = key_ + suffix + "reorder_p";
|
|
|
|
@ -218,7 +220,7 @@ class MKLDNNHandler {
|
|
|
|
|
return target_memory_p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::string GetHash(mkldnn::memory::dims& operand_dims,
|
|
|
|
|
static std::string GetHash(mkldnn::memory::dims& operand_dims, // NOLINT
|
|
|
|
|
const std::string& suffix) {
|
|
|
|
|
auto dims2str = [](const mkldnn::memory::dims& operand_dims) {
|
|
|
|
|
std::string dstr = "";
|
|
|
|
@ -227,6 +229,7 @@ class MKLDNNHandler {
|
|
|
|
|
}
|
|
|
|
|
return dstr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return dims2str(operand_dims) + suffix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|