| 411 | } // namespace |
| 412 | |
| 413 | bool ElmwiseKernel::IsAvailable(TContext* context) const { |
| 414 | auto mode = context->getAttrStr("mode"); |
| 415 | auto nr_operands = context->getAttrInt("nr_operands"); |
| 416 | auto dtype = context->getAttrOprand("operand:0").dtype; |
| 417 | bool nr_operands_ok = nr_operands >= 2 && nr_operands <= 5; |
| 418 | bool mode_ok_unary = mode == "RELU" || mode == "SIGMOID" || mode == "EXP" || |
| 419 | mode == "NEGATE" || mode == "ROUND" || mode == "ABS" || |
| 420 | mode == "H_SWISH" || mode == "LOG" || mode == "SILU" || |
| 421 | mode == "ERF" || mode == "SQRT" || mode == "SIN" || |
| 422 | mode == "COS"; |
| 423 | bool mode_ok_binary = |
| 424 | mode == "ADD" || mode == "SUB" || mode == "MUL" || mode == "MAX" || |
| 425 | mode == "MIN" || mode == "LEQ" || mode == "LT" || mode == "FLOOR_DIV" || |
| 426 | mode == "EQ" || mode == "TRUE_DIV" || mode == "FUSE_ADD_RELU" || |
| 427 | mode == "FUSE_ADD_SIGMOID" || mode == "FUSE_ADD_TANH" || |
| 428 | (mode == "MOD" && (dtype == "i32" || dtype == "si32" || dtype == "f32")); |
| 429 | bool mode_ok_other = mode == "FUSE_MUL_ADD3" || mode == "FUSE_MUL_ADD4"; |
| 430 | return nr_operands_ok && (mode_ok_unary || mode_ok_binary || mode_ok_other); |
| 431 | } |
| 432 | |
| 433 | std::string ElmwiseKernel::GetKernelSymbol(TContext* context) const { |
| 434 | std::stringstream ss; |
nothing calls this directly
no test coverage detected