Skip to content

Commit b405010

Browse files
jeffmakLuke Iwanski
authored andcommitted
[OpenCL] Registers AdjustContrastv2 (tensorflow#93)
1 parent e78468d commit b405010

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎tensorflow/core/kernels/adjust_contrast_op.cc‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ namespace tensorflow {
3131

3232
typedef Eigen::ThreadPoolDevice CPUDevice;
3333
typedef Eigen::GpuDevice GPUDevice;
34+
#ifdef TENSORFLOW_USE_SYCL
35+
typedef Eigen::SyclDevice SYCLDevice;
36+
#endif
3437

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

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

416+
#ifdef TENSORFLOW_USE_SYCL
417+
template <>
418+
class AdjustContrastOpv2<SYCLDevice> : public AdjustContrastOpV2Base {
419+
public:
420+
explicit AdjustContrastOpv2(OpKernelConstruction* context)
421+
: AdjustContrastOpV2Base(context) {}
422+
423+
void DoCompute(OpKernelContext* context,
424+
const ComputeOptions& options) override {
425+
const int64 shape[4] = {options.batch, options.height, options.width,
426+
options.channels};
427+
functor::AdjustContrastv2<SYCLDevice>()(
428+
context->eigen_device<SYCLDevice>(),
429+
options.input->shaped<float, 4>(shape), options.factor->scalar<float>(),
430+
options.output->shaped<float, 4>(shape));
431+
}
432+
};
433+
REGISTER_KERNEL_BUILDER(Name("AdjustContrastv2").Device(DEVICE_SYCL),
434+
AdjustContrastOpv2<SYCLDevice>);
435+
#endif // TENSORFLOW_USE_SYCL
436+
413437
} // namespace tensorflow

0 commit comments

Comments
 (0)