-
Notifications
You must be signed in to change notification settings - Fork 23
/
op_coverage.rb
executable file
·60 lines (52 loc) · 1.35 KB
/
op_coverage.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/ruby
passing_node_tests = []
File.readlines('scripts/runtests.py').each do |line|
next if line =~ /^ *#/
if line =~ /TestCase\(NODE_TEST, '(.*?)'/
passing_node_tests << $1
end
end
node_tests = Dir.glob(
'third_party/onnx/onnx/backend/test/data/node/*').map do |f|
File.basename(f)
end
onnx_ops = []
File.readlines('third_party/onnx/docs/Operators.md').each do |line|
if line =~ /^ \* <a href="#(.*?)"/
onnx_ops << $1
end
end
grad_ops = []
File.readlines('compiler/gradient_ops.cc').each do |line|
if line =~ /^ *register_grad_fn\(Node::k(.*?), /
grad_ops << $1
end
end
ops = []
File.readlines('compiler/gen_node.py').each do |line|
if line !~ /^NodeDef\('(.*?)'/
next
end
ops << $1
end
def categorize(ops)
supported_ops = []
chainer_ops = []
ops.each do |op|
if op =~ /^Chainer/
chainer_ops << op
else
supported_ops << op
end
end
[supported_ops, chainer_ops]
end
supported_ops, chainer_ops = categorize(ops)
grad_onnx_ops, _ = categorize(grad_ops)
puts "Failing node tests:"
puts (node_tests - passing_node_tests).sort * "\n"
puts "Missing ops: #{onnx_ops - supported_ops}"
puts "Node tests: #{passing_node_tests.size}/#{node_tests.size}"
puts "Custom ops: #{chainer_ops.size}"
puts "Differentiable ops: #{grad_onnx_ops.size}"
puts "Supported ops: #{supported_ops.size}/#{onnx_ops.size}"