-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exportable baby llama example (#4345)
Summary: Add a small LLaMa model, based on the babyllama paper. Note that this test case is only one layer by default, and the number of layers can be adjusted in the test. Removed some pyre changes that broke the OSS AoT export, and added some required passes and operators. Differential Revision: D60073137
- Loading branch information
1 parent
fd2dccf
commit f623ca8
Showing
6 changed files
with
171 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# All rights reserved. | ||
# | ||
# This source code is licensed under the BSD-style license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
# Example script for exporting simple models to flatbuffer | ||
|
||
import logging | ||
|
||
from executorch.backends.cadence.aot.ops_registrations import * # noqa | ||
|
||
import torch | ||
|
||
from executorch.backends.cadence.aot.export_example import export_model | ||
|
||
from executorch.examples.models.llama2.llama_transformer import ModelArgs, Transformer | ||
|
||
|
||
FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s" | ||
logging.basicConfig(level=logging.INFO, format=FORMAT) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
args = ModelArgs( | ||
dim=512, | ||
vocab_size=512, | ||
hidden_dim=1024, | ||
n_heads=8, | ||
# use_kv_cache=True, | ||
n_layers=1, | ||
) | ||
seq = 64 | ||
b = 1 | ||
model = Transformer(args) | ||
example_inputs = (torch.randint(0, 10, [b, seq], dtype=torch.int64),) | ||
|
||
export_model(model, example_inputs) |