Skip to content

Commit

Permalink
linting, add onnx networks to create.py, change default cmssw version
Browse files Browse the repository at this point in the history
  • Loading branch information
nprouvost committed Apr 16, 2024
1 parent 33b2320 commit 4efcc27
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 0 additions & 3 deletions cmssw/install_sandbox_tfaot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ action() {
# define additional model variables
local tool_name="tfaot-model-mlprof-test"

# temporarily prepend the local cms_tfaot path
export PYTHONPATH="${MLP_BASE}/modules/cms-tfaot:${PYTHONPATH}"

# remove existing code
rm -rf MLProf

Expand Down
18 changes: 18 additions & 0 deletions examples/simple_dnn/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"""
Test script to create a simple DNN model.
Best to be executed in a CMSSW environment with TensorFlow and cmsml installed.
Will install tf2onnx for the user if not present in environment.
Signature: f32(64) -> f32(8)
"""

import os
import subprocess
import importlib.util

import cmsml

Expand Down Expand Up @@ -63,6 +66,21 @@ def create_model(
os.path.join(model_dir, f"saved_model_{_postfix}"),
)

# convert SavedModel to onnx
# install tf2onnx if necessary
if importlib.util.find_spec("tf2onnx") is None:
subprocess.run("pip3 install --user tf2onnx", shell=True)

# convert
subprocess.run(
f"""
python3 -m tf2onnx.convert \
--saved-model saved_model_{_postfix} \
--output onnx_graph_{_postfix}.onnx \
""",
shell=True,
)


def main():
this_dir = os.path.dirname(os.path.abspath(__file__))
Expand Down
4 changes: 2 additions & 2 deletions mlprof/scripts/render_aot.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def render_aot(plugin_file: str, header_file: str, model_name: str) -> None:
]
# untied inference
content["untied_inference"] = [
f"model_.run<{', '.join(output_arrays)}>(batchSize_, {', '.join(input_names)});"
f"model_.run<{', '.join(output_arrays)}>(batchSize_, {', '.join(input_names)});",
]
# tied inference
content["tied_inference"] = [
f"std::tie({', '.join(output_names)}) = {content['untied_inference'][0]};"
f"std::tie({', '.join(output_names)}) = {content['untied_inference'][0]};",
]

# read the plugin file content
Expand Down
4 changes: 2 additions & 2 deletions mlprof/tasks/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class CMSSWParameters(BaseTask):
"""

cmssw_version = luigi.Parameter(
default="CMSSW_14_1_X_2024-04-04-2300",
description="CMSSW version; default: CMSSW_14_1_X_2024-04-04-2300",
default="CMSSW_14_1_X_2024-04-15-2300",
description="CMSSW version; default: CMSSW_14_1_X_2024-04-15-2300",
)
scram_arch = luigi.Parameter(
default="slc7_amd64_gcc12",
Expand Down

0 comments on commit 4efcc27

Please sign in to comment.