File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,8 @@ run_portable_executor_runner() {
6060
6161test_model () {
6262 if [[ " ${MODEL_NAME} " == " llama2" ]]; then
63+ # Install requirements for export_llama
64+ bash examples/models/llama2/install_requirements.sh
6365 # Test export_llama script: python3 -m examples.models.llama2.export_llama
6466 " ${PYTHON_EXECUTABLE} " -m examples.models.llama2.export_llama -c examples/models/llama2/params/demo_rand_params.pth -p examples/models/llama2/params/demo_config.json
6567 run_portable_executor_runner
Original file line number Diff line number Diff line change 2525from executorch .exir .passes .quant_fusion_pass import QuantFusionPass
2626from executorch .exir .passes .sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass
2727from executorch .util .activation_memory_profiler import generate_memory_trace
28- from executorch .util .python_profiler import CProfilerFlameGraph
2928from torch ._export import capture_pre_autograd_graph
3029from torch .ao .quantization .quantize_pt2e import convert_pt2e , prepare_pt2e
3130from torch .ao .quantization .quantizer .composable_quantizer import ComposableQuantizer
@@ -266,8 +265,16 @@ def _get_quantization_options(args):
266265
267266def export_llama (modelname , args ) -> str :
268267 if args .profile_path is not None :
269- with CProfilerFlameGraph (args .profile_path ):
270- return _export_llama (modelname , args )
268+ try :
269+ from executorch .util .python_profiler import CProfilerFlameGraph
270+
271+ with CProfilerFlameGraph (args .profile_path ):
272+ return _export_llama (modelname , args )
273+ except ImportError :
274+ print (
275+ "Please run `pip install snakeviz` to install required dependencies for cProfiler flamegraph."
276+ )
277+ return ""
271278 else :
272279 return _export_llama (modelname , args )
273280
Original file line number Diff line number Diff line change 1+ #! /bin/bash
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+ # Install snakeviz for cProfile flamegraph
9+ pip install snakeviz
You can’t perform that action at this time.
0 commit comments