Skip to content

Commit

Permalink
Merge pull request #11 from jinhuang415/refactor_pr1
Browse files Browse the repository at this point in the history
OP primitive cache: use memory as signature for MKLDNN storage type
  • Loading branch information
zheng-da authored Jan 10, 2018
2 parents e814b3e + b4cdd13 commit 1cba97f
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 @@ -313,9 +313,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 1cba97f

Please sign in to comment.