MCPcopy Create free account
hub / github.com/MegEngine/MegCC / IsAvailable

Method IsAvailable

compiler/lib/KernelGen/BareMetal/WarpPerspective.cpp:11–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace BareMetal;
10
11bool WarpPerspectiveKernel::IsAvailable(TContext* ctx) const {
12 auto nr_operands = ctx->getAttrInt("nr_operands");
13 auto src_layout = ctx->getAttrOprand("operand:0");
14 auto mat_layout = ctx->getAttrOprand("operand:1");
15 auto dst_layout = ctx->getAttrOprand("operand:2");
16 if (nr_operands == 4) {
17 dst_layout = ctx->getAttrOprand("operand:3");
18 } else {
19 CC_ASSERT(nr_operands == 3);
20 }
21 bool dtype_valid = (src_layout.dtype == "f32" || src_layout.dtype == "ui8" ||
22 src_layout.dtype == "f16") &&
23 mat_layout.dtype == "f32" &&
24 dst_layout.dtype == src_layout.dtype;
25 bool shape_valid =
26 (nr_operands == 3 && src_layout.shape[0] == mat_layout.shape[0] &&
27 src_layout.shape[0] == dst_layout.shape[0]) ||
28 (nr_operands == 4);
29 bool imode_valid = (ctx->getAttrStr("imode") == "LINEAR");
30 return dtype_valid && shape_valid && imode_valid;
31}
32//! kernel gen
33std::string WarpPerspectiveKernel::GetKernelSymbol(TContext* ctx) const {
34 std::stringstream ss;

Callers

nothing calls this directly

Calls 2

getAttrOprandMethod · 0.80
getAttrStrMethod · 0.80

Tested by

no test coverage detected