• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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  */
8 
9 package com.example.executorchllamademo;
10 
11 public class ModelUtils {
12   // XNNPACK or QNN
13   static final int TEXT_MODEL = 1;
14 
15   // XNNPACK
16   static final int VISION_MODEL = 2;
17   static final int VISION_MODEL_IMAGE_CHANNELS = 3;
18   static final int VISION_MODEL_SEQ_LEN = 768;
19   static final int TEXT_MODEL_SEQ_LEN = 256;
20 
21   // MediaTek
22   static final int MEDIATEK_TEXT_MODEL = 3;
23 
getModelCategory(ModelType modelType, BackendType backendType)24   public static int getModelCategory(ModelType modelType, BackendType backendType) {
25     if (backendType.equals(BackendType.XNNPACK)) {
26       switch (modelType) {
27         case LLAVA_1_5:
28           return VISION_MODEL;
29         case LLAMA_3:
30         case LLAMA_3_1:
31         case LLAMA_3_2:
32         default:
33           return TEXT_MODEL;
34       }
35     } else if (backendType.equals(BackendType.MEDIATEK)) {
36       return MEDIATEK_TEXT_MODEL;
37     }
38 
39     return TEXT_MODEL; // default
40   }
41 }
42