| 10 | namespace BareMetal { |
| 11 | |
| 12 | bool 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 |
| 33 | std::string IndexingMultiAxisKernel::GetKernelSymbol(TContext* context) const { |
| 34 | std::stringstream ss; |
nothing calls this directly
no test coverage detected