1# Copyright (c) Meta Platforms, Inc. and affiliates. 2# All rights reserved. 3# 4# This source code is licensed under the BSD-style license found in the 5# LICENSE file in the root directory of this source tree. 6 7from executorch.extension.gguf_util.load_gguf import GGUFModelArgs, GGUFWeights 8 9 10def convert_to_pte(model_args: GGUFModelArgs, weights: GGUFWeights) -> None: 11 """Convert a GGUF model into a PTE file, an ExecuTorch program. 12 13 Args: 14 model_args: The arguments for the GGUF model. 15 weights: The weights of the GGUF model. 16 """ 17 18 # Switch statement based on the architecture enum. 19 # Each enum has its own converter function. 20 if model_args.arch == "llama": 21 from executorch.extension.gguf_util.converters.llama_converter import ( 22 convert_to_pte as llama_convert_to_pte, 23 ) 24 25 return llama_convert_to_pte(model_args, weights) 26 else: 27 raise NotImplementedError("Unsupported architecture.") 28