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

Method IsAvailable

compiler/lib/KernelGen/BareMetal/Pooling.cpp:15–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace BareMetal;
14
15bool PoolingKernel::IsAvailable(TContext* context) const {
16 bool mode_ok = context->getAttrStr("format") == "NCHW";
17 auto src_dtype = context->getAttrOprand("operand:0").dtype;
18 auto dst_dtype = context->getAttrOprand("operand:1").dtype;
19 bool dtype_ok = (src_dtype == dst_dtype) && (Utils::is_float_dtype(src_dtype) ||
20 Utils::is_float_dtype(src_dtype, 16) ||
21 Utils::is_quant_dtype(src_dtype));
22 if (Utils::is_quant_dtype(src_dtype)) {
23 CC_ASSERT(
24 context->getAttrOprand("operand:0").scale ==
25 context->getAttrOprand("operand:1").scale)
26 << "quant pooling only support same scale\n";
27 }
28 return mode_ok && dtype_ok;
29}
30//! kernel gen
31std::string PoolingImpl::GetKernelSymbol(TContext* context) const {
32 std::stringstream ss;

Callers

nothing calls this directly

Calls 4

is_float_dtypeFunction · 0.85
is_quant_dtypeFunction · 0.85
getAttrStrMethod · 0.80
getAttrOprandMethod · 0.80

Tested by

no test coverage detected