tvm
image.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
24 #ifndef TVM_RELAX_ATTRS_IMAGE_H_
25 #define TVM_RELAX_ATTRS_IMAGE_H_
26 
27 #include <tvm/relax/expr.h>
28 
29 namespace tvm {
30 namespace relax {
31 
33 struct Resize2DAttrs : public AttrsNodeReflAdapter<Resize2DAttrs> {
34  ffi::Array<FloatImm> roi;
35  ffi::String layout;
36  ffi::String method;
38  ffi::String rounding_method;
39  double cubic_alpha;
43 
44  static void RegisterReflection() {
45  namespace refl = tvm::ffi::reflection;
46  refl::ObjectDef<Resize2DAttrs>()
47  .def_ro("roi", &Resize2DAttrs::roi,
48  "Region of Interest for coordinate transformation mode 'tf_crop_and_resize'")
49  .def_ro("layout", &Resize2DAttrs::layout,
50  "Dimension ordering of input data. Can be 'NCHW', 'NHWC', etc."
51  "'N', 'C', 'H', 'W' stands for batch, channel, height, and width"
52  "dimensions respectively. Resize is applied on the 'H' and"
53  "'W' dimensions.")
54  .def_ro("method", &Resize2DAttrs::method,
55  "Specify the mode to use for scaling."
56  "nearest_neighbor - Nearest Neighbor"
57  "linear - Bilinear Interpolation"
58  "cubic - Bicubic Interpolation")
59  .def_ro("coordinate_transformation_mode", &Resize2DAttrs::coordinate_transformation_mode,
60  "Describes how to transform the coordinate in the resized tensor"
61  "to the coordinate in the original tensor."
62  "Refer to the ONNX Resize operator specification for details"
63  "Available options are half_pixel, align_corners and asymmetric")
64  .def_ro("rounding_method", &Resize2DAttrs::rounding_method,
65  "indicates how to find the \"nearest\" pixel in nearest_neighbor method"
66  "Available options are round, floor, and ceil.")
67  .def_ro("cubic_alpha", &Resize2DAttrs::cubic_alpha,
68  "Spline Coefficient for Bicubic Interpolation")
69  .def_ro("cubic_exclude", &Resize2DAttrs::cubic_exclude,
70  "Flag to exclude exterior of the image during bicubic interpolation")
71  .def_ro("extrapolation_value", &Resize2DAttrs::extrapolation_value,
72  "Value to return when roi is outside of the image")
73  .def_ro(
74  "out_dtype", &Resize2DAttrs::out_dtype,
75  "The dtype of the output tensor. It it is not specified, the output will have the same "
76  "dtype as input if not specified.");
77  }
79 }; // struct Resize2dAttrs
80 
81 } // namespace relax
82 } // namespace tvm
83 
84 #endif // TVM_RELAX_ATTRS_IMAGE_H_
Adapter for AttrsNode with the new reflection API.
Definition: attrs.h:385
Base class of all attribute class.
Definition: attrs.h:102
Runtime primitive data type.
Definition: data_type.h:47
Definition: repr_printer.h:91
Performance counters for profiling via the PAPI library.
Definition: analyzer.h:37
Attributes used in image resize2d operator.
Definition: image.h:33
ffi::Array< FloatImm > roi
Definition: image.h:34
DataType out_dtype
Definition: image.h:42
double extrapolation_value
Definition: image.h:41
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.Resize2DAttrs", Resize2DAttrs, BaseAttrsNode)
ffi::String method
Definition: image.h:36
ffi::String layout
Definition: image.h:35
static void RegisterReflection()
Definition: image.h:44
int cubic_exclude
Definition: image.h:40
double cubic_alpha
Definition: image.h:39
ffi::String rounding_method
Definition: image.h:38
ffi::String coordinate_transformation_mode
Definition: image.h:37