tensorflow::tensorflow/core/lib/core/threadpool.h
namespace tensorflow {
namespace thread {
class ThreadPool {
public:
ThreadPool(Env* env, const ThreadOptions& thread_options, const string& name,
int num_threads, bool low_latency_hint);
ThreadPool(Env* env, const string& name, int num_threads);
ThreadPool(Env* env, const ThreadOptions& thread_options, const string& name, int num_threads);
~ThreadPool();
void Schedule(std::function<void()> fn); void ParallelFor(int64 total, int64 cost_per_unit, std::function<void(int64, int64)> fn);
void ParallelForWithWorkerId( int64 total, int64 cost_per_unit, const std::function<void(int64, int64, int)>& fn);
int NumThreads() const;
int CurrentThreadId() const;
struct Impl;
private: std::unique_ptr<Impl> impl_; TF_DISALLOW_COPY_AND_ASSIGN(ThreadPool); };
} }
本文详细介绍了TensorFlow中线程池类的定义及使用方法。主要涉及线程池构造函数的不同形式及其参数意义,如环境配置、线程选项、线程数量等。此外还阐述了线程池的主要成员函数,包括任务调度、并行循环等功能。
1107

被折叠的 条评论
为什么被折叠?



