Bolt
task.h
Go to the documentation of this file.
1 
22 #ifndef UNI_INCLUDE_TASK_H_
23 #define UNI_INCLUDE_TASK_H_
24 
25 #include <string>
26 #include <map>
27 #include <memory>
28 #include <iostream>
29 #include <sstream>
30 
31 #include "tensor.hpp"
32 #include "profiling.h"
33 
35 typedef enum TaskStatus {
40 } TaskStatus;
41 
42 class Task {
43 public:
49  Task()
50  {
51  this->status = TASK_CREATE;
52  }
53 
61  Task(std::string graphPath, std::map<std::string, std::shared_ptr<Tensor>> data)
62  {
63  this->set(ut_time_ms(), graphPath, data, TASK_READY);
64  }
65 
74  Task(int id, std::string graphPath, std::map<std::string, std::shared_ptr<Tensor>> data)
75  {
76  this->set(id, graphPath, data, TASK_READY);
77  }
78 
85  Task(Task *task)
86  {
87  this->set(task->id, task->graphPath, task->data, task->status);
88  }
89 
99  void set(int id,
100  std::string graphPath,
101  std::map<std::string, std::shared_ptr<Tensor>> data,
103  {
104  this->id = id;
105  this->graphPath = graphPath;
106  this->data = data;
107  this->status = status;
108  }
109 
110  friend std::ostream &operator<<(std::ostream &os, const Task &task)
111  {
112  os << "Task " << task.id << "(timestamp " << task.id << ", status " << task.status
113  << ", graph " << task.graphPath << ", data " << std::endl;
114  for (auto iter : task.data) {
115  os << "tensor name " << iter.first << " " << iter.second->string(1) << std::endl;
116  }
117  os << ")";
118  return os;
119  }
120 
122  int id;
126  std::string graphPath;
128  std::map<std::string, std::shared_ptr<Tensor>> data;
129 };
130 #endif // UNI_INCLUDE_TASK_H_
Task()
Task constructor.
Definition: task.h:49
task has been finished
Definition: task.h:39
Task(std::string graphPath, std::map< std::string, std::shared_ptr< Tensor >> data)
Task constructor.
Definition: task.h:61
task can be processed
Definition: task.h:37
int id
Definition: task.h:122
Task(int id, std::string graphPath, std::map< std::string, std::shared_ptr< Tensor >> data)
Task constructor.
Definition: task.h:74
task is being processed
Definition: task.h:38
TaskStatus status
Definition: task.h:124
TaskStatus
Definition: task.h:35
std::map< std::string, std::shared_ptr< Tensor > > data
Definition: task.h:128
std::string graphPath
Definition: task.h:126
task is created
Definition: task.h:36
Task(Task *task)
Task copy constructor.
Definition: task.h:85
Definition: task.h:42