tvm
Loading...
Searching...
No Matches
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
29namespace tvm {
30namespace relax {
31
33struct Resize2DAttrs : public AttrsNode {
34 ffi::Array<FloatImm> roi;
35 ffi::String layout;
36 ffi::String method;
38 ffi::String rounding_method;
42 ffi::Optional<DLDataType> out_dtype;
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
82struct Resize3DAttrs : public AttrsNode {
83 ffi::Array<FloatImm> roi;
84 ffi::String layout;
85 ffi::String method;
87 ffi::String rounding_method;
91 ffi::Optional<DLDataType> out_dtype;
92
93 static void RegisterReflection() {
94 namespace refl = tvm::ffi::reflection;
95 refl::ObjectDef<Resize3DAttrs>()
96 .def_ro("roi", &Resize3DAttrs::roi,
97 "Region of Interest for coordinate transformation mode 'tf_crop_and_resize'")
98 .def_ro("layout", &Resize3DAttrs::layout,
99 "Dimension ordering of input data. Can be 'NCDHW', 'NDHWC', etc."
100 "'N', 'C', 'D', 'H', 'W' stands for batch, channel, depth, height, and width"
101 "dimensions respectively. Resize is applied on the 'D', 'H' and"
102 "'W' dimensions.")
103 .def_ro("method", &Resize3DAttrs::method,
104 "Specify the mode to use for scaling."
105 "nearest_neighbor - Nearest Neighbor"
106 "linear - Trilinear Interpolation"
107 "cubic - Tricubic Interpolation")
108 .def_ro("coordinate_transformation_mode", &Resize3DAttrs::coordinate_transformation_mode,
109 "Describes how to transform the coordinate in the resized tensor"
110 "to the coordinate in the original tensor."
111 "Refer to the ONNX Resize operator specification for details"
112 "Available options are half_pixel, align_corners and asymmetric")
113 .def_ro("rounding_method", &Resize3DAttrs::rounding_method,
114 "indicates how to find the \"nearest\" pixel in nearest_neighbor method"
115 "Available options are round, floor, and ceil.")
116 .def_ro("cubic_alpha", &Resize3DAttrs::cubic_alpha,
117 "Spline Coefficient for Tricubic Interpolation")
118 .def_ro("cubic_exclude", &Resize3DAttrs::cubic_exclude,
119 "Flag to exclude exterior of the image during tricubic interpolation")
120 .def_ro("extrapolation_value", &Resize3DAttrs::extrapolation_value,
121 "Value to return when roi is outside of the image")
122 .def_ro(
123 "out_dtype", &Resize3DAttrs::out_dtype,
124 "The dtype of the output tensor. It it is not specified, the output will have the same "
125 "dtype as input if not specified.");
126 }
128}; // struct Resize3DAttrs
129
131struct GridSampleAttrs : public AttrsNode {
132 ffi::String method;
133 ffi::String layout;
134 ffi::String padding_mode;
136
137 static void RegisterReflection() {
138 namespace refl = tvm::ffi::reflection;
139 refl::ObjectDef<GridSampleAttrs>()
140 .def_ro("method", &GridSampleAttrs::method,
141 "Interpolation method. Can be 'nearest', 'bilinear', or 'bicubic'.")
142 .def_ro("layout", &GridSampleAttrs::layout,
143 "Dimension ordering of input data. Can be 'NCHW', 'NHWC', etc.")
144 .def_ro("padding_mode", &GridSampleAttrs::padding_mode,
145 "Padding mode for outside grid values. Can be 'zeros', 'border', or 'reflection'.")
146 .def_ro("align_corners", &GridSampleAttrs::align_corners,
147 "If True, the corner pixels of the input and output tensors are aligned.");
148 }
150}; // struct GridSampleAttrs
151
153struct AffineGridAttrs : public AttrsNode {
155
156 static void RegisterReflection() {
157 namespace refl = tvm::ffi::reflection;
158 refl::ObjectDef<AffineGridAttrs>().def_ro(
159 "align_corners", &AffineGridAttrs::align_corners,
160 "If True, normalized grid coordinates map to corner pixels; otherwise to pixel centers.");
161 }
163}; // struct AffineGridAttrs
164
165} // namespace relax
166} // namespace tvm
167
168#endif // TVM_RELAX_ATTRS_IMAGE_H_
Base class of all attribute class.
Definition attrs.h:49
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
Attributes used in image affine_grid operator.
Definition image.h:153
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.AffineGridAttrs", AffineGridAttrs, AttrsNode)
static void RegisterReflection()
Definition image.h:156
bool align_corners
Definition image.h:154
Attributes used in image grid_sample operator.
Definition image.h:131
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.GridSampleAttrs", GridSampleAttrs, AttrsNode)
ffi::String method
Definition image.h:132
bool align_corners
Definition image.h:135
static void RegisterReflection()
Definition image.h:137
ffi::String padding_mode
Definition image.h:134
ffi::String layout
Definition image.h:133
Attributes used in image resize2d operator.
Definition image.h:33
ffi::Array< FloatImm > roi
Definition image.h:34
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.Resize2DAttrs", Resize2DAttrs, AttrsNode)
double extrapolation_value
Definition image.h:41
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
ffi::Optional< DLDataType > out_dtype
Definition image.h:42
Attributes used in image resize3d operator.
Definition image.h:82
double extrapolation_value
Definition image.h:90
ffi::String method
Definition image.h:85
ffi::String layout
Definition image.h:84
ffi::Array< FloatImm > roi
Definition image.h:83
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.Resize3DAttrs", Resize3DAttrs, AttrsNode)
static void RegisterReflection()
Definition image.h:93
int cubic_exclude
Definition image.h:89
ffi::String coordinate_transformation_mode
Definition image.h:86
ffi::String rounding_method
Definition image.h:87
ffi::Optional< DLDataType > out_dtype
Definition image.h:91
double cubic_alpha
Definition image.h:88