.. _op_ai_onnx_PRelu: PRelu ===== - **Domain**: ``ai.onnx`` - **Since version**: 16 PRelu takes input data (Tensor ) and slope tensor as input, and produces one output data (Tensor ) where the function ``f(x) = slope * x for x = 0``., is applied to the data tensor elementwise. **Inputs** - **X** (*T*): Input tensor - **slope** (*T*): Slope tensor. The shape of slope can be smaller than first input X; if so, its shape must be unidirectional broadcastable to X **Outputs** - **Y** (*T*): Output tensor (same size as X) **Type Constraints** - **T**: Constrain input and output types to float/int tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64), tensor(uint32), tensor(uint64). Examples -------- **test_cc_prelu** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(2, 3), dtype=float32 [[-3., -1., 0.], [ 1., 2., 3.]] slope: shape=(2, 3), dtype=float32 [[0.25, 0.5 , 0.75], [0.1 , 0.2 , 0.3 ]] Outputs: y: shape=(2, 3), dtype=float32 [[-0.75, -0.5 , 0. ], [ 1. , 2. , 3. ]] **test_cc_prelu_bcast** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(2, 3), dtype=float32 [[-1., -2., -3.], [ 1., 2., 3.]] slope: shape=(3,), dtype=float32 [0.1, 0.2, 0.3] Outputs: y: shape=(2, 3), dtype=float32 [[-0.1 , -0.4 , -0.90000004], [ 1. , 2. , 3. ]] **test_cc_prelu_empty_shape_scalars** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(), dtype=float32 2.5 slope: shape=(), dtype=float32 3.5 Outputs: y: shape=(), dtype=float32 2.5 **test_cc_prelu_empty_shape_zero_dim** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(0,), dtype=float32 [] slope: shape=(0,), dtype=float32 [] Outputs: y: shape=(0,), dtype=float32 [] **test_cc_prelu_empty_shape_zero_dim_2d** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(0, 3), dtype=float32 [] slope: shape=(0, 3), dtype=float32 [] Outputs: y: shape=(0, 3), dtype=float32 [] **test_cc_prelu_inf** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(4,), dtype=float32 [ inf, -inf, 5.0e+30, -2.5e+00] slope: shape=(4,), dtype=float32 [0.25, 0.5 , 0.25, 0.25] Outputs: y: shape=(4,), dtype=float32 [ inf, -inf, 5.00e+30, -6.25e-01] **test_prelu_broadcast** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(3, 4, 5), dtype=float32 [[[-0.62216586, 0.23071946, -0.44037476, 1.1018444 , 0.33993453], [ 0.6673572 , 0.23079044, -0.33776435, -0.7145624 , 0.23379254], [-0.87260103, -0.03636372, 0.3375118 , -0.56752586, 1.3069218 ], [ 0.23701055, -1.4519347 , 0.5864804 , -1.6773233 , 0.667711 ]], [[ 0.59248346, 0.25854757, 0.9993237 , -0.2519604 , 0.4396883 ], [-0.12366938, 1.5436682 , -1.5088953 , -0.02319983, -1.4253234 ], [-1.2474204 , -1.5215695 , 1.252772 , -1.7240764 , 0.42119765], [-0.7997555 , -0.5946146 , 0.34001034, 0.25650212, 0.39954498]], [[ 0.30716214, -0.5623004 , 1.3781636 , 0.5957701 , -0.3376929 ], [ 0.11759786, -1.637436 , 0.37568974, 2.3201282 , -0.38706338], [ 1.8695779 , 1.0533305 , -0.699427 , -1.2625815 , -0.61388 ], [ 0.7215071 , 0.21707447, 0.07948666, 0.6312519 , -0.6393902 ]]] slope: shape=(5,), dtype=float32 [ 0.9154805, -0.5188539, 1.3467076, -1.0085899, 1.2497014] Outputs: y: shape=(3, 4, 5), dtype=float32 [[[-0.56958073, 0.23071946, -0.593056 , 1.1018444 , 0.33993453], [ 0.6673572 , 0.23079044, -0.4548698 , 0.7207004 , 0.23379254], [-0.7988492 , 0.01886746, 0.3375118 , 0.5724008 , 1.3069218 ], [ 0.23701055, 0.753342 , 0.5864804 , 1.6917313 , 0.667711 ]], [[ 0.59248346, 0.25854757, 0.9993237 , 0.2541247 , 0.4396883 ], [-0.11321691, 1.5436682 , -2.0320406 , 0.02339911, -1.7812285 ], [-1.1419891 , 0.7894723 , 1.252772 , 1.738886 , 0.42119765], [-0.73216057, 0.3085181 , 0.34001034, 0.25650212, 0.39954498]], [[ 0.30716214, 0.29175174, 1.3781636 , 0.5957701 , -0.42201528], [ 0.11759786, 0.84959006, 0.37568974, 2.3201282 , -0.48371366], [ 1.8695779 , 1.0533305 , -0.9419237 , 1.2734269 , -0.7671667 ], [ 0.7215071 , 0.21707447, 0.07948666, 0.6312519 , -0.79904675]]] **test_prelu_example** .. code-block:: text Node: PRelu(x, slope) -> (y) .. code-block:: text Inputs: x: shape=(3, 4, 5), dtype=float32 [[[-0.7513602 , 0.51713336, 0.7695295 , -0.22347532, 0.18149193], [ 0.24913743, 1.994417 , -0.07321609, 0.1076815 , 2.7155633 ], [-0.47996232, 1.631689 , 0.49418923, -2.1702976 , 2.58957 ], [ 0.14372788, 0.06502817, 1.441035 , -0.6060344 , 1.2044882 ]], [[ 0.73592454, -1.4978608 , -1.3068415 , 2.285458 , 0.94369376], [ 0.24891663, -1.1944486 , -0.20609704, -2.257049 , -1.3082974 ], [ 1.7855092 , -0.24503152, 0.6468487 , 0.05505385, 0.0182795 ], [-0.18279839, 0.14583768, -1.6932459 , 2.7747114 , -0.18945445]], [[-0.8139422 , -0.83692306, -1.5865561 , -1.0409492 , -0.04504394], [-0.3157502 , 0.20416091, 0.6947444 , -0.93289083, 0.02533321], [-0.7196668 , -2.7953355 , 1.6615764 , -1.6629553 , -1.2022487 ], [ 1.0108496 , -0.98562527, 0.70152247, 0.48280644, -0.1113701 ]]] slope: shape=(3, 4, 5), dtype=float32 [[[-1.0029005 , 1.0619555 , -0.30622792, -0.5332439 , 1.4375478 ], [ 1.2071373 , -0.6458864 , 0.8300795 , 0.21273202, -0.7806308 ], [-0.40428525, 0.6376805 , 1.1788383 , -0.4927185 , 2.5766451 ], [-1.7393267 , -1.0279831 , -0.6508921 , -2.7996702 , 0.2743459 ]], [[ 0.78074443, 1.0220166 , -0.2684288 , 0.6771564 , -0.21049254], [ 0.6646813 , -1.1061122 , 1.5222495 , -2.4748578 , 0.76601636], [ 0.05163119, 1.052501 , -0.36132503, -0.23450962, 0.11239426], [ 2.8382437 , 1.5054117 , -0.7077736 , -0.50181675, 2.6686907 ]], [[ 0.13030747, -0.88599855, -0.22711682, 0.37078258, -0.25641453], [-1.1376325 , 0.06863393, 0.33454004, 0.8406287 , -1.4702488 ], [ 0.20493318, -1.3650485 , 0.04658019, 0.7189073 , -1.0817056 ], [-1.1260862 , -2.0177746 , -0.2981477 , 0.33546326, 0.69503844]]] Outputs: y: shape=(3, 4, 5), dtype=float32 [[[ 0.7535395 , 0.51713336, 0.7695295 , 0.11916685, 0.18149193], [ 0.24913743, 1.994417 , -0.06077517, 0.1076815 , 2.7155633 ], [ 0.19404168, 1.631689 , 0.49418923, 1.0693457 , 2.58957 ], [ 0.14372788, 0.06502817, 1.441035 , 1.6966964 , 1.2044882 ]], [[ 0.73592454, -1.5308386 , 0.3507939 , 2.285458 , 0.94369376], [ 0.24891663, 1.3211942 , -0.3137311 , 5.5858755 , -1.0021772 ], [ 1.7855092 , -0.25789592, 0.6468487 , 0.05505385, 0.0182795 ], [-0.51882637, 0.14583768, 1.1984348 , 2.7747114 , -0.5055953 ]], [[-0.10606275, 0.7415126 , 0.36033356, -0.38596585, 0.01154992], [ 0.3592077 , 0.20416091, 0.6947444 , -0.7842148 , 0.02533321], [-0.1474836 , 3.8157687 , 1.6615764 , -1.1955107 , 1.300479 ], [ 1.0108496 , 1.9887697 , 0.70152247, 0.48280644, -0.0774065 ]]] Differences with previous version (9) ------------------------------------- **SchemaDiff**: ``PRelu`` (domain ``'ai.onnx'``) * old version: 9 * new version: 16 * breaking: no **Type constraints:** * changed 'T': added types: ['tensor(bfloat16)'] Version History --------------- - :doc:`Version 9 ` - :doc:`Version 7 ` - :doc:`Version 6 ` - :doc:`Version 1 `