aboutsummaryrefslogtreecommitdiff
path: root/driver_library
diff options
context:
space:
mode:
authorDavide Grohmann <davide.grohmann@arm.com>2022-04-25 12:52:38 +0200
committerDavide Grohmann <davide.grohmann@arm.com>2022-05-02 09:40:15 +0200
commit82d225899bd3d4fd07d70cac80f50c1b288dc4a3 (patch)
treed0edc8d0fa059bba99e00377feab1aad42385590 /driver_library
parent415de582dcf6f06dc71c9c48eeed0a01bfefc222 (diff)
downloadethos-u-linux-driver-stack-82d225899bd3d4fd07d70cac80f50c1b288dc4a3.tar.gz
Add support for rejected inference responses
Change-Id: I62e13df69c712ed4cf70766429b4cb13fc9c9dcb
Diffstat (limited to 'driver_library')
-rw-r--r--driver_library/include/ethosu.hpp11
-rw-r--r--driver_library/src/ethosu.cpp29
2 files changed, 37 insertions, 3 deletions
diff --git a/driver_library/include/ethosu.hpp b/driver_library/include/ethosu.hpp
index a12d668..61e2bc5 100644
--- a/driver_library/include/ethosu.hpp
+++ b/driver_library/include/ethosu.hpp
@@ -180,6 +180,15 @@ private:
std::vector<size_t> ofmDims;
};
+enum class InferenceStatus {
+ OK,
+ ERROR,
+ RUNNING,
+ REJECTED,
+};
+
+std::ostream &operator<<(std::ostream &out, const InferenceStatus &v);
+
class Inference {
public:
template <typename T>
@@ -220,7 +229,7 @@ public:
int wait(int64_t timeoutNanos = -1) const;
const std::vector<uint32_t> getPmuCounters() const;
uint64_t getCycleCounter() const;
- bool failed() const;
+ InferenceStatus status() const;
int getFd() const;
const std::shared_ptr<Network> getNetwork() const;
std::vector<std::shared_ptr<Buffer>> &getIfmBuffers();
diff --git a/driver_library/src/ethosu.cpp b/driver_library/src/ethosu.cpp
index 2b1da45..0da30c3 100644
--- a/driver_library/src/ethosu.cpp
+++ b/driver_library/src/ethosu.cpp
@@ -330,6 +330,20 @@ size_t Network::getOfmSize() const {
* Inference
****************************************************************************/
+ostream &operator<<(ostream &out, const InferenceStatus &status) {
+ switch (status) {
+ case InferenceStatus::OK:
+ return out << "ok";
+ case InferenceStatus::ERROR:
+ return out << "error";
+ case InferenceStatus::RUNNING:
+ return out << "running";
+ case InferenceStatus::REJECTED:
+ return out << "rejected";
+ }
+ throw Exception("Unknown inference status");
+}
+
Inference::~Inference() noexcept(false) {
eclose(fd);
}
@@ -395,12 +409,23 @@ int Inference::wait(int64_t timeoutNanos) const {
return eppoll(&pfd, 1, &tmo_p, NULL);
}
-bool Inference::failed() const {
+InferenceStatus Inference::status() const {
ethosu_uapi_result_status uapi;
eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi));
- return uapi.status != ETHOSU_UAPI_STATUS_OK;
+ switch (uapi.status) {
+ case ETHOSU_UAPI_STATUS_OK:
+ return InferenceStatus::OK;
+ case ETHOSU_UAPI_STATUS_ERROR:
+ return InferenceStatus::ERROR;
+ case ETHOSU_UAPI_STATUS_RUNNING:
+ return InferenceStatus::RUNNING;
+ case ETHOSU_UAPI_STATUS_REJECTED:
+ return InferenceStatus::REJECTED;
+ }
+
+ throw Exception("Unknown inference status");
}
const std::vector<uint32_t> Inference::getPmuCounters() const {