|
|
|
@ -264,47 +264,63 @@ struct InferParams { |
|
|
|
|
|
|
|
|
|
class ElapsedTimeCriteria : public StopCriteria { |
|
|
|
|
public: |
|
|
|
|
ElapsedTimeCriteria(int64_t work_time_mcs) : m_work_time_mcs(work_time_mcs) { }; |
|
|
|
|
ElapsedTimeCriteria(int64_t work_time_mcs); |
|
|
|
|
|
|
|
|
|
void start() override { |
|
|
|
|
void start() override; |
|
|
|
|
void iter() override; |
|
|
|
|
bool done() override; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
int64_t m_work_time_mcs; |
|
|
|
|
int64_t m_start_ts = -1; |
|
|
|
|
int64_t m_curr_ts = -1; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
ElapsedTimeCriteria::ElapsedTimeCriteria(int64_t work_time_mcs) |
|
|
|
|
: m_work_time_mcs(work_time_mcs) { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
void ElapsedTimeCriteria::start() { |
|
|
|
|
m_start_ts = m_curr_ts = utils::timestamp<std::chrono::microseconds>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void iter() override { |
|
|
|
|
void ElapsedTimeCriteria::iter() { |
|
|
|
|
m_curr_ts = utils::timestamp<std::chrono::microseconds>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool done() override { |
|
|
|
|
bool ElapsedTimeCriteria::done() { |
|
|
|
|
return (m_curr_ts - m_start_ts) >= m_work_time_mcs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class NumItersCriteria : public StopCriteria { |
|
|
|
|
public: |
|
|
|
|
NumItersCriteria(int64_t num_iters); |
|
|
|
|
|
|
|
|
|
void start() override; |
|
|
|
|
void iter() override; |
|
|
|
|
bool done() override; |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
int64_t m_work_time_mcs; |
|
|
|
|
int64_t m_start_ts = -1; |
|
|
|
|
int64_t m_curr_ts = -1; |
|
|
|
|
int64_t m_num_iters; |
|
|
|
|
int64_t m_curr_iters = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class NumItersCriteria : public StopCriteria { |
|
|
|
|
public: |
|
|
|
|
NumItersCriteria(int64_t num_iters) : m_num_iters(num_iters) { }; |
|
|
|
|
NumItersCriteria::NumItersCriteria(int64_t num_iters) |
|
|
|
|
: m_num_iters(num_iters) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void start() override { |
|
|
|
|
void NumItersCriteria::start() { |
|
|
|
|
m_curr_iters = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void iter() override { |
|
|
|
|
void NumItersCriteria::iter() { |
|
|
|
|
++m_curr_iters; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool done() override { |
|
|
|
|
bool NumItersCriteria::done() { |
|
|
|
|
return m_curr_iters == m_num_iters; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
int64_t m_num_iters; |
|
|
|
|
int64_t m_curr_iters = 0; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class PipelineBuilder { |
|
|
|
|
public: |
|
|
|
|
PipelineBuilder(); |
|
|
|
|