MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / Checker

Class Checker

dnn/test/common/checker.h:118–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116
117template <typename Opr, typename Proxy = OprProxy<Opr>>
118class Checker : public CheckerHelper {
119public:
120 using Param = typename Opr::Param;
121 using BeforeExecCallback = std::function<void(Opr*, const TensorValueArray&)>;
122 Checker(Handle* handle, bool check_dispatch = true)
123 : CheckerHelper(handle, check_dispatch), m_param(Param()) {}
124
125 TensorLayoutArray make_layouts(const TensorShapeArray& shapes) {
126 TensorLayoutArray layouts(shapes.size());
127 for (size_t i = 0; i < shapes.size(); ++i) {
128 DType dt =
129 (m_dtype.find(i) != m_dtype.end() ? m_dtype[i] : dtype::Float32());
130 if (m_fmt.find(i) == m_fmt.end()) {
131 layouts[i] = TensorLayout(shapes[i], dt);
132 } else
133 layouts[i] = TensorLayout(shapes[i], dt, m_fmt[i]);
134 }
135 return layouts;
136 }
137
138 /*!
139 * \brief execute opr on current param/dtype/rng config
140 * \param shapes input/output shapes, which would be passed as
141 * arguments to Opr::deduce_layout
142 *
143 * Checker would construct TensorLayout vectors from shapes and dtypes,
144 * and call exec(TensorLayoutArray &).
145 */
146 Checker& exec(const TensorShapeArray& shapes) {
147 exec(make_layouts(shapes));
148 return *this;
149 }
150
151 void exec(TensorLayoutArray layouts);
152
153 //! explicitly require argument to be TensorShape
154 Checker& execs(const TensorShapeArray& shapes) { return exec(shapes); }
155
156 //! explicitly require argument to be TensorLayout
157 Checker& execl(const TensorLayoutArray& layouts) {
158 exec(layouts);
159 return *this;
160 }
161
162 Checker& exect(
163 const TensorValueArray& testcase_in, const TensorValueArray& testcase_out);
164
165 Checker& set_param(Param param) {
166 m_param = param;
167 opr()->param() = param;
168 return *this;
169 }
170 Checker& set_dtype(size_t idx, DType dtype) {
171 m_dtype[idx] = dtype;
172 return *this;
173 }
174 Checker& set_fmt(size_t idx, TensorFormat fmt) {
175 m_fmt[idx] = fmt;

Callers 1

TESTFunction · 0.50

Calls 3

execFunction · 0.50
paramMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected