1460{
1462
1463 switch (builtin_op)
1464 {
1465 case BuiltinOperator::BuiltinOperator_ADD_N:
1466 loadOperationTo<ir::operation::AddN>(op, subg);
1467 return;
1468 case BuiltinOperator::BuiltinOperator_CONV_2D:
1469 loadConv2D(op, subg);
1470 return;
1471 case BuiltinOperator::BuiltinOperator_AVERAGE_POOL_2D:
1473 return;
1474 case BuiltinOperator::BuiltinOperator_DEPTHWISE_CONV_2D:
1475 loadDepthwiseConv2D(op, subg);
1476 return;
1477 case BuiltinOperator::BuiltinOperator_TRANSPOSE_CONV:
1478 loadTransposeConv(op, subg);
1479 return;
1480 case BuiltinOperator::BuiltinOperator_RESHAPE:
1481 loadReshape(op, subg);
1482 return;
1483 case BuiltinOperator::BuiltinOperator_SOFTMAX:
1484 loadSoftmax(op, subg);
1485 return;
1486 case BuiltinOperator::BuiltinOperator_MAX_POOL_2D:
1488 return;
1489 case BuiltinOperator::BuiltinOperator_CONCATENATION:
1490 loadConcatenation(op, subg);
1491 return;
1492 case BuiltinOperator::BuiltinOperator_FLOOR:
1494 return;
1495 case BuiltinOperator::BuiltinOperator_FULLY_CONNECTED:
1496 loadFC(op, subg);
1497 return;
1498 case BuiltinOperator::BuiltinOperator_ADD:
1500 return;
1501 case BuiltinOperator::BuiltinOperator_SUB:
1503 return;
1504 case BuiltinOperator::BuiltinOperator_MUL:
1506 return;
1507 case BuiltinOperator::BuiltinOperator_DIV:
1509 return;
1510 case BuiltinOperator::BuiltinOperator_PACK:
1511 loadPack(op, subg);
1512 return;
1513 case BuiltinOperator::BuiltinOperator_ELU:
1515 return;
1516 case BuiltinOperator::BuiltinOperator_RELU:
1519 return;
1520 case BuiltinOperator::BuiltinOperator_RELU_N1_TO_1:
1522 -1.f);
1523 return;
1524 case BuiltinOperator::BuiltinOperator_RELU6:
1526 0.f);
1527 return;
1528 case BuiltinOperator::BuiltinOperator_RESIZE_BILINEAR:
1529 loadResizeBilinear(op, subg);
1530 return;
1531 case BuiltinOperator::BuiltinOperator_RESIZE_NEAREST_NEIGHBOR:
1532 loadResizeNearestNeighbor(op, subg);
1533 return;
1534 case BuiltinOperator::BuiltinOperator_RSQRT:
1536 return;
1537 case BuiltinOperator::BuiltinOperator_SELECT:
1538 case BuiltinOperator::BuiltinOperator_SELECT_V2:
1539 loadOperationTo<ir::operation::Select>(op, subg);
1540 return;
1541 case BuiltinOperator::BuiltinOperator_SQRT:
1543 return;
1544 case BuiltinOperator::BuiltinOperator_SQUARE:
1546 return;
1547 case BuiltinOperator::BuiltinOperator_SQUARED_DIFFERENCE:
1548 loadOperationTo<ir::operation::SquaredDifference>(op, subg);
1549 return;
1550 case BuiltinOperator::BuiltinOperator_TANH:
1552 1.f);
1553 return;
1554 case BuiltinOperator::BuiltinOperator_TRANSPOSE:
1555 loadOperationTo<ir::operation::Transpose>(op, subg);
1556 return;
1557 case BuiltinOperator::BuiltinOperator_MEAN:
1559 return;
1560 case BuiltinOperator::BuiltinOperator_REDUCE_ANY:
1562 return;
1563 case BuiltinOperator::BuiltinOperator_REDUCE_MAX:
1565 return;
1566 case BuiltinOperator::BuiltinOperator_REVERSE_V2:
1567 loadOperationTo<ir::operation::Reverse>(op, subg);
1568 return;
1569 case BuiltinOperator::BuiltinOperator_PAD:
1570 case BuiltinOperator::BuiltinOperator_PADV2:
1571 loadOperationTo<ir::operation::Pad>(op, subg);
1572 return;
1573 case BuiltinOperator::BuiltinOperator_LOGISTIC:
1575 return;
1576 case BuiltinOperator::BuiltinOperator_EXP:
1578 return;
1579 case BuiltinOperator::BuiltinOperator_EXPAND_DIMS:
1580 loadOperationTo<ir::operation::ExpandDims>(op, subg);
1581 return;
1582 case BuiltinOperator::BuiltinOperator_GATHER:
1583 loadGather(op, subg);
1584 return;
1585 case BuiltinOperator::BuiltinOperator_SPACE_TO_BATCH_ND:
1586 loadOperationTo<ir::operation::SpaceToBatchND>(op, subg);
1587 return;
1588 case BuiltinOperator::BuiltinOperator_BATCH_TO_SPACE_ND:
1589 loadOperationTo<ir::operation::BatchToSpaceND>(op, subg);
1590 return;
1591 case BuiltinOperator::BuiltinOperator_SUM:
1593 return;
1594 case BuiltinOperator::BuiltinOperator_CUSTOM:
1595 loadCustom(op, subg);
1596 return;
1597 case BuiltinOperator::BuiltinOperator_SQUEEZE:
1598 loadSqueeze(op, subg);
1599 return;
1600 case BuiltinOperator::BuiltinOperator_PRELU:
1601 loadOperationTo<ir::operation::PReLU>(op, subg);
1602 return;
1603 case BuiltinOperator::BuiltinOperator_SPLIT:
1604 loadSplit(op, subg);
1605 return;
1606 case BuiltinOperator::BuiltinOperator_SPLIT_V:
1607 loadSplitV(op, subg);
1608 return;
1609 case BuiltinOperator::BuiltinOperator_SLICE:
1610 loadOperationTo<ir::operation::Slice>(op, subg);
1611 return;
1612 case BuiltinOperator::BuiltinOperator_STRIDED_SLICE:
1613 loadStridedSlice(op, subg);
1614 return;
1615 case BuiltinOperator::BuiltinOperator_UNPACK:
1616 loadUnpack(op, subg);
1617 return;
1618 case BuiltinOperator::BuiltinOperator_FLOOR_DIV:
1619 loadElementwiseBinary(op, subg,
1621 return;
1622 case BuiltinOperator::BuiltinOperator_FLOOR_MOD:
1623 loadElementwiseBinary(op, subg,
1625 return;
1626 case BuiltinOperator::BuiltinOperator_MINIMUM:
1628 return;
1629 case BuiltinOperator::BuiltinOperator_MAXIMUM:
1631 return;
1632 case BuiltinOperator::BuiltinOperator_CAST:
1634 return;
1635 case BuiltinOperator::BuiltinOperator_EQUAL:
1636 case BuiltinOperator::BuiltinOperator_NOT_EQUAL:
1637 case BuiltinOperator::BuiltinOperator_GREATER_EQUAL:
1638 case BuiltinOperator::BuiltinOperator_GREATER:
1639 case BuiltinOperator::BuiltinOperator_LESS_EQUAL:
1640 case BuiltinOperator::BuiltinOperator_LESS:
1641 loadComparison(op, subg);
1642 return;
1643 case BuiltinOperator::BuiltinOperator_ONE_HOT:
1644 loadOneHot(op, subg);
1645 return;
1646 case BuiltinOperator::BuiltinOperator_ABS:
1648 return;
1649 case BuiltinOperator::BuiltinOperator_COS:
1651 return;
1652 case BuiltinOperator::BuiltinOperator_SIN:
1654 return;
1655 case BuiltinOperator::BuiltinOperator_SHAPE:
1656 loadOperationTo<ir::operation::Shape>(op, subg);
1657 return;
1658 case BuiltinOperator::BuiltinOperator_REDUCE_PROD:
1660 return;
1661 case BuiltinOperator::BuiltinOperator_IF:
1662 loadIf(op, subg);
1663 return;
1664 case BuiltinOperator::BuiltinOperator_WHILE:
1665 loadWhile(op, subg);
1666 return;
1667 case BuiltinOperator::BuiltinOperator_NEG:
1669 return;
1670 case BuiltinOperator::BuiltinOperator_ARG_MAX:
1671 loadArgMinMax(op, subg, true);
1672 return;
1673 case BuiltinOperator::BuiltinOperator_ARG_MIN:
1674 loadArgMinMax(op, subg, false);
1675 return;
1676 case BuiltinOperator::BuiltinOperator_LOG:
1678 return;
1679 case BuiltinOperator::BuiltinOperator_ROUND:
1681 return;
1682 case BuiltinOperator::BuiltinOperator_POW:
1683 loadOperationTo<ir::operation::Pow>(op, subg);
1684 return;
1685 case BuiltinOperator::BuiltinOperator_LOGICAL_NOT:
1687 return;
1688 case BuiltinOperator::BuiltinOperator_LOGICAL_AND:
1689 loadElementwiseBinary(op, subg,
1691 return;
1692 case BuiltinOperator::BuiltinOperator_LOGICAL_OR:
1693 loadElementwiseBinary(op, subg,
1695 return;
1696 case BuiltinOperator::BuiltinOperator_FILL:
1697 loadOperationTo<ir::operation::Fill>(op, subg);
1698 return;
1699 case BuiltinOperator::BuiltinOperator_ZEROS_LIKE:
1701 return;
1702 case BuiltinOperator::BuiltinOperator_TILE:
1703 loadOperationTo<ir::operation::Tile>(op, subg);
1704 return;
1705 case BuiltinOperator::BuiltinOperator_RANGE:
1706 loadOperationTo<ir::operation::Range>(op, subg);
1707 return;
1708 case BuiltinOperator::BuiltinOperator_BATCH_MATMUL:
1709 loadBatchMatMul(op, subg);
1710 return;
1711 case BuiltinOperator::BuiltinOperator_LOG_SOFTMAX:
1712 loadLogSoftmax(op, subg);
1713 return;
1714 case BuiltinOperator::BuiltinOperator_QUANTIZE:
1716 return;
1717 case BuiltinOperator::BuiltinOperator_DEQUANTIZE:
1719 return;
1720 case BuiltinOperator::BuiltinOperator_SPACE_TO_DEPTH:
1721 loadSpaceToDepth(op, subg);
1722 return;
1723 case BuiltinOperator::BuiltinOperator_L2_NORMALIZATION:
1724 loadOperationTo<ir::operation::L2Normalization>(op, subg);
1725 break;
1726 case BuiltinOperator::BuiltinOperator_LEAKY_RELU:
1727 loadLeakyRelu(op, subg);
1728 return;
1729 case BuiltinOperator::BuiltinOperator_RANK:
1730 loadOperationTo<ir::operation::Rank>(op, subg);
1731 return;
1732 case BuiltinOperator::BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM:
1733 loadUnidirectionalSequenceLSTM(op, subg);
1734 return;
1735 case BuiltinOperator::BuiltinOperator_DEPTH_TO_SPACE:
1736 loadDepthToSpace(op, subg);
1737 return;
1738 case BuiltinOperator::BuiltinOperator_EMBEDDING_LOOKUP:
1739 loadOperationTo<ir::operation::EmbeddingLookup>(op, subg);
1740 return;
1741 case BuiltinOperator::BuiltinOperator_HASHTABLE_LOOKUP:
1742 loadOperationTo<ir::operation::HashtableLookup>(op, subg);
1743 return;
1744 default:
1745 throw std::runtime_error(
1746 std::string("Unsupported operation: ").append(EnumNameBuiltinOperator(builtin_op)));
1747 }
1748}
BuiltinOperator getBuiltinOperator(const Operator *op)