Skip to content

Commit

Permalink
[OpenCL] Registers AdjustContrastv2 (tensorflow#10949)
Browse files Browse the repository at this point in the history
* [OpenCL] Registers AdjustContrastv2 (#93)

* [OpenCL] Extended adjust_contrast_op_benchmark_test for OpenCL (#96)

* [OpenCL] Extended adjust_contrast_op_benchmark_test for OpenCL

* simplified to #ifndef

* Changed to "#if GOOGLE_CUDA"

* Update adjust_contrast_op_benchmark_test.cc

* Added comments
  • Loading branch information
Luke Iwanski authored and benoitsteiner committed Jun 21, 2017
1 parent 5248a48 commit 832894e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tensorflow/core/kernels/adjust_contrast_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ namespace tensorflow {

typedef Eigen::ThreadPoolDevice CPUDevice;
typedef Eigen::GpuDevice GPUDevice;
#ifdef TENSORFLOW_USE_SYCL
typedef Eigen::SyclDevice SYCLDevice;
#endif

// AdjustContrastOp is deprecated as of GraphDef version >= 2

Expand Down Expand Up @@ -410,4 +413,25 @@ REGISTER_KERNEL_BUILDER(Name("AdjustContrastv2").Device(DEVICE_GPU),
AdjustContrastOpv2<GPUDevice>);
#endif // GOOGLE_CUDA

#ifdef TENSORFLOW_USE_SYCL
template <>
class AdjustContrastOpv2<SYCLDevice> : public AdjustContrastOpV2Base {
public:
explicit AdjustContrastOpv2(OpKernelConstruction* context)
: AdjustContrastOpV2Base(context) {}

void DoCompute(OpKernelContext* context,
const ComputeOptions& options) override {
const int64 shape[4] = {options.batch, options.height, options.width,
options.channels};
functor::AdjustContrastv2<SYCLDevice>()(
context->eigen_device<SYCLDevice>(),
options.input->shaped<float, 4>(shape), options.factor->scalar<float>(),
options.output->shaped<float, 4>(shape));
}
};
REGISTER_KERNEL_BUILDER(Name("AdjustContrastv2").Device(DEVICE_SYCL),
AdjustContrastOpv2<SYCLDevice>);
#endif // TENSORFLOW_USE_SYCL

} // namespace tensorflow
5 changes: 5 additions & 0 deletions tensorflow/core/kernels/adjust_contrast_op_benchmark_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ static Graph* BM_AdjustContrast(int batches, int width, int height) {
// BM_AdjustContrast_cpu_1_299_299 179084 340186 2181 751.9M items/s
// BM_AdjustContrast_gpu_32_299_299 85276 123665 4189 2.9G items/s
BM_AdjustContrastDev(cpu, 1, 299, 299);
#if GOOGLE_CUDA
BM_AdjustContrastDev(gpu, 32, 299, 299);
#endif // GOOGLE_CUDA
#ifdef TENSORFLOW_USE_SYCL
BM_AdjustContrastDev(sycl, 32, 299, 299);
#endif // TENSORFLOW_USE_SYCL

} // namespace tensorflow

0 comments on commit 832894e

Please sign in to comment.