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