Commit 6430acb6 authored by Robert Kimball's avatar Robert Kimball

wip

parent 47a7e128
......@@ -91,10 +91,44 @@ std::shared_ptr<runtime::Executable> runtime::Backend::load(istream& input_strea
throw runtime_error("load opertion unimplemented.");
}
void runtime::Backend::post_write(const void* p, size_t size_in_bytes, std::promise<void>& promise)
runtime::Backend::AsyncEvent::AsyncEvent(Type type, void* p, size_t size_in_bytes)
: m_type{type}
, m_data{p}
, m_size_in_bytes{size_in_bytes}
, m_executable{nullptr}
, m_outputs{nullptr}
, m_inputs{nullptr}
{
}
void runtime::Backend::post_read(void* p, size_t size_in_bytes, std::promise<void>& promise)
runtime::Backend::AsyncEvent::AsyncEvent(const shared_ptr<Executable>& executable,
const vector<shared_ptr<runtime::Tensor>>& outputs,
const vector<shared_ptr<runtime::Tensor>>& inputs)
: m_type{Type::EXECUTE}
, m_data{nullptr}
, m_size_in_bytes{0}
, m_executable{executable}
, m_outputs{&outputs}
, m_inputs{&inputs}
{
}
void runtime::Backend::post_async_read_event(void* p,
size_t size_in_bytes,
std::promise<void>& promise)
{
}
void runtime::Backend::post_async_write_event(const void* p,
size_t size_in_bytes,
std::promise<void>& promise)
{
}
void runtime::Backend::post_async_execute_event(
const std::shared_ptr<Executable>& executable,
const std::vector<std::shared_ptr<runtime::Tensor>>& outputs,
const std::vector<std::shared_ptr<runtime::Tensor>>& inputs,
std::promise<void>& promise)
{
}
......@@ -143,25 +143,42 @@ public:
protected:
friend class ngraph::runtime::Tensor;
void post_write(const void* p, size_t size_in_bytes, std::promise<void>& promise);
void post_read(void* p, size_t size_in_bytes, std::promise<void>& promise);
class ReadWriteInfo
class AsyncEvent
{
public:
ReadWriteInfo(void* p, size_t size, bool is_read)
: m_data{p}
, m_size_in_bytes{size}
, m_is_read{is_read}
enum class Type
{
}
bool is_read() const { return m_is_read; }
bool is_write() const { return !is_read(); }
void* get_ptr() const { return m_data; }
READ,
WRITE,
EXECUTE
};
void* get_data() const { return m_data; }
bool get_size_in_bytes() const { return m_size_in_bytes; }
Type get_type() const { return m_type; }
std::shared_ptr<Executable> get_executable() const { return m_executable; }
const std::vector<std::shared_ptr<runtime::Tensor>>* get_outputs() const
{
return m_outputs;
}
const std::vector<std::shared_ptr<runtime::Tensor>>* get_inputs() const { return m_inputs; }
private:
AsyncEvent(Type, void* p, size_t size_in_bytes);
AsyncEvent(const std::shared_ptr<Executable>& m_executable,
const std::vector<std::shared_ptr<runtime::Tensor>>& m_outputs,
const std::vector<std::shared_ptr<runtime::Tensor>>& m_inputs);
const Type m_type;
void* m_data;
size_t m_size_in_bytes;
bool m_is_read;
const size_t m_size_in_bytes;
std::shared_ptr<Executable> m_executable;
const std::vector<std::shared_ptr<runtime::Tensor>>* m_outputs;
const std::vector<std::shared_ptr<runtime::Tensor>>* m_inputs;
};
void post_async_read_event(void* p, size_t size_in_bytes, std::promise<void>& promise);
void post_async_write_event(const void* p, size_t size_in_bytes, std::promise<void>& promise);
void post_async_execute_event(const std::shared_ptr<Executable>& executable,
const std::vector<std::shared_ptr<runtime::Tensor>>& outputs,
const std::vector<std::shared_ptr<runtime::Tensor>>& inputs,
std::promise<void>& promise);
};
......@@ -103,7 +103,7 @@ future<void> runtime::Tensor::begin_write(const void* p, size_t n)
if (m_backend)
{
auto f = m_promise.get_future();
m_backend->post_write(p, n, m_promise);
m_backend->post_async_write_event(p, n, m_promise);
return f;
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment