return ANEURALNETWORKS_UNEXPECTED_NULL;
}
+ if (!event->waitFinish())
+ {
+ return ANEURALNETWORKS_BAD_STATE;
+ }
+
return ANEURALNETWORKS_NO_ERROR;
}
}
// TODO: Handle event
- *event = new (std::nothrow) ANeuralNetworksEvent{};
+ auto instance = execution->instance();
+ *event = new (std::nothrow) ANeuralNetworksEvent{instance};
if (*event == nullptr)
{
VERBOSE(NNAPI::Execution) << "startCompute: Fail to create event" << std::endl;
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- if (!execution->execute())
+ if (!execution->startExecute())
{
VERBOSE(NNAPI::Execution) << "startCompute: Fail to start execution" << std::endl;
return ANEURALNETWORKS_BAD_STATE;
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed 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.
+ */
+
+#include "ANeuralNetworksEvent.h"
+
+#include "exec/Execution.h"
+#include "util/logging.h"
+
+ANeuralNetworksEvent::ANeuralNetworksEvent(
+ const std::shared_ptr<neurun::exec::Execution> &execution)
+ : _execution{execution}
+{
+ // DO NOTHING
+}
+
+bool ANeuralNetworksEvent::waitFinish(void) noexcept
+{
+ try
+ {
+ _execution->waitFinish();
+ }
+ catch (const std::exception &e)
+ {
+ VERBOSE(EXCEPTION) << e.what() << std::endl;
+
+ return false;
+ }
+
+ return true;
+}
#ifndef __EVENT_H__
#define __EVENT_H__
+#include <NeuralNetworks.h>
+
+#include <memory>
+
+namespace neurun
+{
+namespace exec
+{
+class Execution;
+} // namespace exec
+} // namespace neurun
+
struct ANeuralNetworksEvent
{
+public:
+ ANeuralNetworksEvent(const std::shared_ptr<neurun::exec::Execution> &execution);
+
+public:
+ bool waitFinish(void) noexcept;
+
+private:
+ const std::shared_ptr<neurun::exec::Execution> _execution;
};
#endif
return true;
}
-bool ANeuralNetworksExecution::execute(void) noexcept
+bool ANeuralNetworksExecution::startExecute(void) noexcept
{
try
{
- _execution->execute();
+ _execution->startExecute();
}
catch (const std::exception &e)
{
return true;
}
+
+const std::shared_ptr<neurun::exec::Execution> ANeuralNetworksExecution::instance(void) noexcept
+{
+ return _execution;
+}
#include <NeuralNetworks.h>
+#include <memory>
+
#include "exec/Execution.h"
-#include <cpp14/memory.h>
struct ANeuralNetworksExecution
{
public:
ANeuralNetworksExecution(const std::shared_ptr<neurun::exec::IExecutor> &executor)
- : _execution{nnfw::cpp14::make_unique<neurun::exec::Execution>(executor)}
+ : _execution{std::make_shared<neurun::exec::Execution>(executor)}
{
// DO NOTHING
}
size_t length) noexcept;
bool setOutput(uint32_t index, const ANeuralNetworksOperandType *type, void *buffer,
size_t length) noexcept;
- bool execute(void) noexcept;
+ bool startExecute(void) noexcept;
const neurun::model::OperandIndex getInputOperandIndex(int32_t index) noexcept;
const neurun::model::OperandIndex getOutputOperandIndex(int32_t index) noexcept;
const neurun::model::OperandIndex index) noexcept;
bool haveUnspecifiedDims(const neurun::model::OperandIndex index) noexcept;
size_t getOperandSize(const neurun::model::OperandIndex index) noexcept;
+ const std::shared_ptr<neurun::exec::Execution> instance(void) noexcept;
private:
- std::unique_ptr<neurun::exec::Execution> _execution;
+ std::shared_ptr<neurun::exec::Execution> _execution;
};
#endif