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

Method IsAvailable

compiler/lib/KernelGen/Arm/ArmCommon/Typecvt.cpp:14–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace ArmCommon;
13
14bool TypecvtKernel::IsAvailable(TContext* context) const {
15 auto src_dtype =
16 SymbolHelper::gen_valid_dtype(context->getAttrOprand("operand:0").dtype);
17 auto dst_dtype =
18 SymbolHelper::gen_valid_dtype(context->getAttrOprand("operand:1").dtype);
19 bool ok_type =
20 (Utils::is_quant_dtype(src_dtype, 8) &&
21 Utils::is_quant_dtype(dst_dtype, 8)) ||
22 (Utils::is_quant_dtype(src_dtype, 8) && Utils::is_float_dtype(dst_dtype)) ||
23 (Utils::is_float_dtype(src_dtype) && Utils::is_quant_dtype(dst_dtype, 8)) ||
24 (Utils::get_dtype_enum(src_dtype) == Utils::DtypeEnum::uint8 &&
25 Utils::is_float_dtype(dst_dtype));
26 if (Utils::is_quant_dtype(src_dtype)) {
27 CC_ASSERT(context->getAttrOprand("operand:0").scale > 0);
28 }
29 if (Utils::is_quant_dtype(dst_dtype)) {
30 CC_ASSERT(context->getAttrOprand("operand:1").scale > 0);
31 }
32 return ok_type;
33}
34
35//! kernel gen
36std::string TypecvtKernel::GetKernelSymbol(TContext* context) const {

Callers

nothing calls this directly

Calls 4

is_quant_dtypeFunction · 0.85
is_float_dtypeFunction · 0.85
getAttrOprandMethod · 0.80
get_dtype_enumFunction · 0.50

Tested by

no test coverage detected