.. _op_ai_onnx_Div: Div === - **Domain**: ``ai.onnx`` - **Since version**: 14 Performs element-wise binary division (with Numpy-style broadcasting support). This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the broadcasting behavior in ONNX. For integer inputs, the result is computed using truncating division (rounding toward zero). **Inputs** - **A** (*T*): First operand. - **B** (*T*): Second operand. **Outputs** - **C** (*T*): Result, has same element type as two inputs **Type Constraints** - **T**: Constrain input and output types to all numeric tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8). Examples -------- **test_cc_div** .. code-block:: text Inputs: x: shape=(2, 3), dtype=float32 [[10., 20., 30.], [40., 50., 60.]] y: shape=(2, 3), dtype=float32 [[ 2., 4., 5.], [ 8., 10., 12.]] Outputs: z: shape=(2, 3), dtype=float32 [[5., 5., 6.], [5., 5., 5.]] **test_cc_div_bcast** .. code-block:: text Inputs: x: shape=(2, 2), dtype=float32 [[1., 2.], [3., 4.]] y: shape=(), dtype=float32 2. Outputs: z: shape=(2, 2), dtype=float32 [[0.5, 1. ], [1.5, 2. ]] **test_div** .. code-block:: text Inputs: x: shape=(3, 4, 5), dtype=float32 [[[-1.049021 , -0.1805252 , 0.37299186, -1.2512525 , -0.81569797], [-0.51167107, 0.58341527, -0.28096995, 0.2715433 , 1.9851228 ], [-0.78261596, -0.520758 , -0.79341817, -1.150229 , -0.08576501], [-1.2088639 , -0.6402479 , -0.5225338 , -1.3520603 , 0.02162574]], [[-0.4249209 , 1.0771086 , 1.4951609 , 0.90683544, -1.0156072 ], [ 0.37091243, 0.12427244, -0.29227057, -0.12246624, 1.5876821 ], [ 1.2864141 , -1.5520498 , -0.9380287 , -1.4733943 , -2.022197 ], [ 0.86833507, -0.7941745 , -1.3814762 , 0.21208183, -1.630374 ]], [[-0.03658122, -1.3079208 , 0.38689163, 0.39617118, -0.36848107], [-0.37426245, 1.1562018 , 0.26353467, 1.0308264 , 0.49909028], [-0.39126182, -0.20753261, -0.29138264, 0.8988023 , 0.23219402], [-0.5025339 , -0.8213971 , -0.00865438, -0.06307457, -0.30020058]]] y: shape=(3, 4, 5), dtype=float32 [[[1.5357083, 1.8058548, 1.452791 , 1.5595028, 1.1919273], [1.5022644, 1.0285268, 1.2006115, 1.0872525, 1.5033492], [1.91171 , 1.0404063, 1.539953 , 1.4004827, 1.4956635], [1.9724481, 1.3472846, 1.9810288, 1.9347854, 1.7963282]], [[1.2332932, 1.7613184, 1.6210763, 1.444618 , 1.8672727], [1.497163 , 1.4243505, 1.1764996, 1.166526 , 1.197805 ], [1.246526 , 1.7593678, 1.2666925, 1.2551589, 1.4532425], [1.7616735, 1.5010916, 1.3315657, 1.9084283, 1.3779802]], [[1.5801901, 1.3586056, 1.2933483, 1.2460475, 1.9181892], [1.6862582, 1.4296997, 1.5208707, 1.4980319, 1.7667483], [1.1650997, 1.3381588, 1.7704554, 1.1649324, 1.1307691], [1.678083 , 1.2587595, 1.1164734, 1.0768781, 1.2795889]]] Outputs: z: shape=(3, 4, 5), dtype=float32 [[[-0.6830861 , -0.09996662, 0.25674158, -0.8023406 , -0.6843521 ], [-0.34059986, 0.5672339 , -0.23402238, 0.24975182, 1.3204669 ], [-0.40938005, -0.5005333 , -0.5152223 , -0.821309 , -0.05734245], [-0.61287487, -0.47521356, -0.26376888, -0.6988167 , 0.01203886]], [[-0.34454167, 0.61153543, 0.922326 , 0.6277337 , -0.5438987 ], [ 0.24774352, 0.0872485 , -0.24842386, -0.10498372, 1.325493 ], [ 1.0319995 , -0.88216335, -0.7405338 , -1.1738707 , -1.3915069 ], [ 0.49290353, -0.52906466, -1.0374825 , 0.11112905, -1.1831621 ]], [[-0.02314989, -0.9626935 , 0.29913956, 0.3179423 , -0.1920984 ], [-0.22194849, 0.8087026 , 0.17327881, 0.6881205 , 0.28249088], [-0.3358183 , -0.15508817, -0.16458061, 0.77154887, 0.20534167], [-0.29946905, -0.6525449 , -0.00775153, -0.0585717 , -0.23460704]]] **test_div_bcast** .. code-block:: text Inputs: x: shape=(3, 4, 5), dtype=float32 [[[ 0.31121665, 1.0258594 , -3.1395116 , -1.7966223 , 0.06096684], [ 0.70985043, -0.19639817, -2.1368458 , -1.3620541 , -1.0705928 ], [ 1.3230867 , 0.44482955, -1.9483898 , -0.28574938, -1.1584307 ], [-0.8643142 , -0.02712508, -1.7259822 , -0.15632714, 0.911871 ]], [[-0.79225 , -0.60901046, -1.0763875 , -0.21682826, -0.0795441 ], [ 0.02737821, -1.2745905 , -0.7107443 , -0.67446405, -0.4757256 ], [-1.7844657 , -0.91062653, 2.4688623 , -1.4964907 , -0.01263986], [ 0.4145471 , -2.1071372 , 0.9477474 , -0.739947 , -0.24369246]], [[ 0.82412815, 0.36990932, -0.1963979 , 0.31643096, 2.1840649 ], [ 0.366072 , -1.5286286 , -0.5150546 , 1.3649099 , -0.9546026 ], [ 0.5755407 , 1.6345203 , -1.6135515 , 1.4676467 , -0.73048383], [-0.44720328, -0.7687108 , -0.48270035, -0.4476123 , 1.1505837 ]]] y: shape=(5,), dtype=float32 [1.9128889, 1.3388335, 1.2953714, 1.350092 , 1.5780545] Outputs: z: shape=(3, 4, 5), dtype=float32 [[[ 0.16269457, 0.76623374, -2.423638 , -1.3307406 , 0.03863418], [ 0.37108818, -0.1466935 , -1.6496009 , -1.0088602 , -0.6784257 ], [ 0.6916694 , 0.3322516 , -1.5041167 , -0.21165177, -0.7340879 ], [-0.45183712, -0.02026024, -1.3324226 , -0.11578999, 0.57784504]], [[-0.41416413, -0.45488143, -0.83094895, -0.16060257, -0.05040643], [ 0.01431249, -0.9520157 , -0.54867995, -0.49956894, -0.30146334], [-0.93286425, -0.68016416, 1.9059107 , -1.1084361 , -0.00800977], [ 0.21671258, -1.5738606 , 0.7316415 , -0.5480715 , -0.15442587]], [[ 0.43082908, 0.27629226, -0.15161513, 0.23437732, 1.3840237 ], [ 0.19137128, -1.1417615 , -0.3976115 , 1.0109755 , -0.6049237 ], [ 0.30087516, 1.220854 , -1.2456285 , 1.0870715 , -0.4629015 ], [-0.23378424, -0.5741646 , -0.3726347 , -0.33154204, 0.7291153 ]]] **test_div_example** .. code-block:: text Inputs: x: shape=(2,), dtype=float32 [3., 4.] y: shape=(2,), dtype=float32 [1., 2.] Outputs: z: shape=(2,), dtype=float32 [3., 2.] Differences with previous version (13) -------------------------------------- **SchemaDiff**: ``Div`` (domain ``'ai.onnx'``) * old version: 13 * new version: 14 * breaking: no **Type constraints:** * changed 'T': added types: ['tensor(int16)', 'tensor(int8)', 'tensor(uint16)', 'tensor(uint8)'] Version History --------------- - :doc:`Version 13 ` - :doc:`Version 7 ` - :doc:`Version 6 ` - :doc:`Version 1 `