1#!/usr/bin/env fbpython 2# Copyright (c) Meta Platforms, Inc. and affiliates. 3# All rights reserved. 4# 5# This source code is licensed under the BSD-style license found in the 6# LICENSE file in the root directory of this source tree. 7 8import unittest 9 10import yaml 11from executorch.kernels.test.gen_supported_features import ( 12 generate_definition, 13 generate_header, 14) 15 16 17class TestGenSupportedFeatures(unittest.TestCase): 18 def test_gen_header(self): 19 y = yaml.load( 20 """ 21- namespace: global 22 is_aten: 23 type: bool 24 default: false 25 output_resize: 26 type: bool 27 default: true 28 29- namespace: op_gelu 30 dtype_double: 31 type: bool 32 default: true 33""", 34 Loader=yaml.FullLoader, 35 ) 36 result = generate_header(y) 37 self.assertTrue("bool is_aten = false;" in result) 38 self.assertTrue("bool output_resize = true;" in result) 39 self.assertTrue("bool op_gelu_dtype_double = true;" in result) 40 41 def test_gen_def(self): 42 y = yaml.load( 43 """ 44- namespace: global 45 output_resize: true 46 47- namespace: op_gelu 48 dtype_double: true 49""", 50 Loader=yaml.FullLoader, 51 ) 52 result = generate_definition(y) 53 self.assertTrue(".output_resize = true," in result) 54 self.assertTrue(".op_gelu_dtype_double = true," in result) 55 56 57if __name__ == "__main__": 58 unittest.main() 59