44# LICENSE file in the root directory of this source tree.
55
66import os
7+ from typing import Tuple
78
89os .environ .setdefault ("HF_HUB_DISABLE_XET" , "1" )
910
1011import pytest
12+
1113import torch
1214
1315from executorch .backends .arm .test import common
1416from executorch .backends .arm .test .tester .test_pipeline import (
17+ TosaPipelineFP ,
1518 TosaPipelineINT ,
1619 VgfPipeline ,
1720)
2023 NFRUAutoEncoder ,
2124)
2225
26+ input_t = Tuple [torch .Tensor ] # Input x
2327
2428_RELEASE_REFS = (
2529 os .environ .get ("GITHUB_REF" , "" ),
3842
3943
4044def nfru () -> NFRUAutoEncoder :
45+ """Get an instance of NFRU with FP32 weights loaded."""
4146 weights = hf_hub_download ( # nosec B615
4247 repo_id = "Arm/neural-frame-rate-upscaling" ,
4348 filename = "nfru_v1_fp32.pt" ,
@@ -60,6 +65,85 @@ def nfru() -> NFRUAutoEncoder:
6065 return model
6166
6267
68+ def example_inputs (memory_format : torch .memory_format = torch .channels_last ):
69+ return (torch .randn ((1 , 16 , 270 , 480 )).to (memory_format = memory_format ),)
70+
71+
72+ def test_nfru_tosa_FP ():
73+ pipeline = TosaPipelineFP [input_t ](
74+ nfru ().eval (),
75+ example_inputs (),
76+ aten_op = [],
77+ exir_op = [],
78+ )
79+ pipeline .run ()
80+
81+
82+ def test_nfru_tosa_INT ():
83+ pipeline = TosaPipelineINT [input_t ](
84+ nfru ().eval (),
85+ example_inputs (),
86+ aten_op = [],
87+ exir_op = [],
88+ atol = 0.2 ,
89+ )
90+ pipeline .run ()
91+
92+
93+ def test_nfru_tosa_INT_a16w8 ():
94+ pipeline = TosaPipelineINT [input_t ](
95+ nfru ().eval (),
96+ example_inputs (),
97+ aten_op = [],
98+ exir_op = [],
99+ tosa_extensions = ["int16" ],
100+ atol = 0.1 ,
101+ )
102+ pipeline .run ()
103+
104+
105+ @common .SkipIfNoModelConverter
106+ def test_nfru_vgf_no_quant ():
107+ pipeline = VgfPipeline [input_t ](
108+ nfru ().eval (),
109+ example_inputs (),
110+ aten_op = [],
111+ exir_op = [],
112+ tosa_version = "TOSA-1.0+FP" ,
113+ quantize = False ,
114+ )
115+ pipeline .run ()
116+
117+
118+ @common .SkipIfNoModelConverter
119+ def test_nfru_vgf_quant ():
120+ pipeline = VgfPipeline [input_t ](
121+ nfru ().eval (),
122+ example_inputs (),
123+ aten_op = [],
124+ exir_op = [],
125+ tosa_version = "TOSA-1.0+INT" ,
126+ symmetric_io_quantization = True ,
127+ atol = 0.2 ,
128+ )
129+ pipeline .run ()
130+
131+
132+ @common .SkipIfNoModelConverter
133+ def test_nfru_vgf_quant_a16w8 ():
134+ pipeline = VgfPipeline [input_t ](
135+ nfru ().eval (),
136+ example_inputs (),
137+ aten_op = [],
138+ exir_op = [],
139+ tosa_version = "TOSA-1.0+INT" ,
140+ tosa_extensions = ["int16" ],
141+ symmetric_io_quantization = True ,
142+ atol = 0.2 ,
143+ )
144+ pipeline .run ()
145+
146+
63147def test_nfru_qat_tosa_INT () -> None :
64148 pipeline = TosaPipelineINT (
65149 nfru (),
0 commit comments