From b04b08456027c7228eb98435c3711f215f3903de Mon Sep 17 00:00:00 2001 From: Arjun Suresh Date: Sat, 8 Feb 2025 22:55:35 +0000 Subject: [PATCH] Merge from GO (#201) * Update flow.md * Download imagenet dataset to host by default * Added template script for MLC --- flow.md | 8 ++++++-- script/app-mlperf-inference/meta.yaml | 2 ++ script/template-script/COPYRIGHT.md | 9 +++++++++ script/template-script/customize.py | 23 +++++++++++++++++++++++ script/template-script/meta.yaml | 24 ++++++++++++++++++++++++ script/template-script/run.bat | 23 +++++++++++++++++++++++ script/template-script/run.sh | 17 +++++++++++++++++ 7 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 script/template-script/COPYRIGHT.md create mode 100644 script/template-script/customize.py create mode 100644 script/template-script/meta.yaml create mode 100644 script/template-script/run.bat create mode 100644 script/template-script/run.sh diff --git a/flow.md b/flow.md index 052d8dc13..87e2b2304 100644 --- a/flow.md +++ b/flow.md @@ -3,7 +3,11 @@ ```mermaid flowchart TD A[MLC interface] --> B{Script Automation} - A[MLC interface] --> C{Cache Automation} - B[Script Automation] --> C{Cache Automation} + A[MLC interface] --> C{Cache Action} + B[Script Automation] --> C{Cache Action} + A[MLC interface] --> E{Docker Action} + B[Script Automation] --> E{Docker Action} + A[MLC interface] --> F{Test Action} + B[Script Automation] --> F{Test Action} B[Script Automation] --> D{MLPerf Scripts} ``` diff --git a/script/app-mlperf-inference/meta.yaml b/script/app-mlperf-inference/meta.yaml index 86be8fa3b..b1abbe02d 100644 --- a/script/app-mlperf-inference/meta.yaml +++ b/script/app-mlperf-inference/meta.yaml @@ -676,6 +676,8 @@ variations: model default: true + default_env: + MLC_USE_DATASET_FROM_HOST: yes env: MLC_MODEL: resnet50 diff --git a/script/template-script/COPYRIGHT.md b/script/template-script/COPYRIGHT.md new file mode 100644 index 000000000..9e44ad290 --- /dev/null +++ b/script/template-script/COPYRIGHT.md @@ -0,0 +1,9 @@ +# Copyright Notice + +© 2022-2025 MLCommons. All Rights Reserved. + +This file is licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License can be obtained at: + +[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software distributed under the License is provided on an "AS IS" basis, without warranties or conditions of any kind, either express or implied. Please refer to the License for the specific language governing permissions and limitations under the License. diff --git a/script/template-script/customize.py b/script/template-script/customize.py new file mode 100644 index 000000000..a0539e016 --- /dev/null +++ b/script/template-script/customize.py @@ -0,0 +1,23 @@ +from mlc import utils +import os +import subprocess + + +def preprocess(i): + + env = i['env'] + state = i['state'] + + os_info = i['os_info'] + + return {'return': 0} + + +def postprocess(i): + + env = i['env'] + state = i['state'] + + os_info = i['os_info'] + + return {'return': 0} diff --git a/script/template-script/meta.yaml b/script/template-script/meta.yaml new file mode 100644 index 000000000..e6e022b03 --- /dev/null +++ b/script/template-script/meta.yaml @@ -0,0 +1,24 @@ +alias: template-script +automation_alias: script +automation_uid: 5b4e0237da074764 + +category: MLC Script Template + +# ENV keys matching the regular expression in new_env_keys will be exported by this script to the caller script, similar for new_state_keys too +new_env_keys: [] +new_state_keys: [] + +# Deps are executed first before the preprocess function inside customize.py +deps: [] +# Prehook deps are executed after the preprocess function inside customize.py but before the run script +prehook_deps: [] +# Posthook deps are executed after the run script but before the postprocess function inside customize.py +posthook_deps: [] +# Post deps are executed after the postprocess function inside customize.py +post_deps: [] + +tags: +- generic +- template + +uid: fc3e6915a29342d8 diff --git a/script/template-script/run.bat b/script/template-script/run.bat new file mode 100644 index 000000000..80625c80e --- /dev/null +++ b/script/template-script/run.bat @@ -0,0 +1,23 @@ +@echo off +setlocal enabledelayedexpansion + +:: Function to exit if the last command failed +:exit_if_error +if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL% +exit /b 0 + +:: Function to run a command +:run +echo Running: +echo %1 +echo. + +if /I "%MLC_FAKE_RUN%" NEQ "yes" ( + call %1 + call :exit_if_error +) +exit /b 0 + +:: Add your run commands here... +:: call :run "%MLC_RUN_CMD%" + diff --git a/script/template-script/run.sh b/script/template-script/run.sh new file mode 100644 index 000000000..fa21de70c --- /dev/null +++ b/script/template-script/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +function exit_if_error() { + test $? -eq 0 || exit $? +} + +function run() { + echo "Running: " + echo "$1" + echo "" + if [[ ${MLC_FAKE_RUN} != 'yes' ]]; then + eval "$1" + exit_if_error + fi +} + +#Add your run commands here... +# run "$MLC_RUN_CMD"