Skip to content

Commit 154c85f

Browse files
committed
add error handling
1 parent 76b0de0 commit 154c85f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cpp_dl_benchmark/executorch_launcher/include/memory_manager.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,23 @@ class LowLevelInferenceAPI : public InferenceAPI {
7171

7272
void set_input(const std::vector<std::vector<executorch::runtime::EValue>>& tens, const int input_idx) override {
7373
Error set_input_error = method.get()->get().set_input(tens[0][input_idx], 0);
74+
if (set_input_error != Error::Ok) {
75+
throw std::runtime_error("Error when setting input tensor.");
76+
}
7477
}
7578

7679
void inference() override {
7780
Error execute_error = method.get()->get().execute();
81+
if (execute_error != Error::Ok) {
82+
throw std::runtime_error("Inference error.");
83+
}
7884
}
7985

8086
const Tensor dump_output(const std::vector<std::vector<executorch::runtime::EValue>>& tens) override {
8187
Error set_input_error = method.get()->get().set_input(tens[0][0], 0);
88+
if (set_input_error != Error::Ok) {
89+
throw std::runtime_error("Error when setting input tensor.");
90+
}
8291
method.get()->get().execute();
8392
const auto result = method.get()->get().get_output(0);
8493
return result.toTensor();

0 commit comments

Comments
 (0)