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

Method IsAvailable

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

Source from the content-addressed store, hash-verified

10namespace BareMetal {
11
12bool IndexingMultiAxisKernel::IsAvailable(TContext* context) const {
13 int nr_operand = context->getAttrInt("nr_operands");
14 bool ok_operand = nr_operand > 2;
15 auto src_dtype = context->getAttrOprand("operand:0").dtype;
16 std::string src_specifier =
17 Utils::cvt_dtype_specifier(SymbolHelper::gen_valid_dtype(src_dtype));
18 std::string dst_specifier = Utils::cvt_dtype_specifier(
19 SymbolHelper::gen_valid_dtype(Utils::get_last_operand(context).dtype));
20 bool ok_dtype = (src_specifier == dst_specifier);
21 bool ok_axis = true;
22 int last_axis = -1;
23 for (int i = 0; i < nr_operand - 2; ++i) {
24 int axis = context->getAttrInt("axis:" + std::to_string(i));
25 if (last_axis >= 0) {
26 ok_axis = ok_axis && (axis == last_axis + 1);
27 }
28 last_axis = axis;
29 }
30 return ok_dtype && ok_operand && ok_axis;
31}
32//! kernel gen
33std::string IndexingMultiAxisKernel::GetKernelSymbol(TContext* context) const {
34 std::stringstream ss;

Callers

nothing calls this directly

Calls 4

cvt_dtype_specifierFunction · 0.85
get_last_operandFunction · 0.85
getAttrOprandMethod · 0.80
to_stringFunction · 0.50

Tested by

no test coverage detected