1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 #ifndef TENSORFLOW_COMPILER_TF2XLA_KERNELS_IMAGE_RESIZE_OPS_H_
16 #define TENSORFLOW_COMPILER_TF2XLA_KERNELS_IMAGE_RESIZE_OPS_H_
17 
18 #include "tensorflow/compiler/tf2xla/xla_op_kernel.h"
19 #include "tensorflow/compiler/xla/primitive_util.h"
20 
21 namespace tensorflow {
22 
23 class ResizeNearestNeighborOp : public XlaOpKernel {
24  public:
25   explicit ResizeNearestNeighborOp(OpKernelConstruction* ctx);
26   void Compile(XlaOpKernelContext* ctx) override;
27 
28  protected:
29   bool align_corners_ = true;
30   bool half_pixel_centers_ = true;
31   bool is_kernel_bilinear_ = false;
32 };
33 
34 class ResizeBilinearOp : public XlaOpKernel {
35  public:
36   explicit ResizeBilinearOp(OpKernelConstruction* ctx);
37 
38   void Compile(XlaOpKernelContext* ctx) override;
39 
40  protected:
41   bool align_corners_ = true;
42   bool half_pixel_centers_ = true;
43   bool is_kernel_bilinear_ = true;
44 };
45 
46 class ResizeBilinearGradOp : public XlaOpKernel {
47  public:
48   explicit ResizeBilinearGradOp(OpKernelConstruction* ctx);
49 
50   void Compile(XlaOpKernelContext* ctx) override;
51 
52  protected:
53   bool align_corners_;
54   bool half_pixel_centers_ = true;
55   xla::PrimitiveType output_type_;
56 };
57 
58 }  // namespace tensorflow
59 
60 #endif  // TENSORFLOW_COMPILER_TF2XLA_KERNELS_IMAGE_RESIZE_OPS_H_
61