This repository has been archived by the owner on Nov 25, 2022. It is now read-only.
forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ETHOSN] Throw error message when inference fails (apache#13022)
* [ETHOSN] Throw error message when inference fails Previously the runtime would silently skip interence failures and return random values as the result. This can make spotting inference failures challenging. The runtime now throws a fatal error when inference did not complete successfully along with an error message that gives some details about the error that occurred. Change-Id: Iadb6da04ad1c906e3ec49959eb3da0978295aebf * Address comments * clarify test file brief * add test case for running status * add driver stack reference to WaitStatus class Change-Id: I792742892b761534904816135ae2ffcb3f028b2c
- Loading branch information
Showing
4 changed files
with
154 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* \file tests/cpp/runtime/contrib/ethosn/inference_test.cc | ||
* \brief Tests to check Arm(R) Ethos(TM)-N runtime components used during inference. | ||
*/ | ||
|
||
#ifdef ETHOSN_HW | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "../../../../../src/runtime/contrib/ethosn/ethosn_device.cc" | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
namespace ethosn { | ||
|
||
TEST(WaitForInference, InferenceScheduled) { | ||
const int inference_result = 0 /* Scheduled */; | ||
const int timeout = 0; | ||
|
||
dl::Inference inference = dl::Inference(inference_result); | ||
InferenceWaitStatus result = WaitForInference(&inference, timeout); | ||
|
||
ASSERT_EQ(result.GetErrorCode(), InferenceWaitErrorCode::kTimeout); | ||
ICHECK_EQ(result.GetErrorDescription(), "Timed out while waiting for the inference to complete."); | ||
} | ||
|
||
TEST(WaitForInference, InferenceRunning) { | ||
const int inference_result = 1 /* Running */; | ||
const int timeout = 0; | ||
|
||
dl::Inference inference = dl::Inference(inference_result); | ||
InferenceWaitStatus result = WaitForInference(&inference, timeout); | ||
|
||
ASSERT_EQ(result.GetErrorCode(), InferenceWaitErrorCode::kTimeout); | ||
std::cout << result.GetErrorDescription() << std::endl; | ||
ICHECK_EQ(result.GetErrorDescription(), "Timed out while waiting for the inference to complete."); | ||
} | ||
|
||
TEST(WaitForInference, InferenceError) { | ||
const int inference_result = 3 /* Error */; | ||
const int timeout = 0; | ||
|
||
dl::Inference inference = dl::Inference(inference_result); | ||
InferenceWaitStatus result = WaitForInference(&inference, timeout); | ||
|
||
ASSERT_EQ(result.GetErrorCode(), InferenceWaitErrorCode::kError); | ||
ICHECK_EQ(result.GetErrorDescription(), | ||
"Failed to read inference result status (No such file or directory)"); | ||
} | ||
|
||
} // namespace ethosn | ||
} // namespace runtime | ||
} // namespace tvm | ||
|
||
#endif |