1- # Copyright 2025 Arm Limited and/or its affiliates.
1+ # Copyright 2025-2026 Arm Limited and/or its affiliates.
22#
33# This source code is licensed under the BSD-style license found in the
44# LICENSE file in the root directory of this source tree.
2121
2222
2323class LeakyReLU (torch .nn .Module ):
24- def __init__ (self , slope : float = 0.01 ):
24+ def __init__ (self , slope : float = 0.01 , inplace : bool = True ):
2525 super ().__init__ ()
26- self .activation = torch .nn .LeakyReLU (slope )
26+ self .activation = torch .nn .LeakyReLU (slope , inplace = inplace )
2727
2828 def forward (self , x : torch .Tensor ):
2929 return self .activation (x )
3030
3131 test_data : dict [str , input_t1 ] = {
32- "zeros" : lambda : ((torch .zeros (1 , 1 , 5 , 5 ),), 0.01 ),
33- "ones" : lambda : ((torch .ones (1 , 16 , 96 , 96 ),), 0.01 ),
34- "rand" : lambda : ((torch .rand (1 , 64 , 56 , 56 ),), 0.2 ),
35- "3Dtensor" : lambda : ((torch .rand (5 , 5 , 5 ),), 0.001 ),
36- "negative_slope" : lambda : ((torch .rand (1 , 16 , 96 , 96 ),), - 0.002 ),
32+ "zeros" : lambda : ((torch .zeros (1 , 1 , 5 , 5 ),), 0.01 , True ),
33+ "ones" : lambda : ((torch .ones (1 , 16 , 96 , 96 ),), 0.01 , False ),
34+ "rand" : lambda : ((torch .rand (1 , 64 , 56 , 56 ),), 0.2 , False ),
35+ "3Dtensor" : lambda : ((torch .rand (5 , 5 , 5 ),), 0.001 , True ),
36+ "negative_slope" : lambda : ((torch .rand (1 , 16 , 96 , 96 ),), - 0.002 , True ),
3737 }
3838
3939
4040@common .parametrize ("test_data" , LeakyReLU .test_data )
4141def test_leaky_relu_tosa_FP (test_data ):
42- data , slope = test_data ()
42+ data , slope , inplace = test_data ()
4343 pipeline = TosaPipelineFP [input_t1 ](
44- LeakyReLU (slope ),
44+ LeakyReLU (slope , inplace ),
4545 data ,
4646 [],
4747 use_to_edge_transform_and_lower = True ,
@@ -54,9 +54,9 @@ def test_leaky_relu_tosa_FP(test_data):
5454
5555@common .parametrize ("test_data" , LeakyReLU .test_data )
5656def test_leaky_relu_tosa_INT (test_data ):
57- data , slope = test_data ()
57+ data , slope , inplace = test_data ()
5858 pipeline = TosaPipelineINT [input_t1 ](
59- LeakyReLU (slope ),
59+ LeakyReLU (slope , inplace ),
6060 data ,
6161 [],
6262 use_to_edge_transform_and_lower = True ,
@@ -68,9 +68,9 @@ def test_leaky_relu_tosa_INT(test_data):
6868@common .parametrize ("test_data" , LeakyReLU .test_data )
6969@common .XfailIfNoCorstone300
7070def test_leaky_relu_u55_INT (test_data ):
71- data , slope = test_data ()
71+ data , slope , inplace = test_data ()
7272 pipeline = EthosU55PipelineINT [input_t1 ](
73- LeakyReLU (slope ),
73+ LeakyReLU (slope , inplace ),
7474 data ,
7575 [],
7676 use_to_edge_transform_and_lower = True ,
@@ -82,9 +82,9 @@ def test_leaky_relu_u55_INT(test_data):
8282@common .parametrize ("test_data" , LeakyReLU .test_data )
8383@common .XfailIfNoCorstone320
8484def test_leaky_relu_u85_INT (test_data ):
85- data , slope = test_data ()
85+ data , slope , inplace = test_data ()
8686 pipeline = EthosU85PipelineINT [input_t1 ](
87- LeakyReLU (slope ),
87+ LeakyReLU (slope , inplace ),
8888 data ,
8989 [],
9090 use_to_edge_transform_and_lower = True ,
@@ -96,9 +96,9 @@ def test_leaky_relu_u85_INT(test_data):
9696@common .parametrize ("test_data" , LeakyReLU .test_data )
9797@common .SkipIfNoModelConverter
9898def test_leaky_relu_vgf_no_quant (test_data ):
99- data , slope = test_data ()
99+ data , slope , inplace = test_data ()
100100 pipeline = VgfPipeline [input_t1 ](
101- LeakyReLU (slope ),
101+ LeakyReLU (slope , inplace ),
102102 data ,
103103 [],
104104 use_to_edge_transform_and_lower = True ,
@@ -113,9 +113,9 @@ def test_leaky_relu_vgf_no_quant(test_data):
113113@common .parametrize ("test_data" , LeakyReLU .test_data )
114114@common .SkipIfNoModelConverter
115115def test_leaky_relu_vgf_quant (test_data ):
116- data , slope = test_data ()
116+ data , slope , inplace = test_data ()
117117 pipeline = VgfPipeline [input_t1 ](
118- LeakyReLU (slope ),
118+ LeakyReLU (slope , inplace ),
119119 data ,
120120 [],
121121 use_to_edge_transform_and_lower = True ,
0 commit comments