Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions video/conversion/_exporter/_onnx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import onnx
import onnxscript
from onnx import shape_inference
from onnxscript import ir

DEFAULT_ONNX_PASSES = [
Expand Down Expand Up @@ -57,6 +58,16 @@ def optimize(self, passes=DEFAULT_ONNX_PASSES):
self._qc_workaround_clip_min_only()
else:
raise ValueError(f"Unknown pass: {pass_name}")

# Passes like qc_workaround_squeeze_gather_4d hand-craft new tensors
# and value_info entries without keeping the rest of the graph's
# shape info in sync. onnxruntime tolerates the resulting
# inconsistency, but AI Hub's strict onnx.checker rejects it with
# e.g. "Inferred shape and existing shape differ in rank: (2) vs
# (4)". Rebuild value_info from scratch so every saved model is
# internally consistent, regardless of which passes ran.
del self._model.graph.value_info[:]
self._model = shape_inference.infer_shapes(self._model)
return self._model

def _replace_reciprocal_op(self):
Expand Down
2 changes: 1 addition & 1 deletion video/conversion/_powermetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _run_apple(self):
break

line = process.stdout.readline()
if line[0] == 0:
if line and line[0] == 0:
d = b"".join(buffer)
data = plistlib.loads(d)
row = PowermetricsSample(
Expand Down