-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd7b908
commit 92432d4
Showing
15 changed files
with
1,057 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ jobs: | |
directory: [ | ||
data_prep, | ||
train, | ||
eval | ||
eval, | ||
onnx_optimize | ||
] | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.12.5-slim AS builder | ||
|
||
RUN pip install --upgrade pip==24.2.0 && \ | ||
pip install poetry==1.8.3 | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.toml poetry.lock ./ | ||
|
||
RUN poetry install | ||
|
||
FROM python:3.12.5-slim AS runtime | ||
|
||
WORKDIR /app | ||
|
||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
COPY --from=builder /app/.venv .venv |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from kfp.dsl import Input, Metrics, Model, Output | ||
|
||
|
||
def onnx_optimize( | ||
onnx_with_transform_model: Input[Model], optimization_metrics: Output[Metrics], optimized_onnx_with_transform_model: Output[Model] | ||
) -> None: | ||
import logging | ||
import time | ||
|
||
import onnxruntime as rt | ||
|
||
start_time = time.time() | ||
logging.info("Started ONNX model optimization task.") | ||
|
||
sess_options = rt.SessionOptions() | ||
sess_options.graph_optimization_level = rt.GraphOptimizationLevel.ORT_ENABLE_ALL | ||
sess_options.optimized_model_filepath = optimized_onnx_with_transform_model.path | ||
rt.InferenceSession(f"{onnx_with_transform_model.path}.onnx", sess_options) | ||
optimized_onnx_with_transform_model.framework = ( | ||
f"onnxruntime-{rt.__version__}, graphOptimizationLevel-{str(sess_options.graph_optimization_level)}" | ||
) | ||
optimization_metrics.log_metric("timeTakenSeconds", round(time.time() - start_time, 2)) | ||
logging.info("Successfully finished ONNX model optimization task.") |
Oops, something went wrong.