44 #ifndef EXATN_RUNTIME_TENSOR_RUNTIME_HPP_
45 #define EXATN_RUNTIME_TENSOR_RUNTIME_HPP_
47 #include "tensor_graph_executor.hpp"
48 #include "tensor_graph.hpp"
49 #include "tensor_operation.hpp"
50 #include "tensor_method.hpp"
68 TensorRuntime(
const std::string & graph_executor_name =
"eager-dag-executor",
69 const std::string & node_executor_name =
"talsh-node-executor");
80 void openScope(
const std::string & scope_name);
98 VertexIdType
submit(std::shared_ptr<TensorOperation> op);
113 std::future<std::shared_ptr<talsh::Tensor>>
getLocalTensor(std::shared_ptr<Tensor> tensor,
114 const std::vector<std::pair<DimOffset,DimExtent>> & slice_spec);
120 std::promise<std::shared_ptr<talsh::Tensor>> slice_promise_;
121 std::vector<std::pair<DimOffset,DimExtent>> slice_specs_;
122 std::shared_ptr<Tensor> tensor_;
124 TensorDataReq(std::promise<std::shared_ptr<talsh::Tensor>> && slice_promise,
125 const std::vector<std::pair<DimOffset,DimExtent>> & slice_specs,
126 std::shared_ptr<Tensor> tensor):
127 slice_promise_(std::move(slice_promise)), slice_specs_(slice_specs), tensor_(tensor){}
129 TensorDataReq(
const TensorDataReq & req) =
delete;
130 TensorDataReq & operator=(
const TensorDataReq & req) =
delete;
131 TensorDataReq(TensorDataReq && req) noexcept =
default;
132 TensorDataReq & operator=(TensorDataReq && req) noexcept =
default;
133 ~TensorDataReq() =
default;
137 void launchExecutionThread();
139 void executionThreadWorkflow();
141 void processTensorDataRequests();
143 inline void lockDataReqQ(){data_req_mtx_.lock();}
144 inline void unlockDataReqQ(){data_req_mtx_.unlock();}
147 std::string graph_executor_name_;
149 std::string node_executor_name_;
151 std::shared_ptr<TensorGraphExecutor> graph_executor_;
153 std::map<std::string, std::shared_ptr<TensorGraph>> dags_;
155 std::string current_scope_;
157 std::shared_ptr<TensorGraph> current_dag_;
159 std::list<TensorDataReq> data_req_queue_;
163 std::atomic<bool> executing_;
165 std::atomic<bool> alive_;
167 std::thread exec_thread_;
169 std::mutex data_req_mtx_;
175 #endif //EXATN_RUNTIME_TENSOR_RUNTIME_HPP_