| 13 | using namespace BareMetal; |
| 14 | |
| 15 | bool TypecvtKernel::IsAvailable(TContext* context) const { |
| 16 | auto src_dtype = |
| 17 | SymbolHelper::gen_valid_dtype(context->getAttrOprand("operand:0").dtype); |
| 18 | auto dst_dtype = |
| 19 | SymbolHelper::gen_valid_dtype(context->getAttrOprand("operand:1").dtype); |
| 20 | bool ok_type = |
| 21 | !(!Utils::is_quant_dtype(src_dtype) && !Utils::is_quant_dtype(dst_dtype) && |
| 22 | Utils::is_int_dtype(dst_dtype)) || |
| 23 | ((Utils::is_float_dtype(src_dtype, 32) || |
| 24 | Utils::is_float_dtype(src_dtype, 16)) && |
| 25 | Utils::is_int_dtype(dst_dtype, 8)); |
| 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 |
| 36 | std::string TypecvtKernel::GetKernelSymbol(TContext* context) const { |
nothing calls this directly
no test coverage detected