|
1 | 1 | load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target") |
| 2 | +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") |
2 | 3 | load(":targets.bzl", "define_common_targets") |
3 | 4 |
|
4 | 5 | oncall("executorch") |
5 | 6 |
|
6 | 7 | non_fbcode_target(_kind = define_common_targets,) |
7 | 8 |
|
8 | 9 | fbcode_target(_kind = define_common_targets,) |
| 10 | + |
| 11 | +# Text decoder module |
| 12 | +fbcode_target(_kind = runtime.python_library, |
| 13 | + name = "text_decoder", |
| 14 | + srcs = [ |
| 15 | + "text_decoder/__init__.py", |
| 16 | + "text_decoder/convert_weights.py", |
| 17 | + "text_decoder/gemma4_attention.py", |
| 18 | + "text_decoder/gemma4_config.py", |
| 19 | + "text_decoder/gemma4_cross_decoder.py", |
| 20 | + "text_decoder/gemma4_decoder_layer.py", |
| 21 | + "text_decoder/gemma4_model.py", |
| 22 | + "text_decoder/gemma4_self_decoder.py", |
| 23 | + "text_decoder/gemma4_transformer.py", |
| 24 | + ], |
| 25 | + _is_external_target = True, |
| 26 | + base_module = "executorch.examples.models.gemma4", |
| 27 | + resources = { |
| 28 | + "config/e2b_config.json": "config/e2b_config.json", |
| 29 | + "config/e4b_config.json": "config/e4b_config.json", |
| 30 | + }, |
| 31 | + deps = [ |
| 32 | + "//caffe2:torch", |
| 33 | + "fbsource//third-party/pypi/safetensors:safetensors", |
| 34 | + "fbsource//third-party/pypi/transformers:transformers", |
| 35 | + ], |
| 36 | + visibility = ["PUBLIC"], |
| 37 | +) |
| 38 | + |
| 39 | +# Speech transform module |
| 40 | +fbcode_target(_kind = runtime.python_library, |
| 41 | + name = "speech_transform", |
| 42 | + srcs = [ |
| 43 | + "speech_transform.py", |
| 44 | + ], |
| 45 | + _is_external_target = True, |
| 46 | + base_module = "executorch.examples.models.gemma4", |
| 47 | + deps = [ |
| 48 | + "//caffe2:torch", |
| 49 | + ], |
| 50 | + visibility = ["PUBLIC"], |
| 51 | +) |
| 52 | + |
| 53 | +# Export utilities (shared quantization code) |
| 54 | +fbcode_target(_kind = runtime.python_library, |
| 55 | + name = "quant_utils", |
| 56 | + srcs = ["quant_utils.py"], |
| 57 | + _is_external_target = True, |
| 58 | + base_module = "executorch.examples.models.gemma4", |
| 59 | + deps = [ |
| 60 | + "//caffe2:torch", |
| 61 | + "//executorch/examples/models/llama:source_transformation", |
| 62 | + "//executorch/extension/llm/export:export_lib", |
| 63 | + "//pytorch/ao:torchao", |
| 64 | + ], |
| 65 | + visibility = ["PUBLIC"], |
| 66 | +) |
| 67 | + |
| 68 | +# Single PTE export |
| 69 | +fbcode_target(_kind = runtime.python_binary, |
| 70 | + name = "export_gemma4", |
| 71 | + srcs = ["export_gemma4.py"], |
| 72 | + main_function = "executorch.examples.models.gemma4.export_gemma4.main", |
| 73 | + preload_deps = [ |
| 74 | + "//pytorch/ao/torchao/csrc/cpu/shared_kernels/linear_8bit_act_xbit_weight:op_linear_8bit_act_xbit_weight_aten", |
| 75 | + "//pytorch/ao/torchao/csrc/cpu/shared_kernels/embedding_xbit:op_embedding_xbit_aten", |
| 76 | + "//executorch/extension/llm/custom_ops:custom_ops_aot_lib", |
| 77 | + "//executorch/kernels/quantized:aot_lib", |
| 78 | + ], |
| 79 | + deps = [ |
| 80 | + ":text_decoder", |
| 81 | + ":speech_transform", |
| 82 | + ":quant_utils", |
| 83 | + "//caffe2:torch", |
| 84 | + "//executorch/exir:lib", |
| 85 | + "//executorch/backends/xnnpack/partition:xnnpack_partitioner", |
| 86 | + "//executorch/backends/xnnpack/quantizer:xnnpack_quantizer", |
| 87 | + "//executorch/extension/llm/export:export_lib", |
| 88 | + "//executorch/extension/llm/custom_ops:custom_ops_aot_lib", |
| 89 | + "//executorch/extension/llm/custom_ops:custom_ops_aot_py", |
| 90 | + "//executorch/kernels/quantized:aot_lib", |
| 91 | + "//pytorch/ao:torchao", |
| 92 | + "fbsource//third-party/pypi/safetensors:safetensors", |
| 93 | + "fbsource//third-party/pypi/transformers:transformers", |
| 94 | + ], |
| 95 | +) |
| 96 | + |
| 97 | +# Image preprocessing utilities |
| 98 | +fbcode_target(_kind = runtime.python_library, |
| 99 | + name = "image_utils", |
| 100 | + srcs = ["image_utils.py"], |
| 101 | + _is_external_target = True, |
| 102 | + base_module = "executorch.examples.models.gemma4", |
| 103 | + deps = [ |
| 104 | + "//caffe2:torch", |
| 105 | + "fbsource//third-party/pypi/pillow:pillow", |
| 106 | + ], |
| 107 | + visibility = ["PUBLIC"], |
| 108 | +) |
| 109 | + |
| 110 | +# Python runner (single PTE, audio + vision + text-only) |
| 111 | +fbcode_target(_kind = runtime.python_binary, |
| 112 | + name = "run_gemma4", |
| 113 | + srcs = ["run_gemma4.py"], |
| 114 | + main_function = "executorch.examples.models.gemma4.run_gemma4.main", |
| 115 | + preload_deps = [ |
| 116 | + "//executorch/backends/xnnpack:xnnpack_backend", |
| 117 | + "//executorch/extension/llm/custom_ops:custom_ops_aot_lib", |
| 118 | + "//executorch/kernels/quantized:aot_lib", |
| 119 | + "//pytorch/ao/torchao/csrc/cpu/shared_kernels/embedding_xbit:op_embedding_xbit_aten", |
| 120 | + "//pytorch/ao/torchao/csrc/cpu/shared_kernels/linear_8bit_act_xbit_weight:op_linear_8bit_act_xbit_weight_aten", |
| 121 | + ], |
| 122 | + deps = [ |
| 123 | + ":image_utils", |
| 124 | + "//caffe2:torch", |
| 125 | + "//executorch/runtime:runtime", |
| 126 | + "fbsource//third-party/pypi/sentencepiece:sentencepiece", |
| 127 | + ], |
| 128 | +) |
0 commit comments