test7.py 753 Bytes
Newer Older
zk's avatar
zk committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import onnx
import numpy as np
from onnx import numpy_helper

model = onnx.load("weights/ground.onnx")

# 找所有 initializer
init_map = {i.name: numpy_helper.to_array(i) for i in model.graph.initializer}

for node in model.graph.node:
    if node.op_type == "Gather":
        index_name = node.input[1]

        if index_name in init_map:
            idx = init_map[index_name]

            print("\n🚨 Gather index:", index_name)
            print("dtype:", idx.dtype)
            print("min:", idx.min())
            print("max:", idx.max())
            print("shape:", idx.shape)

            if (idx < 0).any():
                print("❌ NEGATIVE index")

            if (idx > 10000).any():
                print("❌ SUSPICIOUS LARGE index")