diff options
author | 2015-11-06 16:27:58 -0800 | |
---|---|---|
committer | 2015-11-06 16:27:58 -0800 | |
commit | f41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch) | |
tree | ef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/core/framework/reader_op_kernel.h |
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation
using data flow graphs.
Base CL: 107276108
Diffstat (limited to 'tensorflow/core/framework/reader_op_kernel.h')
-rw-r--r-- | tensorflow/core/framework/reader_op_kernel.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tensorflow/core/framework/reader_op_kernel.h b/tensorflow/core/framework/reader_op_kernel.h new file mode 100644 index 0000000000..8e5cc50c9b --- /dev/null +++ b/tensorflow/core/framework/reader_op_kernel.h @@ -0,0 +1,42 @@ +#ifndef TENSORFLOW_FRAMEWORK_READER_OP_KERNEL_H_ +#define TENSORFLOW_FRAMEWORK_READER_OP_KERNEL_H_ + +#include <functional> +#include <string> + +#include "tensorflow/core/framework/op_kernel.h" +#include "tensorflow/core/framework/reader_interface.h" +#include "tensorflow/core/framework/resource_mgr.h" +#include "tensorflow/core/platform/port.h" + +namespace tensorflow { + +// Implementation for ops providing a Reader. +class ReaderOpKernel : public OpKernel { + public: + explicit ReaderOpKernel(OpKernelConstruction* context); + ~ReaderOpKernel() override; + + void Compute(OpKernelContext* context) override; + + // Must be called by descendants before the first call to Compute() + // (typically called during construction). factory must return a + // ReaderInterface descendant allocated with new that ReaderOpKernel + // will take ownership of. + void SetReaderFactory(std::function<ReaderInterface*()> factory) { + mutex_lock l(mu_); + DCHECK(!have_handle_); + factory_ = factory; + } + + private: + mutex mu_; + bool have_handle_ GUARDED_BY(mu_); + PersistentTensor handle_ GUARDED_BY(mu_); + ContainerInfo cinfo_; + std::function<ReaderInterface*()> factory_; +}; + +} // namespace tensorflow + +#endif // TENSORFLOW_FRAMEWORK_READER_OP_KERNEL_H_ |