tvm
Loading...
Searching...
No Matches
vision.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 */
23#ifndef TVM_RELAX_ATTRS_VISION_H_
24#define TVM_RELAX_ATTRS_VISION_H_
25
26#include <tvm/ffi/string.h>
27#include <tvm/ir/attrs.h>
28#include <tvm/ir/type.h>
29#include <tvm/relax/expr.h>
30
31namespace tvm {
32namespace relax {
33
36 ffi::String output_format;
37
38 static void RegisterReflection() {
39 namespace refl = tvm::ffi::reflection;
40 refl::ObjectDef<AllClassNonMaximumSuppressionAttrs>().def_ro(
42 "Output format, onnx or tensorflow. Returns outputs in a way that can be easily "
43 "consumed by each frontend.");
44 }
45 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.AllClassNonMaximumSuppressionAttrs",
47}; // struct AllClassNonMaximumSuppressionAttrs
48
50struct ROIAlignAttrs : public AttrsNode {
51 ffi::Array<int64_t> pooled_size;
54 bool aligned;
55 ffi::String layout;
56 ffi::String mode;
57
58 static void RegisterReflection() {
59 namespace refl = tvm::ffi::reflection;
60 refl::ObjectDef<ROIAlignAttrs>()
61 .def_ro("pooled_size", &ROIAlignAttrs::pooled_size, "Output size of roi align.")
62 .def_ro("spatial_scale", &ROIAlignAttrs::spatial_scale,
63 "Ratio of input feature map height (or width) to raw image height (or width).")
64 .def_ro("sample_ratio", &ROIAlignAttrs::sample_ratio,
65 "Optional sampling ratio of ROI align, using adaptive size by default.")
66 .def_ro("aligned", &ROIAlignAttrs::aligned,
67 "Whether to use the aligned ROIAlign semantics without the legacy 1-pixel clamp.")
68 .def_ro("layout", &ROIAlignAttrs::layout, "Dimension ordering of the input data.")
69 .def_ro("mode", &ROIAlignAttrs::mode, "Mode for ROI Align. Can be 'avg' or 'max'.");
70 }
72}; // struct ROIAlignAttrs
73
75struct ROIPoolAttrs : public AttrsNode {
76 ffi::Array<int64_t> pooled_size;
78 ffi::String layout;
79
80 static void RegisterReflection() {
81 namespace refl = tvm::ffi::reflection;
82 refl::ObjectDef<ROIPoolAttrs>()
83 .def_ro("pooled_size", &ROIPoolAttrs::pooled_size, "Output size of roi pool.")
84 .def_ro("spatial_scale", &ROIPoolAttrs::spatial_scale,
85 "Ratio of input feature map height (or width) to raw image height (or width).")
86 .def_ro("layout", &ROIPoolAttrs::layout, "Dimension ordering of the input data.");
87 }
89}; // struct ROIPoolAttrs
90
96
97 static void RegisterReflection() {
98 namespace refl = tvm::ffi::reflection;
99 refl::ObjectDef<GetValidCountsAttrs>()
100 .def_ro("score_threshold", &GetValidCountsAttrs::score_threshold,
101 "Lower limit of score for valid bounding boxes.")
102 .def_ro("id_index", &GetValidCountsAttrs::id_index,
103 "Index of the class categories, -1 to disable.")
104 .def_ro("score_index", &GetValidCountsAttrs::score_index,
105 "Index of the scores/confidence of boxes.");
106 }
107 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.GetValidCountsAttrs", GetValidCountsAttrs,
108 AttrsNode);
109}; // struct GetValidCountsAttrs
110
116 int top_k;
124
125 static void RegisterReflection() {
126 namespace refl = tvm::ffi::reflection;
127 refl::ObjectDef<NonMaximumSuppressionAttrs>()
128 .def_ro("max_output_size", &NonMaximumSuppressionAttrs::max_output_size,
129 "Max number of output valid boxes, -1 for no limit.")
130 .def_ro("iou_threshold", &NonMaximumSuppressionAttrs::iou_threshold,
131 "Non-maximum suppression IoU threshold.")
132 .def_ro("force_suppress", &NonMaximumSuppressionAttrs::force_suppress,
133 "Whether to suppress all detections regardless of class_id.")
134 .def_ro("top_k", &NonMaximumSuppressionAttrs::top_k,
135 "Keep maximum top k detections before nms, -1 for no limit.")
136 .def_ro("coord_start", &NonMaximumSuppressionAttrs::coord_start,
137 "Start index of the consecutive 4 coordinates.")
138 .def_ro("score_index", &NonMaximumSuppressionAttrs::score_index,
139 "Index of the scores/confidence of boxes.")
140 .def_ro("id_index", &NonMaximumSuppressionAttrs::id_index,
141 "Index of the class categories, -1 to disable.")
142 .def_ro("return_indices", &NonMaximumSuppressionAttrs::return_indices,
143 "Whether to return box indices in input data.")
144 .def_ro("invalid_to_bottom", &NonMaximumSuppressionAttrs::invalid_to_bottom,
145 "Whether to move all valid bounding boxes to the top.")
146 .def_ro("soft_nms_sigma", &NonMaximumSuppressionAttrs::soft_nms_sigma,
147 "Sigma for soft-NMS; 0.0 means standard hard NMS.")
148 .def_ro("score_threshold", &NonMaximumSuppressionAttrs::score_threshold,
149 "Score threshold for soft-NMS validity check; 0.0 when unused.");
150 }
151 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.NonMaximumSuppressionAttrs",
153}; // struct NonMaximumSuppressionAttrs
154
157 bool clip;
158 double threshold;
159 ffi::Array<double> variances;
161
162 static void RegisterReflection() {
163 namespace refl = tvm::ffi::reflection;
164 refl::ObjectDef<MultiboxTransformLocAttrs>()
165 .def_ro("clip", &MultiboxTransformLocAttrs::clip,
166 "Clip decoded ymin,xmin,ymax,xmax to [0,1].")
167 .def_ro("threshold", &MultiboxTransformLocAttrs::threshold,
168 "After softmax, zero scores strictly below this value.")
169 .def_ro("variances", &MultiboxTransformLocAttrs::variances,
170 "(x,y,w,h) scales = TFLite 1/x_scale,1/y_scale,1/w_scale,1/h_scale on "
171 "encodings. Very large w/h scales can overflow exp in decode.")
172 .def_ro("keep_background", &MultiboxTransformLocAttrs::keep_background,
173 "If false, force output scores[:,0,:] to 0 (background class).");
174 }
175 TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.MultiboxTransformLocAttrs",
177}; // struct MultiboxTransformLocAttrs
178
179} // namespace relax
180} // namespace tvm
181
182#endif // TVM_RELAX_ATTRS_VISION_H_
Helpers for attribute objects.
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
IR/AST nodes for TVM types shared across IR variants.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
Attributes used in AllClassNonMaximumSuppression operator.
Definition vision.h:35
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.AllClassNonMaximumSuppressionAttrs", AllClassNonMaximumSuppressionAttrs, AttrsNode)
static void RegisterReflection()
Definition vision.h:38
ffi::String output_format
Definition vision.h:36
Attributes used in GetValidCounts operator.
Definition vision.h:92
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.GetValidCountsAttrs", GetValidCountsAttrs, AttrsNode)
int id_index
Definition vision.h:94
static void RegisterReflection()
Definition vision.h:97
int score_index
Definition vision.h:95
double score_threshold
Definition vision.h:93
Attributes for multibox_transform_loc (SSD / TFLite-style box decode).
Definition vision.h:156
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.MultiboxTransformLocAttrs", MultiboxTransformLocAttrs, AttrsNode)
static void RegisterReflection()
Definition vision.h:162
bool clip
Definition vision.h:157
ffi::Array< double > variances
Definition vision.h:159
double threshold
Definition vision.h:158
bool keep_background
Definition vision.h:160
Attributes used in NonMaximumSuppression operator.
Definition vision.h:112
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.NonMaximumSuppressionAttrs", NonMaximumSuppressionAttrs, AttrsNode)
bool return_indices
Definition vision.h:120
bool force_suppress
Definition vision.h:115
int score_index
Definition vision.h:118
double iou_threshold
Definition vision.h:114
int top_k
Definition vision.h:116
double soft_nms_sigma
Definition vision.h:122
int id_index
Definition vision.h:119
static void RegisterReflection()
Definition vision.h:125
int max_output_size
Definition vision.h:113
bool invalid_to_bottom
Definition vision.h:121
int coord_start
Definition vision.h:117
double score_threshold
Definition vision.h:123
Attributes used in ROIAlign operator.
Definition vision.h:50
static void RegisterReflection()
Definition vision.h:58
ffi::String layout
Definition vision.h:55
bool aligned
Definition vision.h:54
double spatial_scale
Definition vision.h:52
ffi::String mode
Definition vision.h:56
int sample_ratio
Definition vision.h:53
ffi::Array< int64_t > pooled_size
Definition vision.h:51
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.ROIAlignAttrs", ROIAlignAttrs, AttrsNode)
Attributes used in ROIPool operator.
Definition vision.h:75
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("relax.attrs.ROIPoolAttrs", ROIPoolAttrs, AttrsNode)
ffi::String layout
Definition vision.h:78
static void RegisterReflection()
Definition vision.h:80
double spatial_scale
Definition vision.h:77
ffi::Array< int64_t > pooled_size
Definition vision.h:76