@@ -615,10 +615,14 @@ Error defineAddNode(
615
615
616
616
std::pair<float , float > min_max = getOutputMinMax (node);
617
617
auto graph_node = node->xnode_union_as_XNNAdd ();
618
- xnn_status status = xnn_define_add2 (
618
+
619
+ struct xnn_binary_params params = {
620
+ .output_min = min_max.first , .output_max = min_max.second };
621
+
622
+ xnn_status status = xnn_define_binary (
619
623
subgraph_ptr,
620
- min_max. first ,
621
- min_max. second ,
624
+ xnn_binary_add ,
625
+ ¶ms ,
622
626
remapped_ids.at (graph_node->input1_id ()),
623
627
remapped_ids.at (graph_node->input2_id ()),
624
628
remapped_ids.at (graph_node->output_id ()),
@@ -644,8 +648,11 @@ Error defineMinimumNode(
644
648
MAYBE_UNUSED (graph);
645
649
646
650
auto graph_node = node->xnode_union_as_XNNMinimum ();
647
- xnn_status status = xnn_define_minimum2 (
651
+
652
+ xnn_status status = xnn_define_binary (
648
653
subgraph_ptr,
654
+ xnn_binary_minimum,
655
+ nullptr ,
649
656
remapped_ids.at (graph_node->input1_id ()),
650
657
remapped_ids.at (graph_node->input2_id ()),
651
658
remapped_ids.at (graph_node->output_id ()),
@@ -673,10 +680,14 @@ Error defineSubtractNode(
673
680
674
681
auto graph_node = node->xnode_union_as_XNNSubtract ();
675
682
std::pair<float , float > min_max = getOutputMinMax (node);
676
- xnn_status status = xnn_define_subtract (
683
+
684
+ struct xnn_binary_params params = {
685
+ .output_min = min_max.first , .output_max = min_max.second };
686
+
687
+ xnn_status status = xnn_define_binary (
677
688
subgraph_ptr,
678
- min_max. first ,
679
- min_max. second ,
689
+ xnn_binary_subtract ,
690
+ ¶ms ,
680
691
remapped_ids.at (graph_node->input1_id ()),
681
692
remapped_ids.at (graph_node->input2_id ()),
682
693
remapped_ids.at (graph_node->output_id ()),
@@ -704,10 +715,14 @@ Error defineMultiplyNode(
704
715
705
716
auto graph_node = node->xnode_union_as_XNNMultiply ();
706
717
std::pair<float , float > min_max = getOutputMinMax (node);
707
- xnn_status status = xnn_define_multiply2 (
718
+
719
+ struct xnn_binary_params params = {
720
+ .output_min = min_max.first , .output_max = min_max.second };
721
+
722
+ xnn_status status = xnn_define_binary (
708
723
subgraph_ptr,
709
- min_max. first ,
710
- min_max. second ,
724
+ xnn_binary_multiply ,
725
+ ¶ms ,
711
726
remapped_ids.at (graph_node->input1_id ()),
712
727
remapped_ids.at (graph_node->input2_id ()),
713
728
remapped_ids.at (graph_node->output_id ()),
@@ -857,10 +872,14 @@ Error defineClampNode(
857
872
858
873
std::pair<float , float > min_max = getOutputMinMax (node);
859
874
auto graph_node = node->xnode_union_as_XNNClamp ();
860
- xnn_status status = xnn_define_clamp (
875
+
876
+ union xnn_unary_params params = {
877
+ .clamp = {.min = min_max.first , .max = min_max.second }};
878
+
879
+ xnn_status status = xnn_define_unary (
861
880
subgraph_ptr,
862
- min_max. first ,
863
- min_max. second ,
881
+ xnn_unary_clamp ,
882
+ ¶ms ,
864
883
remapped_ids.at (graph_node->input_id ()),
865
884
remapped_ids.at (graph_node->output_id ()),
866
885
graph_node->flags ());
@@ -916,8 +935,10 @@ Error defineSigmoidNode(
916
935
MAYBE_UNUSED (graph);
917
936
918
937
auto graph_node = node->xnode_union_as_XNNSigmoid ();
919
- xnn_status status = xnn_define_sigmoid (
938
+ xnn_status status = xnn_define_unary (
920
939
subgraph_ptr,
940
+ xnn_unary_sigmoid,
941
+ nullptr ,
921
942
remapped_ids.at (graph_node->input_id ()),
922
943
remapped_ids.at (graph_node->output_id ()),
923
944
graph_node->flags ());
@@ -944,8 +965,10 @@ Error defineFloorNode(
944
965
MAYBE_UNUSED (graph);
945
966
946
967
auto graph_node = node->xnode_union_as_XNNFloor ();
947
- xnn_status status = xnn_define_floor (
968
+ xnn_status status = xnn_define_unary (
948
969
subgraph_ptr,
970
+ xnn_unary_floor,
971
+ nullptr ,
949
972
remapped_ids.at (graph_node->input_id ()),
950
973
remapped_ids.at (graph_node->output_id ()),
951
974
graph_node->flags ());
@@ -1167,10 +1190,14 @@ Error defineDivNode(
1167
1190
1168
1191
auto graph_node = node->xnode_union_as_XNNDiv ();
1169
1192
std::pair<float , float > min_max = getOutputMinMax (node);
1170
- xnn_status status = xnn_define_divide (
1193
+
1194
+ struct xnn_binary_params params = {
1195
+ .output_min = min_max.first , .output_max = min_max.second };
1196
+
1197
+ xnn_status status = xnn_define_binary (
1171
1198
subgraph_ptr,
1172
- min_max. first ,
1173
- min_max. second ,
1199
+ xnn_binary_divide ,
1200
+ ¶ms ,
1174
1201
remapped_ids.at (graph_node->input1_id ()),
1175
1202
remapped_ids.at (graph_node->input2_id ()),
1176
1203
remapped_ids.at (graph_node->output_id ()),
@@ -1415,8 +1442,10 @@ Error defineSquareRootNode(
1415
1442
1416
1443
auto graph_node = node->xnode_union_as_XNNSquareRoot ();
1417
1444
1418
- xnn_status status = xnn_define_square_root (
1445
+ xnn_status status = xnn_define_unary (
1419
1446
subgraph_ptr,
1447
+ xnn_unary_square_root,
1448
+ nullptr ,
1420
1449
remapped_ids.at (graph_node->input_id ()),
1421
1450
remapped_ids.at (graph_node->output_id ()),
1422
1451
graph_node->flags ());
@@ -1445,8 +1474,10 @@ Error defineReciprocalSquareRootNode(
1445
1474
1446
1475
auto graph_node = node->xnode_union_as_XNNReciprocalSquareRoot ();
1447
1476
1448
- xnn_status status = xnn_define_reciprocal_square_root (
1477
+ xnn_status status = xnn_define_unary (
1449
1478
subgraph_ptr,
1479
+ xnn_unary_reciprocal_square_root,
1480
+ nullptr ,
1450
1481
remapped_ids.at (graph_node->input_id ()),
1451
1482
remapped_ids.at (graph_node->output_id ()),
1452
1483
graph_node->flags ());
@@ -1475,8 +1506,10 @@ Error defineLogNode(
1475
1506
1476
1507
auto graph_node = node->xnode_union_as_XNNLog ();
1477
1508
1478
- xnn_status status = xnn_define_log (
1509
+ xnn_status status = xnn_define_unary (
1479
1510
subgraph_ptr,
1511
+ xnn_unary_log,
1512
+ nullptr ,
1480
1513
remapped_ids.at (graph_node->input_id ()),
1481
1514
remapped_ids.at (graph_node->output_id ()),
1482
1515
graph_node->flags ());
@@ -1505,8 +1538,10 @@ Error defineGeluNode(
1505
1538
1506
1539
auto graph_node = node->xnode_union_as_XNNGelu ();
1507
1540
1508
- xnn_status status = xnn_define_gelu (
1541
+ xnn_status status = xnn_define_unary (
1509
1542
subgraph_ptr,
1543
+ xnn_unary_gelu,
1544
+ nullptr ,
1510
1545
remapped_ids.at (graph_node->input_id ()),
1511
1546
remapped_ids.at (graph_node->output_id ()),
1512
1547
graph_node->flags ());
@@ -1535,8 +1570,10 @@ Error defineCeilingNode(
1535
1570
1536
1571
auto graph_node = node->xnode_union_as_XNNCeiling ();
1537
1572
1538
- xnn_status status = xnn_define_ceiling (
1573
+ xnn_status status = xnn_define_unary (
1539
1574
subgraph_ptr,
1575
+ xnn_unary_ceiling,
1576
+ nullptr ,
1540
1577
remapped_ids.at (graph_node->input_id ()),
1541
1578
remapped_ids.at (graph_node->output_id ()),
1542
1579
graph_node->flags ());
@@ -1565,8 +1602,10 @@ Error defineHardswishNode(
1565
1602
1566
1603
auto graph_node = node->xnode_union_as_XNNHardswish ();
1567
1604
1568
- xnn_status status = xnn_define_hardswish (
1605
+ xnn_status status = xnn_define_unary (
1569
1606
subgraph_ptr,
1607
+ xnn_unary_hardswish,
1608
+ nullptr ,
1570
1609
remapped_ids.at (graph_node->input_id ()),
1571
1610
remapped_ids.at (graph_node->output_id ()),
1572
1611
graph_node->flags ());
@@ -1595,9 +1634,13 @@ Error defineLeakyReLUNode(
1595
1634
1596
1635
auto graph_node = node->xnode_union_as_XNNLeakyReLU ();
1597
1636
1598
- xnn_status status = xnn_define_leaky_relu (
1637
+ union xnn_unary_params params = {
1638
+ .leaky_relu = {.negative_slope = graph_node->negative_slope ()}};
1639
+
1640
+ xnn_status status = xnn_define_unary (
1599
1641
subgraph_ptr,
1600
- graph_node->negative_slope (),
1642
+ xnn_unary_leaky_relu,
1643
+ ¶ms,
1601
1644
remapped_ids.at (graph_node->input_id ()),
1602
1645
remapped_ids.at (graph_node->output_id ()),
1603
1646
graph_node->flags ());
@@ -1626,8 +1669,10 @@ Error defineMaximumNode(
1626
1669
1627
1670
auto graph_node = node->xnode_union_as_XNNMaximum ();
1628
1671
1629
- xnn_status status = xnn_define_maximum2 (
1672
+ xnn_status status = xnn_define_binary (
1630
1673
subgraph_ptr,
1674
+ xnn_binary_maximum,
1675
+ nullptr ,
1631
1676
remapped_ids.at (graph_node->input1_id ()),
1632
1677
remapped_ids.at (graph_node->input2_id ()),
1633
1678
remapped_ids.at (graph_node->output_id ()),
@@ -1656,8 +1701,10 @@ Error defineNegateNode(
1656
1701
1657
1702
auto graph_node = node->xnode_union_as_XNNNegate ();
1658
1703
1659
- xnn_status status = xnn_define_negate (
1704
+ xnn_status status = xnn_define_unary (
1660
1705
subgraph_ptr,
1706
+ xnn_unary_negate,
1707
+ nullptr ,
1661
1708
remapped_ids.at (graph_node->input_id ()),
1662
1709
remapped_ids.at (graph_node->output_id ()),
1663
1710
graph_node->flags ());
@@ -1685,8 +1732,10 @@ Error defineSquareNode(
1685
1732
1686
1733
auto graph_node = node->xnode_union_as_XNNSquare ();
1687
1734
1688
- xnn_status status = xnn_define_square (
1735
+ xnn_status status = xnn_define_unary (
1689
1736
subgraph_ptr,
1737
+ xnn_unary_square,
1738
+ nullptr ,
1690
1739
remapped_ids.at (graph_node->input_id ()),
1691
1740
remapped_ids.at (graph_node->output_id ()),
1692
1741
graph_node->flags ());
@@ -1714,9 +1763,12 @@ Error defineELUNode(
1714
1763
1715
1764
auto graph_node = node->xnode_union_as_XNNELU ();
1716
1765
1717
- xnn_status status = xnn_define_elu (
1766
+ union xnn_unary_params params = {.elu = {.alpha = graph_node->alpha ()}};
1767
+
1768
+ xnn_status status = xnn_define_unary (
1718
1769
subgraph_ptr,
1719
- graph_node->alpha (),
1770
+ xnn_unary_elu,
1771
+ ¶ms,
1720
1772
remapped_ids.at (graph_node->input_id ()),
1721
1773
remapped_ids.at (graph_node->output_id ()),
1722
1774
graph_node->flags ());
@@ -1744,8 +1796,10 @@ Error defineAbsNode(
1744
1796
1745
1797
auto graph_node = node->xnode_union_as_XNNAbs ();
1746
1798
1747
- xnn_status status = xnn_define_abs (
1799
+ xnn_status status = xnn_define_unary (
1748
1800
subgraph_ptr,
1801
+ xnn_unary_abs,
1802
+ nullptr ,
1749
1803
remapped_ids.at (graph_node->input_id ()),
1750
1804
remapped_ids.at (graph_node->output_id ()),
1751
1805
graph_node->flags ());
0 commit comments