File size: 1,836 Bytes
ce847d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Inspect custom ops in models 11, 12, 22, 33 to determine exact op names and domains."""
import onnx
from pathlib import Path

models_dir = Path("oneocr_extracted/onnx_models")

for idx in [11, 12, 22, 33]:
    matches = list(models_dir.glob(f"model_{idx:02d}_*"))
    if not matches:
        print(f"model_{idx:02d}: NOT FOUND")
        continue
    
    model = onnx.load(str(matches[0]))
    print(f"\n{'='*60}")
    print(f"model_{idx:02d}: {matches[0].name}")
    print(f"  IR version: {model.ir_version}")
    print(f"  Opset imports: {[(o.domain, o.version) for o in model.opset_import]}")
    
    # Find all non-standard ops
    for node in model.graph.node:
        if node.domain and node.domain != "":
            print(f"  Node: op_type={node.op_type!r}, domain={node.domain!r}")
            print(f"    inputs:  {list(node.input)}")
            print(f"    outputs: {list(node.output)}")
            # Print attributes
            for attr in node.attribute:
                if attr.type == 2:  # INT
                    print(f"    attr {attr.name} = {attr.i}")
                elif attr.type == 1:  # FLOAT
                    print(f"    attr {attr.name} = {attr.f}")
                elif attr.type == 3:  # STRING
                    print(f"    attr {attr.name} = {attr.s.decode()!r}")
                elif attr.type == 4:  # TENSOR
                    t = attr.t
                    print(f"    attr {attr.name} = tensor(dtype={t.data_type}, dims={list(t.dims)}, raw_bytes={len(t.raw_data)})")
    
    # Also show graph inputs/outputs
    print(f"  Graph inputs: {[(i.name, [d.dim_value or d.dim_param for d in i.type.tensor_type.shape.dim]) for i in model.graph.input]}")
    print(f"  Graph outputs: {[(o.name, [d.dim_value or d.dim_param for d in o.type.tensor_type.shape.dim]) for o in model.graph.output]}")