Fix a bug that constant folding doesn't check the returned value of OpKernel::Compute (#1243)

This commit is contained in:
Changming Sun 2019-06-18 07:45:09 -07:00 committed by GitHub
parent 723e30b361
commit f22d1df04f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -40,10 +40,9 @@ class OpKernel {
return op_kernel_info_.GetKernelDef();
}
virtual Status Compute(OpKernelContext* context) const = 0;
virtual Status Compute(OpKernelContext* context) const ORT_MUST_USE_RESULT = 0;
virtual Status ComputeAsync(OpKernelContext*,
DoneCallback) const {
virtual Status ComputeAsync(OpKernelContext*, DoneCallback) const ORT_MUST_USE_RESULT {
ORT_NOT_IMPLEMENTED(__FUNCTION__, " is not implemented");
}

View file

@ -49,7 +49,7 @@ Status ConstantFolding::ApplyImpl(Graph& graph, bool& modified, int graph_level)
auto* kernel = info.GetKernel(node->Index());
OpKernelContext op_kernel_context(&frame, kernel, ::onnxruntime::logging::LoggingManager::DefaultLogger());
kernel->Compute(&op_kernel_context);
ORT_RETURN_IF_ERROR(kernel->Compute(&op_kernel_context));
std::vector<OrtValue> fetches;
frame.GetOutputs(fetches);

View file

@ -76,7 +76,8 @@ TEST(OptimizerTest, Basic) {
OpKernelContext op_kernel_context(&frame, kernel, logger);
kernel->Compute(&op_kernel_context);
auto st = kernel->Compute(&op_kernel_context);
ASSERT_TRUE(st.IsOK()) << st.ErrorMessage();
std::vector<OrtValue> fetches;
frame.GetOutputs(fetches);