Skip to content

Commit 7072212

Browse files
author
pytorchbot
committed
2024-10-31 nightly release (f813b6a)
1 parent c464a71 commit 7072212

File tree

75 files changed

+3987
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3987
-434
lines changed

.github/workflows/_android.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ jobs:
6666
# avoid permission issue
6767
sudo chown -R "${USER}" /opt/android
6868
69+
- name: Download Artifacts
70+
shell: bash
71+
run: |
72+
set -eux
73+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
74+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
75+
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
76+
unzip model.zip
77+
mv *.pte model.pte
78+
6979
- name: Gradle cache
7080
uses: gradle/actions/setup-gradle@v3
7181

.github/workflows/pull.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ jobs:
9999
submodules: 'true'
100100
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
101101
timeout: 900
102+
upload-artifact: android-models
103+
upload-artifact-to-s3: true
102104
script: |
103105
# The generic Linux job chooses to use base env, not the one setup by the image
104106
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -107,13 +109,15 @@ jobs:
107109
DTYPE=${{ matrix.dtype }}
108110
BUILD_TOOL="cmake"
109111
MODE=${{ matrix.mode }}
112+
ARTIFACTS_DIR_NAME="artifacts-to-be-uploaded/${DTYPE}-${MODE}"
113+
ARTIFACTS_DIR_NAME="${ARTIFACTS_DIR_NAME/+/-}"
110114
111115
# Setup executorch
112116
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
113117
# Install requirements for export_llama
114118
PYTHON_EXECUTABLE=python bash examples/models/llama/install_requirements.sh
115119
# Test llama2
116-
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}"
120+
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llama.sh stories110M "${BUILD_TOOL}" "${DTYPE}" "${MODE}" "${ARTIFACTS_DIR_NAME}"
117121
118122
test-llama-runner-linux-android:
119123
name: test-llama-runner-linux-android
@@ -320,6 +324,7 @@ jobs:
320324
321325
android:
322326
uses: ./.github/workflows/_android.yml
327+
needs: test-llama-runner-linux
323328

324329
unittest:
325330
uses: ./.github/workflows/_unittest.yml

backends/apple/coreml/compiler/coreml_preprocess.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,15 @@ def preprocess(
425425
CoreMLBackend.op_linear_quantizer_config_from_compile_specs(compile_specs)
426426
)
427427

428+
# Load the model if MODEL_TYPE is 'COMPILED_MODEL'. This step is necessary because
429+
# get_compiled_model_path() requires a loaded model.
430+
skip_model_load = model_type != CoreMLBackend.MODEL_TYPE.COMPILED_MODEL
428431
mlmodel = ct.convert(
429432
model=edge_program,
430433
source="pytorch",
431434
convert_to="mlprogram",
432435
pass_pipeline=ct.PassPipeline.DEFAULT,
433-
skip_model_load=True,
436+
skip_model_load=skip_model_load,
434437
compute_precision=model_compute_precision,
435438
minimum_deployment_target=minimum_deployment_target,
436439
compute_units=compute_units,

backends/apple/coreml/runtime/delegate/backend_delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BackendDelegate {
2828
// Max models cache size in bytes.
2929
size_t max_models_cache_size = 10 * size_t(1024) * size_t(1024) * size_t(1024);
3030
// If set to `true`, delegate pre-warms the most recently used asset.
31-
bool should_prewarm_asset = true;
31+
bool should_prewarm_asset = false;
3232
// If set to `true`, delegate pre-warms the model in `init`.
3333
bool should_prewarm_model = true;
3434
};

backends/apple/coreml/runtime/delegate/com.apple.executorchcoreml_config.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>shouldPrewarmAsset</key>
6-
<true/>
6+
<false/>
77
<key>shouldPrewarmModel</key>
88
<true/>
99
<key>maxAssetsSizeInBytes</key>

backends/apple/coreml/runtime/test/CoreMLBackendDelegateTests.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ - (void)testStateProgramExecute {
209209
}
210210
#endif
211211

212+
- (void)testAddMulCompiledProgramExecute {
213+
NSURL *modelURL = [[self class] bundledResourceWithName:@"add_mul_compiled_coreml_all" extension:@"pte"];
214+
XCTAssertNotNil(modelURL);
215+
[self executeModelAtURL:modelURL nLoads:1 nExecutions:2];
216+
}
217+
212218
- (void)executeMultipleModelsConcurrently:(NSArray<NSURL *> *)modelURLs
213219
nLoads:(NSUInteger)nLoads
214220
nExecutions:(NSUInteger)nExecutions

backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
8307EB8A2C9262060011AE6D /* state_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 8307EB892C9262060011AE6D /* state_coreml_all.pte */; };
11+
838CA6872CD1965700462190 /* add_mul_compiled_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 838CA6862CD1965700462190 /* add_mul_compiled_coreml_all.pte */; };
1112
83BB78A02C65DA7300274ED7 /* ETCoreMLModelDebugInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 83BB789F2C65DA7300274ED7 /* ETCoreMLModelDebugInfo.mm */; };
1213
83BB78BF2C66AAAE00274ED7 /* add_mul_coreml_all.bin in Resources */ = {isa = PBXBuildFile; fileRef = 83BB78BD2C66AAAE00274ED7 /* add_mul_coreml_all.bin */; };
1314
83BB78C02C66AAAE00274ED7 /* add_mul_coreml_all.pte in Resources */ = {isa = PBXBuildFile; fileRef = 83BB78BE2C66AAAE00274ED7 /* add_mul_coreml_all.pte */; };
@@ -122,6 +123,7 @@
122123

123124
/* Begin PBXFileReference section */
124125
8307EB892C9262060011AE6D /* state_coreml_all.pte */ = {isa = PBXFileReference; lastKnownFileType = file; name = state_coreml_all.pte; path = ../test/models/state_coreml_all.pte; sourceTree = "<group>"; };
126+
838CA6862CD1965700462190 /* add_mul_compiled_coreml_all.pte */ = {isa = PBXFileReference; lastKnownFileType = file; name = add_mul_compiled_coreml_all.pte; path = ../test/models/add_mul_compiled_coreml_all.pte; sourceTree = "<group>"; };
125127
83BB789E2C65DA7300274ED7 /* ETCoreMLModelDebugInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ETCoreMLModelDebugInfo.h; path = ../sdk/ETCoreMLModelDebugInfo.h; sourceTree = "<group>"; };
126128
83BB789F2C65DA7300274ED7 /* ETCoreMLModelDebugInfo.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = ETCoreMLModelDebugInfo.mm; path = ../sdk/ETCoreMLModelDebugInfo.mm; sourceTree = "<group>"; };
127129
83BB78BD2C66AAAE00274ED7 /* add_mul_coreml_all.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = add_mul_coreml_all.bin; path = ../test/models/add_mul_coreml_all.bin; sourceTree = "<group>"; };
@@ -606,6 +608,7 @@
606608
C98551992AD2542D009143F9 /* mul_coreml_all.bin */,
607609
C985519C2AD2542D009143F9 /* mul_coreml_all.pte */,
608610
C985519B2AD2542D009143F9 /* mv3_coreml_all.bin */,
611+
838CA6862CD1965700462190 /* add_mul_compiled_coreml_all.pte */,
609612
C98551982AD2542D009143F9 /* mv3_coreml_all.pte */,
610613
83BB78BD2C66AAAE00274ED7 /* add_mul_coreml_all.bin */,
611614
83BB78BE2C66AAAE00274ED7 /* add_mul_coreml_all.pte */,
@@ -680,6 +683,7 @@
680683
C985519E2AD2542D009143F9 /* mv3_coreml_all.pte in Resources */,
681684
C98551A02AD2542D009143F9 /* add_coreml_all.bin in Resources */,
682685
C98551A22AD2542D009143F9 /* mul_coreml_all.pte in Resources */,
686+
838CA6872CD1965700462190 /* add_mul_compiled_coreml_all.pte in Resources */,
683687
8307EB8A2C9262060011AE6D /* state_coreml_all.pte in Resources */,
684688
C98551A32AD2542D009143F9 /* add_coreml_all.pte in Resources */,
685689
);

backends/apple/coreml/scripts/generate_test_models.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ done
3131

3232
echo "Executorch: Generating stateful model"
3333
python3 "$SCRIPT_DIR_PATH/../runtime/test/export_stateful_model.py"
34+
35+
COMPILE_MODELS=("add_mul")
36+
echo "Executorch: Generating compiled model"
37+
for MODEL in "${COMPILE_MODELS[@]}"
38+
do
39+
echo "Executorch: Generating compiled $MODEL model"
40+
python3 -m examples.apple.coreml.scripts.export --model_name "$MODEL" --compile
41+
mv -f "$MODEL""_compiled_coreml_all.pte" "$COREML_DIR_PATH/runtime/test/models"
42+
done

backends/arm/_passes/arm_pass_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
AnnotateChannelsLastDimOrder,
1313
)
1414
from executorch.backends.arm._passes.cast_int64_pass import CastInt64ToInt32Pass
15+
from executorch.backends.arm._passes.conv1d_unsqueeze_pass import Conv1dUnsqueezePass
1516
from executorch.backends.arm._passes.convert_expand_copy_to_repeat import (
1617
ConvertExpandCopyToRepeatPass,
1718
)
@@ -69,6 +70,7 @@ def transform_to_backend_pipeline(
6970
self.add_pass(DecomposeDivPass())
7071
self.add_pass(InsertSqueezeAfterSumPass())
7172
self.add_pass(ConvertSplitToSlicePass())
73+
self.add_pass(Conv1dUnsqueezePass(exported_program))
7274
self.add_pass(DecomposeSoftmaxesPass())
7375
for spec in compile_spec:
7476
if spec.key == "permute_memory_format":

backends/arm/_passes/arm_pass_utils.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
12
# Copyright 2024 Arm Limited and/or its affiliates.
23
# All rights reserved.
34
#
@@ -9,11 +10,57 @@
910
import torch
1011
import torch.fx
1112

13+
from executorch.exir import ExportedProgram
1214
from executorch.exir.dialects._ops import ops as exir_ops
15+
16+
from torch._export.utils import (
17+
get_buffer,
18+
get_lifted_tensor_constant,
19+
get_param,
20+
is_buffer,
21+
is_lifted_tensor_constant,
22+
is_param,
23+
)
1324
from torch._ops import OpOverload
1425
from torch._subclasses.fake_tensor import FakeTensor
1526

1627

28+
def is_get_attr_node(node: torch.fx.Node) -> bool:
29+
"""
30+
Returns true if the given node is a get attr node for a tensor of the model
31+
"""
32+
return isinstance(node, torch.fx.Node) and node.op == "get_attr"
33+
34+
35+
def is_param_node(exp_prog: ExportedProgram, node: torch.fx.Node) -> bool:
36+
return (
37+
is_get_attr_node(node)
38+
or is_param(exp_prog, node)
39+
or is_buffer(exp_prog, node)
40+
or is_lifted_tensor_constant(exp_prog, node)
41+
)
42+
43+
44+
def get_param_tensor(
45+
exp_prog: ExportedProgram, node: torch.fx.Node
46+
) -> Optional[torch.Tensor]:
47+
if node is None:
48+
return None
49+
elif is_param(exp_prog, node):
50+
return get_param(exp_prog, node)
51+
elif is_buffer(exp_prog, node):
52+
return get_buffer(exp_prog, node)
53+
elif is_lifted_tensor_constant(exp_prog, node):
54+
return get_lifted_tensor_constant(exp_prog, node)
55+
elif is_get_attr_node(node):
56+
# This is a hack to support both lifted and unlifted graph
57+
try:
58+
return getattr(node.graph.owning_module, node.target)
59+
except AttributeError:
60+
return getattr(exp_prog.graph_module, node.target)
61+
raise RuntimeError(f"unsupported param type, {node.op}.")
62+
63+
1764
def create_node(
1865
graph: torch.fx.Graph,
1966
op_target: OpOverload,

0 commit comments

Comments
 (0)