未验证 提交 a2bbd06a 编写于 作者: L liym27 提交者: GitHub

[Cherry-Pick 2.0] Check the rank of input in kernel of set_value op (#30147) (#30301)

cherry-pick #30147,For op set_value, check input's rank < 7
上级 04cc659c
......@@ -83,7 +83,7 @@ template <typename DeviceContext, typename T>
class SetValueKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& ctx) const {
const int rank = ctx.Output<framework::LoDTensor>("Out")->dims().size();
const int rank = ctx.Input<framework::LoDTensor>("Input")->dims().size();
// TODO(liym27): A more elegent code to do this. C++ has to make template
// integer as constant, but we had better have alternative writing in the
......@@ -107,6 +107,9 @@ class SetValueKernel : public framework::OpKernel<T> {
case 6:
SetValueCompute<6>(ctx);
break;
default:
PADDLE_THROW(platform::errors::InvalidArgument(
"The rank of input should be less than 7, but received %d.", rank));
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册