onnxslim 0.1.78__tar.gz → 0.1.79__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {onnxslim-0.1.78/onnxslim.egg-info → onnxslim-0.1.79}/PKG-INFO +1 -1
- onnxslim-0.1.79/VERSION +1 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/ir/graph.py +117 -25
- onnxslim-0.1.79/onnxslim/version.py +1 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79/onnxslim.egg-info}/PKG-INFO +1 -1
- onnxslim-0.1.78/VERSION +0 -1
- onnxslim-0.1.78/onnxslim/version.py +0 -1
- {onnxslim-0.1.78 → onnxslim-0.1.79}/LICENSE +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/MANIFEST.in +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/README.md +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/__main__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/argparser.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/cli/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/cli/_main.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/optimization/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/optimization/dead_node_elimination.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/optimization/subexpression_elimination.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/optimization/weight_tying.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/elimination/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/elimination/concat.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/elimination/reshape.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/elimination/reshape_as.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/elimination/slice.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/elimination/unsqueeze.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/concat_reshape.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/convadd.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/convbn.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/convmul.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/gelu.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/gemm.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/padconv.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/fusion/reduce.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/core/pattern/registry.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/misc/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/misc/tabulate.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/_sympy/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/_sympy/functions.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/_sympy/numbers.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/_sympy/printers.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/_sympy/solve.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/_sympy/symbol.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/exporters/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/exporters/base_exporter.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/exporters/onnx_exporter.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/graph_pattern.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/importers/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/importers/base_importer.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/importers/onnx_importer.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/ir/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/ir/function.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/ir/node.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/ir/tensor.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/logger/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/logger/logger.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/util/__init__.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/util/exception.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/util/misc.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/symbolic_shape_infer.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/utils.py +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim.egg-info/SOURCES.txt +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim.egg-info/dependency_links.txt +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim.egg-info/entry_points.txt +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim.egg-info/requires.txt +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim.egg-info/top_level.txt +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim.egg-info/zip-safe +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/pyproject.toml +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/setup.cfg +0 -0
- {onnxslim-0.1.78 → onnxslim-0.1.79}/setup.py +0 -0
onnxslim-0.1.79/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.79
|
|
@@ -978,17 +978,46 @@ class Graph:
|
|
|
978
978
|
return next(iter(tensor.values)) if tensor.shape else tensor.values
|
|
979
979
|
|
|
980
980
|
def fold_shape(tensor):
|
|
981
|
-
"""Returns the input tensor shape if available, otherwise returns None.
|
|
982
|
-
|
|
981
|
+
"""Returns the input tensor shape if available, otherwise returns None.
|
|
982
|
+
Handles Shape node with optional 'start' and 'end' attributes (opset 15+).
|
|
983
|
+
"""
|
|
984
|
+
shape_node = get_producer(tensor, "Shape")
|
|
985
|
+
inp = get_input(shape_node)
|
|
983
986
|
if inp is None:
|
|
984
987
|
return None
|
|
985
988
|
|
|
986
989
|
if inp.shape is None or misc.is_dynamic_shape(inp.shape):
|
|
987
990
|
return None
|
|
988
|
-
|
|
991
|
+
|
|
992
|
+
full_shape = inp.shape
|
|
993
|
+
num_dims = len(full_shape)
|
|
994
|
+
|
|
995
|
+
# Get start and end attributes (default: start=0, end=None means full shape)
|
|
996
|
+
start = shape_node.attrs.get("start", 0)
|
|
997
|
+
end = shape_node.attrs.get("end", None)
|
|
998
|
+
|
|
999
|
+
# Handle negative indices
|
|
1000
|
+
if start < 0:
|
|
1001
|
+
start = num_dims + start
|
|
1002
|
+
if end is None:
|
|
1003
|
+
end = num_dims
|
|
1004
|
+
elif end < 0:
|
|
1005
|
+
end = num_dims + end
|
|
1006
|
+
|
|
1007
|
+
# Clamp to valid range
|
|
1008
|
+
start = max(0, min(start, num_dims))
|
|
1009
|
+
end = max(0, min(end, num_dims))
|
|
1010
|
+
|
|
1011
|
+
if start > end:
|
|
1012
|
+
return None
|
|
1013
|
+
|
|
1014
|
+
target_shape = full_shape[start:end]
|
|
1015
|
+
return np.array(target_shape, dtype=np.int64)
|
|
989
1016
|
|
|
990
1017
|
def fold_shape_gather(tensor):
|
|
991
|
-
"""Retrieves and returns the shape of the input tensor as a NumPy array, otherwise returns None.
|
|
1018
|
+
"""Retrieves and returns the shape of the input tensor as a NumPy array, otherwise returns None.
|
|
1019
|
+
Handles Shape node with optional 'start' and 'end' attributes (opset 15+).
|
|
1020
|
+
"""
|
|
992
1021
|
gather = get_producer(tensor, "Gather")
|
|
993
1022
|
if gather is None:
|
|
994
1023
|
return None
|
|
@@ -996,69 +1025,132 @@ class Graph:
|
|
|
996
1025
|
data = gather.inputs[0]
|
|
997
1026
|
indices_tensor = gather.inputs[1]
|
|
998
1027
|
|
|
999
|
-
|
|
1028
|
+
shape_node = get_producer(data, "Shape")
|
|
1029
|
+
inp = get_input(shape_node)
|
|
1000
1030
|
if inp is None or inp.shape is None:
|
|
1001
1031
|
return None
|
|
1002
1032
|
|
|
1003
1033
|
if not isinstance(indices_tensor, Constant):
|
|
1004
1034
|
return None
|
|
1005
1035
|
|
|
1036
|
+
# Get the shape slice from Shape node (considering start/end attributes)
|
|
1037
|
+
full_shape = inp.shape
|
|
1038
|
+
num_dims = len(full_shape)
|
|
1039
|
+
|
|
1040
|
+
start = shape_node.attrs.get("start", 0)
|
|
1041
|
+
end = shape_node.attrs.get("end", None)
|
|
1042
|
+
|
|
1043
|
+
if start < 0:
|
|
1044
|
+
start = num_dims + start
|
|
1045
|
+
if end is None:
|
|
1046
|
+
end = num_dims
|
|
1047
|
+
elif end < 0:
|
|
1048
|
+
end = num_dims + end
|
|
1049
|
+
|
|
1050
|
+
start = max(0, min(start, num_dims))
|
|
1051
|
+
end = max(0, min(end, num_dims))
|
|
1052
|
+
|
|
1053
|
+
if start > end:
|
|
1054
|
+
return None
|
|
1055
|
+
|
|
1056
|
+
shape_slice = full_shape[start:end]
|
|
1057
|
+
|
|
1006
1058
|
indices = indices_tensor.values
|
|
1007
1059
|
if not indices.shape: # Scalar-case
|
|
1008
|
-
|
|
1060
|
+
idx = int(indices)
|
|
1061
|
+
# Handle negative indices relative to shape_slice
|
|
1062
|
+
if idx < 0:
|
|
1063
|
+
idx = len(shape_slice) + idx
|
|
1064
|
+
if idx < 0 or idx >= len(shape_slice):
|
|
1065
|
+
return None
|
|
1066
|
+
shape = shape_slice[idx]
|
|
1009
1067
|
if misc.is_dynamic_dimension(shape):
|
|
1010
1068
|
return None
|
|
1011
1069
|
else:
|
|
1012
|
-
shape = [
|
|
1070
|
+
shape = []
|
|
1071
|
+
for index in indices:
|
|
1072
|
+
idx = int(index)
|
|
1073
|
+
# Handle negative indices relative to shape_slice
|
|
1074
|
+
if idx < 0:
|
|
1075
|
+
idx = len(shape_slice) + idx
|
|
1076
|
+
if idx < 0 or idx >= len(shape_slice):
|
|
1077
|
+
return None
|
|
1078
|
+
shape.append(shape_slice[idx])
|
|
1013
1079
|
if misc.is_dynamic_shape(shape):
|
|
1014
1080
|
return None
|
|
1015
1081
|
|
|
1016
1082
|
return np.array(shape, dtype=np.int64)
|
|
1017
1083
|
|
|
1018
1084
|
def fold_shape_slice(tensor):
|
|
1019
|
-
"""Fold tensor shape slice information into a NumPy array of int64 type.
|
|
1020
|
-
|
|
1021
|
-
|
|
1085
|
+
"""Fold tensor shape slice information into a NumPy array of int64 type.
|
|
1086
|
+
Handles Shape node with optional 'start' and 'end' attributes (opset 15+).
|
|
1087
|
+
"""
|
|
1088
|
+
slice_node = get_producer(tensor, "Slice")
|
|
1089
|
+
if slice_node is None:
|
|
1022
1090
|
return None
|
|
1023
1091
|
|
|
1024
|
-
data =
|
|
1092
|
+
data = slice_node.inputs[0]
|
|
1025
1093
|
|
|
1026
|
-
if len(
|
|
1027
|
-
starts, ends =
|
|
1094
|
+
if len(slice_node.inputs) >= 3:
|
|
1095
|
+
starts, ends = slice_node.inputs[1:3]
|
|
1028
1096
|
if any(not isinstance(t, Constant) for t in [starts, ends]):
|
|
1029
1097
|
return None
|
|
1030
1098
|
starts, ends = get_scalar_value(starts), get_scalar_value(ends)
|
|
1031
|
-
elif "starts" in
|
|
1032
|
-
starts, ends =
|
|
1099
|
+
elif "starts" in slice_node.attrs and "ends" in slice_node.attrs:
|
|
1100
|
+
starts, ends = slice_node.attrs["starts"][0], slice_node.attrs["ends"][0]
|
|
1033
1101
|
else:
|
|
1034
1102
|
return None
|
|
1035
1103
|
|
|
1036
|
-
|
|
1104
|
+
shape_node = get_producer(data, "Shape")
|
|
1105
|
+
inp = get_input(shape_node)
|
|
1037
1106
|
if inp is None or inp.shape is None:
|
|
1038
1107
|
return None
|
|
1039
1108
|
|
|
1040
1109
|
# For shape tensors, we can only slice on the 0th dimension.
|
|
1041
|
-
if len(
|
|
1042
|
-
axes =
|
|
1110
|
+
if len(slice_node.inputs) > 3:
|
|
1111
|
+
axes = slice_node.inputs[3]
|
|
1043
1112
|
if not isinstance(axes, Constant):
|
|
1044
1113
|
return None
|
|
1045
1114
|
|
|
1046
1115
|
if get_scalar_value(axes) != 0:
|
|
1047
1116
|
return None
|
|
1048
|
-
elif "axes" in
|
|
1049
|
-
if
|
|
1117
|
+
elif "axes" in slice_node.attrs:
|
|
1118
|
+
if slice_node.attrs["axes"][0] != 0:
|
|
1050
1119
|
return None
|
|
1051
1120
|
|
|
1052
1121
|
steps = 1
|
|
1053
|
-
if len(
|
|
1054
|
-
steps =
|
|
1122
|
+
if len(slice_node.inputs) > 4:
|
|
1123
|
+
steps = slice_node.inputs[4]
|
|
1055
1124
|
if not isinstance(steps, Constant):
|
|
1056
1125
|
return None
|
|
1057
1126
|
steps = get_scalar_value(steps)
|
|
1058
|
-
elif "steps" in
|
|
1059
|
-
steps =
|
|
1127
|
+
elif "steps" in slice_node.attrs:
|
|
1128
|
+
steps = slice_node.attrs["steps"][0]
|
|
1129
|
+
|
|
1130
|
+
# Get the shape slice from Shape node (considering start/end attributes)
|
|
1131
|
+
full_shape = inp.shape
|
|
1132
|
+
num_dims = len(full_shape)
|
|
1133
|
+
|
|
1134
|
+
shape_start = shape_node.attrs.get("start", 0)
|
|
1135
|
+
shape_end = shape_node.attrs.get("end", None)
|
|
1136
|
+
|
|
1137
|
+
if shape_start < 0:
|
|
1138
|
+
shape_start = num_dims + shape_start
|
|
1139
|
+
if shape_end is None:
|
|
1140
|
+
shape_end = num_dims
|
|
1141
|
+
elif shape_end < 0:
|
|
1142
|
+
shape_end = num_dims + shape_end
|
|
1143
|
+
|
|
1144
|
+
shape_start = max(0, min(shape_start, num_dims))
|
|
1145
|
+
shape_end = max(0, min(shape_end, num_dims))
|
|
1146
|
+
|
|
1147
|
+
if shape_start > shape_end:
|
|
1148
|
+
return None
|
|
1149
|
+
|
|
1150
|
+
shape_slice = full_shape[shape_start:shape_end]
|
|
1060
1151
|
|
|
1061
|
-
|
|
1152
|
+
# Apply the Slice operation on the shape_slice
|
|
1153
|
+
shape = shape_slice[starts:ends:steps]
|
|
1062
1154
|
if misc.is_dynamic_shape(shape):
|
|
1063
1155
|
return None
|
|
1064
1156
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.79"
|
onnxslim-0.1.78/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.1.78
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.78"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/exporters/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/graph_pattern/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/importers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/logger/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onnxslim-0.1.78 → onnxslim-0.1.79}/onnxslim/third_party/onnx_graphsurgeon/util/exception.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|