Skip to content

Commit

Permalink
Merge pull request #66 from tum-ei-eda/patch_passcfg2col
Browse files Browse the repository at this point in the history
[postprocess] add PassConfig2Columns
  • Loading branch information
PhilippvK authored Jul 11, 2022
2 parents cbedc51 + 3439302 commit ebc6c2a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mlonmcu/flow/tvm/backend/model_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import re
import tflite
from tflite.TensorType import TensorType as TType
import tensorflow as tf


class TensorInfo:
Expand Down Expand Up @@ -161,6 +160,8 @@ def get_tfgraph_inout(graph):

class PBModelInfo(ModelInfo):
def __init__(self, model_file):
import tensorflow as tf

with tf.io.gfile.GFile(model_file, "rb") as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
Expand Down
2 changes: 2 additions & 0 deletions mlonmcu/session/postprocess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
RenameColumnsPostprocess,
Features2ColumnsPostprocess,
Config2ColumnsPostprocess,
PassConfig2ColumnsPostprocess,
VisualizePostprocess,
Bytes2kBPostprocess,
Artifact2ColumnPostprocess,
Expand All @@ -37,6 +38,7 @@
"rename_cols": RenameColumnsPostprocess,
"features2cols": Features2ColumnsPostprocess,
"config2cols": Config2ColumnsPostprocess,
"passcfg2cols": PassConfig2ColumnsPostprocess,
"visualize": VisualizePostprocess,
"bytes2kb": Bytes2kBPostprocess,
"artifact2cols": Artifact2ColumnPostprocess,
Expand Down
19 changes: 19 additions & 0 deletions mlonmcu/session/postprocess/postprocesses.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,25 @@ def post_session(self, report):
report.post_df = new_df


class PassConfig2ColumnsPostprocess(SessionPostprocess):
"""Postprocess which can be used to transform (explode) the TVM pass_config into separate columns.
requires prior Config2Columns pass."""

def __init__(self, features=None, config=None):
super().__init__("passcfg2cols", features=features, config=config)

def post_session(self, report):
"""Called at the end of a session."""
df = report.post_df
name = "config_tvmaot.extra_pass_config"
if name not in df.columns:
return
config_df = df[name].apply(pd.Series).add_prefix("passcfg_")
tmp_df = df.drop(columns=[name])
new_df = pd.concat([tmp_df, config_df], axis=1)
report.post_df = new_df


class Bytes2kBPostprocess(SessionPostprocess): # RunPostprocess?
"""Postprocess which can be used to scale the memory related columns from Bytes to KiloBytes."""

Expand Down

0 comments on commit ebc6c2a

Please sign in to comment.