Skip to content

Commit

Permalink
OP primitive cache: use memory as signature for MKLDNN storage type
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Huang authored and zheng-da committed Jan 11, 2018
1 parent 982796b commit 7fa4d0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/operator/nn/mkldnn/mkldnn_act.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static MKLDNNActForward &GetActForward(const ActivationParam& param,
MKLDNNActSignature key(param);
key.AddSign(ctx.is_train);
key.AddSign(param.act_type);
key.AddSign(in_mem);
key.AddSign(in_data);

auto it = fwds.find(key);
if (it == fwds.end()) {
Expand Down
10 changes: 7 additions & 3 deletions src/operator/nn/mkldnn/mkldnn_base-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ class MKLDNNOpSignature {
}

void AddSign(const NDArray &arr) {
hash = hash * 2 + arr.dtype();
eles.push_back(arr.dtype());
AddSign(arr.shape());
if (arr.IsMKLDNN()) {
AddSign(*(arr.GetMKLDNNData()));
} else {
hash = hash * 2 + arr.dtype();
eles.push_back(arr.dtype());
AddSign(arr.shape());
}
}

void AddSign(const TShape &shape) {
Expand Down

0 comments on commit 7fa4d0a

Please sign in to comment.