Skip to content
68 changes: 68 additions & 0 deletions .github/workflows/export-stories-model.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Export Stories Model

on:
pull_request:
workflow_dispatch:
schedule:
- cron: '0 10 * * *'

jobs:
export-mv3-model:
name: export-mv3-model
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
id-token: write
contents: read
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install executorch
run: |
pip install torchvision executorch

- name: Export model to PTE
run: |
cat <<EOF > export_mv3.py
import torch
import torchvision.models as models
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import to_edge_transform_and_lower
def main() -> None:
model = models.mobilenet_v3_large(weights='DEFAULT').eval()
sample_inputs = (torch.randn(1, 3, 224, 224), )
et_program = to_edge_transform_and_lower(
torch.export.export(model, sample_inputs),
partitioner=[XnnpackPartitioner()],
).to_executorch()
with open("mv3_xnnpack_fp32.pte", "wb") as file:
et_program.write_to_file(file)
if __name__ == "__main__":
main()
EOF

python export_mv3.py

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: mv3-pte
path: |
mv3_xnnpack_fp32.pte

- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-android
aws-region: us-east-1

- name: Upload to S3
run: |
pip install awscli==1.32.18

VERSION="snapshot-$(date +"%Y%m%d")"

aws s3 cp mv3_xnnpack_fp32.pte s3://ossci-android/executorch/models/${VERSION}/mv3_xnnpack_fp32.pte --acl public-read
Loading