Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omit scalar weight #424

Merged
merged 4 commits into from
Feb 5, 2024
Merged
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
5 changes: 4 additions & 1 deletion src/sparsezoo/utils/onnx/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,15 @@ def get_node_weight(
:param node: node to which parameter belongs to
:return: a numpy array of param value, None if not found
"""

initializer_name = get_node_weight_name(model_graph, node)
weight = get_initializer_value(model_graph, node, initializer_name)

if initializer_name is not None and weight is None and node.op_type != "Gather":
raise Exception(f"Parameter for {node.name} not found")

# some weights are not accessible, and returns the zero_points, which are scalars
if weight is not None and weight.ndim in [0, 1]:
return None
return weight


Expand Down