Skip to content

Commit 14fd53d

Browse files
authored
fix bug of slice_grad using use_mkldnn attr (#37584)
slice_grad op在选择kernel过程中出现错误,问题原因是在获取use_mkldnn属性时,map中未找到该键值,所以抛出out_of_range异常 本PR在map获取use_mkldnn属性数据前增加了是否存在该键值的判断逻辑,从而避免出现上述异常
1 parent 3a81805 commit 14fd53d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

paddle/fluid/framework/operator.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,9 @@ bool OperatorWithKernel::SupportsMKLDNN(
10661066

10671067
bool OperatorWithKernel::CanMKLDNNBeUsed(const framework::ExecutionContext& ctx,
10681068
proto::VarType::Type data_type) const {
1069-
bool use_mkldnn_ctx =
1070-
ctx.Attr<bool>("use_mkldnn") && platform::is_cpu_place(ctx.GetPlace());
1069+
bool use_mkldnn_ctx = ctx.HasAttr("use_mkldnn") &&
1070+
ctx.Attr<bool>("use_mkldnn") &&
1071+
platform::is_cpu_place(ctx.GetPlace());
10711072
return use_mkldnn_ctx && this->SupportsMKLDNN(data_type);
10721073
}
10731074

0 commit comments

Comments
 (0)