| 25 | } |
| 26 | |
| 27 | bool RelayoutKernel::IsAvailable(TContext* context) const { |
| 28 | auto dtype_str = context->getAttrOprand("operand:0").dtype; |
| 29 | int32_t type_size = Utils::get_dtype_size(dtype_str); |
| 30 | bool ok_dtype = (context->getAttrOprand("operand:0").dtype == |
| 31 | context->getAttrOprand("operand:1").dtype) && |
| 32 | (type_size == 1 || type_size == 2 || type_size == 4); |
| 33 | std::vector<size_t> shape_in = context->getAttrOprand("operand:0").shape; |
| 34 | std::vector<size_t> shape_out = context->getAttrOprand("operand:0").shape; |
| 35 | bool ok_shape = shape_in.size() == shape_out.size(); |
| 36 | for (size_t i = 0; ok_shape && i < shape_in.size(); ++i) { |
| 37 | ok_shape = ok_shape && shape_in.at(i) == shape_out.at(i); |
| 38 | } |
| 39 | return ok_dtype && ok_shape; |
| 40 | } |
| 41 | |
| 42 | //! kernel gen |
| 43 | std::string RelayoutKernel::GetKernelSymbol(TContext* context) const { |
nothing calls this directly
no test coverage detected