未验证 提交 14fd53d5 编写于 作者: Z zyfncg 提交者: GitHub

fix bug of slice_grad using use_mkldnn attr (#37584)

slice_grad op在选择kernel过程中出现错误,问题原因是在获取use_mkldnn属性时,map中未找到该键值,所以抛出out_of_range异常
本PR在map获取use_mkldnn属性数据前增加了是否存在该键值的判断逻辑,从而避免出现上述异常
上级 3a81805b
......@@ -1066,8 +1066,9 @@ bool OperatorWithKernel::SupportsMKLDNN(
bool OperatorWithKernel::CanMKLDNNBeUsed(const framework::ExecutionContext& ctx,
proto::VarType::Type data_type) const {
bool use_mkldnn_ctx =
ctx.Attr<bool>("use_mkldnn") && platform::is_cpu_place(ctx.GetPlace());
bool use_mkldnn_ctx = ctx.HasAttr("use_mkldnn") &&
ctx.Attr<bool>("use_mkldnn") &&
platform::is_cpu_place(ctx.GetPlace());
return use_mkldnn_ctx && this->SupportsMKLDNN(data_type);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册