From 468ebb7ecbcbbb32c7a92fc1f8f5bf7f4f68f325 Mon Sep 17 00:00:00 2001 From: Jeremy Fowers Date: Mon, 12 Aug 2024 10:15:06 -0400 Subject: [PATCH 1/6] Move the performance module and Device class under the run module --- src/turnkeyml/{common => run}/performance.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/turnkeyml/{common => run}/performance.py (100%) diff --git a/src/turnkeyml/common/performance.py b/src/turnkeyml/run/performance.py similarity index 100% rename from src/turnkeyml/common/performance.py rename to src/turnkeyml/run/performance.py From 6bf334ae8e1d99b3126abb2059aab67b4ae76dc0 Mon Sep 17 00:00:00 2001 From: Jeremy Fowers Date: Mon, 12 Aug 2024 10:15:36 -0400 Subject: [PATCH 2/6] Fix imports --- src/turnkeyml/run/basert.py | 2 +- src/turnkeyml/run/benchmark_model.py | 2 +- src/turnkeyml/run/torchrt/runtime.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/turnkeyml/run/basert.py b/src/turnkeyml/run/basert.py index 938647fb..42722f9b 100644 --- a/src/turnkeyml/run/basert.py +++ b/src/turnkeyml/run/basert.py @@ -7,7 +7,7 @@ from abc import ABC, abstractmethod import torch import numpy as np -from turnkeyml.common.performance import MeasuredPerformance, Device +from turnkeyml.run.performance import MeasuredPerformance, Device import turnkeyml.common.build as build import turnkeyml.common.exceptions as exp import turnkeyml.common.filesystem as fs diff --git a/src/turnkeyml/run/benchmark_model.py b/src/turnkeyml/run/benchmark_model.py index f231d23e..66e6094e 100644 --- a/src/turnkeyml/run/benchmark_model.py +++ b/src/turnkeyml/run/benchmark_model.py @@ -10,7 +10,7 @@ apply_default_runtime, ) import turnkeyml.cli.parser_helpers as parser_helpers -from turnkeyml.common.performance import Device, parse_device +from turnkeyml.run.performance import Device, parse_device default_iterations = 100 benchmark_default_device = "x86" diff --git a/src/turnkeyml/run/torchrt/runtime.py b/src/turnkeyml/run/torchrt/runtime.py index d7e3c87d..7673194c 100644 --- a/src/turnkeyml/run/torchrt/runtime.py +++ b/src/turnkeyml/run/torchrt/runtime.py @@ -7,7 +7,7 @@ import torch import numpy as np from turnkeyml.run.basert import BaseRT -from turnkeyml.common.performance import MeasuredPerformance +from turnkeyml.run.performance import MeasuredPerformance from turnkeyml.run.onnxrt.execute import get_cpu_specs import turnkeyml.common.build as build import turnkeyml.common.exceptions as exp From 8a13518c9279a09281d9e783a5c38f58ce955aed Mon Sep 17 00:00:00 2001 From: Jeremy Fowers Date: Mon, 12 Aug 2024 10:16:39 -0400 Subject: [PATCH 3/6] rev version number --- src/turnkeyml/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/turnkeyml/version.py b/src/turnkeyml/version.py index e94f36fe..6ed01825 100644 --- a/src/turnkeyml/version.py +++ b/src/turnkeyml/version.py @@ -1 +1 @@ -__version__ = "3.0.5" +__version__ = "3.0.6" From b70c6ec7946112358222c964eb98868a5d98858e Mon Sep 17 00:00:00 2001 From: Jeremy Fowers Date: Mon, 12 Aug 2024 10:23:17 -0400 Subject: [PATCH 4/6] fix one more import --- test/unit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit.py b/test/unit.py index 0b34fa2e..49c909f8 100644 --- a/test/unit.py +++ b/test/unit.py @@ -6,8 +6,8 @@ import os import sys import turnkeyml.common.filesystem as filesystem -import turnkeyml.common.performance as performance import turnkeyml.common.build as build +import turnkeyml.run.performance as performance import turnkeyml.run.plugin_helpers as plugin_helpers From b0acc01cdbeba459d79c985bb325e389a7a85aec Mon Sep 17 00:00:00 2001 From: Jeremy Fowers Date: Mon, 12 Aug 2024 10:32:55 -0400 Subject: [PATCH 5/6] fix more imports --- .../turnkeyml_plugin_example_combined/runtime.py | 2 +- .../plugins/example_rt/turnkeyml_plugin_example_rt/runtime.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/cli/plugins/example_combined/turnkeyml_plugin_example_combined/runtime.py b/examples/cli/plugins/example_combined/turnkeyml_plugin_example_combined/runtime.py index d96b6b23..64395209 100644 --- a/examples/cli/plugins/example_combined/turnkeyml_plugin_example_combined/runtime.py +++ b/examples/cli/plugins/example_combined/turnkeyml_plugin_example_combined/runtime.py @@ -8,7 +8,7 @@ import turnkeyml.common.exceptions as exp import turnkeyml.common.filesystem as fs from turnkeyml.run.onnxrt.within_conda import dummy_inputs -from turnkeyml.common.performance import MeasuredPerformance +from turnkeyml.run.performance import MeasuredPerformance combined_rt_name = "example-combined-rt" diff --git a/examples/cli/plugins/example_rt/turnkeyml_plugin_example_rt/runtime.py b/examples/cli/plugins/example_rt/turnkeyml_plugin_example_rt/runtime.py index 5ce10915..ed010694 100644 --- a/examples/cli/plugins/example_rt/turnkeyml_plugin_example_rt/runtime.py +++ b/examples/cli/plugins/example_rt/turnkeyml_plugin_example_rt/runtime.py @@ -1,7 +1,7 @@ import os import numpy as np from turnkeyml.run.basert import BaseRT -from turnkeyml.common.performance import MeasuredPerformance +from turnkeyml.run.performance import MeasuredPerformance import turnkeyml.common.exceptions as exp from turnkeyml.common.filesystem import Stats From 779536f1d63d59e189cf4ab5e39d0edf1fa715bb Mon Sep 17 00:00:00 2001 From: Jeremy Fowers Date: Mon, 12 Aug 2024 11:04:29 -0400 Subject: [PATCH 6/6] Allow plugin benchmark tools to override the built-in one --- src/turnkeyml/sequence/tool_plugins.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/turnkeyml/sequence/tool_plugins.py b/src/turnkeyml/sequence/tool_plugins.py index a9aa5e8f..9cd170a8 100644 --- a/src/turnkeyml/sequence/tool_plugins.py +++ b/src/turnkeyml/sequence/tool_plugins.py @@ -2,7 +2,6 @@ import turnkeyml.tools.onnx as onnx_tools import turnkeyml.common.plugins as plugins import turnkeyml.tools.management_tools as mgmt -from turnkeyml.run.benchmark_model import Benchmark from turnkeyml.tools.discovery import Discover import turnkeyml.tools.report as report from turnkeyml.tools.load_build import LoadBuild @@ -16,7 +15,6 @@ mgmt.Cache, mgmt.ModelsLocation, report.Report, - Benchmark, Discover, export.ExportPytorchModel, onnx_tools.OptimizeOnnxModel, @@ -40,3 +38,11 @@ ) SUPPORTED_TOOLS.append(tool_class) + +# Give a "benchmark" tool installed by a plugin priority over +# a "benchmark" tool built into turnkeyml +tool_names = [tool.unique_name for tool in SUPPORTED_TOOLS] +if "benchmark" not in tool_names: + from turnkeyml.run.benchmark_model import Benchmark + + SUPPORTED_TOOLS.append(Benchmark)