You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tvm.apache.org by Anil via TVM Discuss <no...@discuss.tvm.ai> on 2020/05/18 06:45:32 UTC
[TVM Discuss] [Development] Seeing many input placeholders in graph
json using BYOC
Hi Team,
After building the resnet18 example with BYOC, the resultant json file is showing lot of input nodes. Could you please check.?
Below is the code i have used for partition and compiling.
def _register_external_op_helper(op_name, supported=True):
@reg.register(op_name, "target.external_compiler")
def _func_wrapper(attrs, args):
return supported
return _func_wrapper
_register_external_op_helper("nn.conv2d")
#_register_external_op_helper("nn.dense")
_register_external_op_helper("nn.relu")
_register_external_op_helper("add")
_register_external_op_helper("multiply")
#_register_external_op_helper("nn.bias_add")
#_register_external_op_helper("nn.batch_flatten")
_register_external_op_helper("nn.max_pool2d")
_register_external_op_helper("nn.dropout")
_register_external_op_helper("nn.batch_norm")
_register_external_op_helper("nn.global_avg_pool2d")
block = get_model('resnet18_v1', pretrained=True)
mod, params = relay.frontend.from_mxnet(block, shape={'data': (1, 3, 224, 224)}, dtype='float32')
mod = relay.transform.AnnotateTarget("external_compiler")(mod)
mod = relay.transform.MergeCompilerRegions()(mod)
mod = relay.transform.PartitionGraph()(mod)
tvm_target='llvm'
graph, lib, params = relay.build(mod, tvm_target, params=params)
lib_kwargs = {}
lib.export_library("tvm_dpu_cpu.so", **lib_kwargs)
with open("tvm_cpu.json","w") as f:
f.write(graph)
rt_mod = tvm.contrib.graph_runtime.create(graph, lib, tvm.cpu())
**Example output:**
{
"nodes": [
{
"op": "null",
"name": "data",
"inputs": []
},
{
"op": "null",
"name": "p0",
"inputs": []
},
{
"op": "null",
"name": "p1",
"inputs": []
},
{
"op": "null",
"name": "p2",
"inputs": []
},
{
"op": "null",
"name": "p3",
"inputs": []
},
{
"op": "null",
"name": "p4",
"inputs": []
},
{
"op": "null",
"name": "p5",
"inputs": []
},
{
"op": "null",
"name": "p6",
"inputs": []
},
{
"op": "null",
"name": "p7",
"inputs": []
},
{
"op": "null",
"name": "p8",
"inputs": []
},
{
"op": "null",
"name": "p9",
"inputs": []
},
{
"op": "null",
"name": "p10",
"inputs": []
},
{
"op": "null",
"name": "p11",
"inputs": []
},
{
"op": "null",
"name": "p12",
"inputs": []
},
{
"op": "null",
"name": "p13",
"inputs": []
},
{
"op": "null",
"name": "p14",
"inputs": []
},
{
"op": "null",
"name": "p15",
"inputs": []
},
{
"op": "null",
"name": "p16",
"inputs": []
},
{
"op": "null",
"name": "p17",
"inputs": []
},
{
"op": "null",
"name": "p18",
"inputs": []
},
{
"op": "null",
"name": "p19",
"inputs": []
},
{
"op": "null",
"name": "p20",
"inputs": []
},
{
"op": "null",
"name": "p21",
"inputs": []
},
{
"op": "null",
"name": "p22",
"inputs": []
},
{
"op": "null",
"name": "p23",
"inputs": []
},
{
"op": "null",
"name": "p24",
"inputs": []
},
{
"op": "null",
"name": "p25",
"inputs": []
},
{
"op": "null",
"name": "p26",
"inputs": []
},
{
"op": "null",
"name": "p27",
"inputs": []
},
{
"op": "null",
"name": "p28",
"inputs": []
},
{
"op": "null",
"name": "p29",
"inputs": []
},
{
"op": "null",
"name": "p30",
"inputs": []
},
{
"op": "null",
"name": "p31",
"inputs": []
},
{
"op": "null",
"name": "p32",
"inputs": []
},
{
"op": "null",
"name": "p33",
"inputs": []
},
{
"op": "null",
"name": "p34",
"inputs": []
},
{
"op": "null",
"name": "p35",
"inputs": []
},
{
"op": "null",
"name": "p36",
"inputs": []
},
{
"op": "null",
"name": "p37",
"inputs": []
},
{
"op": "null",
"name": "p38",
"inputs": []
},
{
"op": "null",
"name": "p39",
"inputs": []
},
{
"op": "null",
"name": "p40",
"inputs": []
},
{
"op": "null",
"name": "p41",
"inputs": []
},
{
"op": "null",
"name": "p42",
"inputs": []
},
{
"op": "null",
"name": "p43",
"inputs": []
},
{
"op": "null",
"name": "p44",
"inputs": []
},
{
"op": "null",
"name": "p45",
"inputs": []
},
{
"op": "null",
"name": "p46",
"inputs": []
},
{
"op": "null",
"name": "p47",
"inputs": []
},
{
"op": "null",
"name": "p48",
"inputs": []
},
{
"op": "null",
"name": "p49",
"inputs": []
},
{
"op": "null",
"name": "p50",
"inputs": []
},
{
"op": "null",
"name": "p51",
"inputs": []
},
{
"op": "null",
"name": "p52",
"inputs": []
},
{
"op": "null",
"name": "p53",
"inputs": []
},
{
"op": "null",
"name": "p54",
"inputs": []
},
{
"op": "null",
"name": "p55",
"inputs": []
},
{
"op": "null",
"name": "p56",
"inputs": []
},
{
"op": "null",
"name": "p57",
"inputs": []
},
{
"op": "null",
"name": "p58",
"inputs": []
},
{
"op": "null",
"name": "p59",
"inputs": []
},
{
"op": "null",
"name": "p60",
"inputs": []
},
{
"op": "null",
"name": "p61",
"inputs": []
},
{
"op": "null",
"name": "p62",
"inputs": []
},
{
"op": "null",
"name": "p63",
"inputs": []
},
{
"op": "null",
"name": "p64",
"inputs": []
},
{
"op": "null",
"name": "p65",
"inputs": []
},
{
"op": "null",
"name": "p66",
"inputs": []
},
{
"op": "null",
"name": "p67",
"inputs": []
},
{
"op": "null",
"name": "p68",
"inputs": []
},
{
"op": "null",
"name": "p69",
"inputs": []
},
{
"op": "null",
"name": "p70",
"inputs": []
},
{
"op": "null",
"name": "p71",
"inputs": []
},
{
"op": "null",
"name": "p72",
"inputs": []
},
{
"op": "null",
"name": "p73",
"inputs": []
},
{
"op": "null",
"name": "p74",
"inputs": []
},
{
"op": "null",
"name": "p75",
"inputs": []
},
{
"op": "null",
"name": "p76",
"inputs": []
},
{
"op": "null",
"name": "p77",
"inputs": []
},
{
"op": "null",
"name": "p78",
"inputs": []
},
{
"op": "null",
"name": "p79",
"inputs": []
},
{
"op": "null",
"name": "p80",
"inputs": []
},
{
"op": "null",
"name": "p81",
"inputs": []
},
{
"op": "null",
"name": "p82",
"inputs": []
},
{
"op": "null",
"name": "p83",
"inputs": []
},
{
"op": "null",
"name": "p84",
"inputs": []
},
{
"op": "null",
"name": "p85",
"inputs": []
},
{
"op": "null",
"name": "p86",
"inputs": []
},
{
"op": "null",
"name": "p87",
"inputs": []
},
{
"op": "null",
"name": "p88",
"inputs": []
},
{
"op": "null",
"name": "p89",
"inputs": []
},
{
"op": "null",
"name": "p90",
"inputs": []
},
{
"op": "null",
"name": "p91",
"inputs": []
},
{
"op": "null",
"name": "p92",
"inputs": []
},
{
"op": "null",
"name": "p93",
"inputs": []
},
{
"op": "null",
"name": "p94",
"inputs": []
},
{
"op": "null",
"name": "p95",
"inputs": []
},
{
"op": "null",
"name": "p96",
"inputs": []
},
{
"op": "null",
"name": "p97",
"inputs": []
},
{
"op": "null",
"name": "p98",
"inputs": []
},
{
"op": "null",
"name": "p99",
"inputs": []
},
{
"op": "tvm_op",
"name": "external_compiler_0",
"attrs": {
"num_outputs": "1",
"num_inputs": "101",
"func_name": "ccompiler_0",
"flatten_data": "0"
},
"inputs": [
[
0,
0,
0
],
[
1,
0,
0
],
[
2,
0,
0
],
[
3,
0,
0
],
[
4,
0,
0
],
[
5,
0,
0
],
[
6,
0,
0
],
[
7,
0,
0
],
[
8,
0,
0
],
[
9,
0,
0
],
[
10,
0,
0
],
[
11,
0,
0
],
[
12,
0,
0
],
[
13,
0,
0
],
[
14,
0,
0
],
[
15,
0,
0
],
[
16,
0,
0
],
[
17,
0,
0
],
[
18,
0,
0
],
[
19,
0,
0
],
[
20,
0,
0
],
[
21,
0,
0
],
[
22,
0,
0
],
[
23,
0,
0
],
[
24,
0,
0
],
[
25,
0,
0
],
[
26,
0,
0
],
[
27,
0,
0
],
[
28,
0,
0
],
[
29,
0,
0
],
[
30,
0,
0
],
[
31,
0,
0
],
[
32,
0,
0
],
[
33,
0,
0
],
[
34,
0,
0
],
[
35,
0,
0
],
[
36,
0,
0
],
[
37,
0,
0
],
[
38,
0,
0
],
[
39,
0,
0
],
[
40,
0,
0
],
[
41,
0,
0
],
[
42,
0,
0
],
[
43,
0,
0
],
[
44,
0,
0
],
[
45,
0,
0
],
[
46,
0,
0
],
[
47,
0,
0
],
[
48,
0,
0
],
[
49,
0,
0
],
[
50,
0,
0
],
[
51,
0,
0
],
[
52,
0,
0
],
[
53,
0,
0
],
[
54,
0,
0
],
[
55,
0,
0
],
[
56,
0,
0
],
[
57,
0,
0
],
[
58,
0,
0
],
[
59,
0,
0
],
[
60,
0,
0
],
[
61,
0,
0
],
[
62,
0,
0
],
[
63,
0,
0
],
[
64,
0,
0
],
[
65,
0,
0
],
[
66,
0,
0
],
[
67,
0,
0
],
[
68,
0,
0
],
[
69,
0,
0
],
[
70,
0,
0
],
[
71,
0,
0
],
[
72,
0,
0
],
[
73,
0,
0
],
[
74,
0,
0
],
[
75,
0,
0
],
[
76,
0,
0
],
[
77,
0,
0
],
[
78,
0,
0
],
[
79,
0,
0
],
[
80,
0,
0
],
[
81,
0,
0
],
[
82,
0,
0
],
[
83,
0,
0
],
[
84,
0,
0
],
[
85,
0,
0
],
[
86,
0,
0
],
[
87,
0,
0
],
[
88,
0,
0
],
[
89,
0,
0
],
[
90,
0,
0
],
[
91,
0,
0
],
[
92,
0,
0
],
[
93,
0,
0
],
[
94,
0,
0
],
[
95,
0,
0
],
[
96,
0,
0
],
[
97,
0,
0
],
[
98,
0,
0
],
[
99,
0,
0
],
[
100,
0,
0
]
]
},
{
"op": "tvm_op",
"name": "fused_nn_batch_flatten",
"attrs": {
"num_outputs": "1",
"num_inputs": "1",
"func_name": "fused_nn_batch_flatten",
"flatten_data": "0"
},
"inputs": [
[
101,
0,
0
]
]
},
{
"op": "null",
"name": "p100",
"inputs": []
},
{
"op": "null",
"name": "p101",
"inputs": []
},
{
"op": "tvm_op",
"name": "fused_nn_dense_nn_bias_add",
"attrs": {
"num_outputs": "1",
"num_inputs": "3",
"func_name": "fused_nn_dense_nn_bias_add",
"flatten_data": "0"
},
"inputs": [
[
102,
0,
0
],
[
103,
0,
0
],
[
104,
0,
0
]
]
}
],
"arg_nodes": [
0,
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,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
103,
104
],
"heads": [
[
105,
0,
0
]
],
"attrs": {
"dltype": [
"list_str",
[
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32",
"float32"
]
],
"shape": [
"list_shape",
[
[1, 3, 224, 224],
[64, 3, 7, 7],
[64],
[64],
[64],
[64],
[64, 64, 3, 3],
[64],
[64],
[64],
[64],
[64, 64, 3, 3],
[64],
[64],
[64],
[64],
[64, 64, 3, 3],
[64],
[64],
[64],
[64],
[64, 64, 3, 3],
[64],
[64],
[64],
[64],
[128, 64, 1, 1],
[128],
[128],
[128],
[128],
[128, 64, 3, 3],
[128],
[128],
[128],
[128],
[128, 128, 3, 3],
[128],
[128],
[128],
[128],
[128, 128, 3, 3],
[128],
[128],
[128],
[128],
[128, 128, 3, 3],
[128],
[128],
[128],
[128],
[256, 128, 1, 1],
[256],
[256],
[256],
[256],
[256, 128, 3, 3],
[256],
[256],
[256],
[256],
[256, 256, 3, 3],
[256],
[256],
[256],
[256],
[256, 256, 3, 3],
[256],
[256],
[256],
[256],
[256, 256, 3, 3],
[256],
[256],
[256],
[256],
[512, 256, 1, 1],
[512],
[512],
[512],
[512],
[512, 256, 3, 3],
[512],
[512],
[512],
[512],
[512, 512, 3, 3],
[512],
[512],
[512],
[512],
[512, 512, 3, 3],
[512],
[512],
[512],
[512],
[512, 512, 3, 3],
[512],
[512],
[512],
[512],
[1, 512, 1, 1],
[1, 512],
[1000, 512],
[1000],
[1, 1000]
]
],
"storage_id": [
"list_int",
[
0,
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,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
101
]
]
},
"node_row_ptr": [
0,
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,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106
]
}
---
[Visit Topic](https://discuss.tvm.ai/t/seeing-many-input-placeholders-in-graph-json-using-byoc/6708/1) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/c2f93d98abbe6db18b105010c6928cafacdb55c8ad8177f6f279f11d4db81e13).
[TVM Discuss] [Development] Seeing many input placeholders in graph
json using BYOC
Posted by Anil via TVM Discuss <no...@discuss.tvm.ai>.
@comaniac
I printed the mod value after partition. It is coming correctly. I found the problem with my setup. The issue has been solved now.
---
[Visit Topic](https://discuss.tvm.ai/t/seeing-many-input-placeholders-in-graph-json-using-byoc/6708/3) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/d774853e692336288b6d78da69384ebfbf569dcb0b5f03232be00bf3490b841f).
[TVM Discuss] [Development] Seeing many input placeholders in graph
json using BYOC
Posted by "Cody H. Yu via TVM Discuss" <no...@discuss.tvm.ai>.
Considering the weight of every layer will be an individual input, it might be fine.
Could you print out the graph after the partition pass? For example:
```
print(mod)
mod = relay.transform.AnnotateTarget("external_compiler")(mod)
mod = relay.transform.MergeCompilerRegions()(mod)
mod = relay.transform.PartitionGraph()(mod)
print(mod)
```
So that we can compare if the second printed module was correctly partitioned.
---
[Visit Topic](https://discuss.tvm.ai/t/seeing-many-input-placeholders-in-graph-json-using-byoc/6708/2) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/4904aa757ef0f07720d764244780c3a2d5c511acef7b3dd996928de62dc72d6e).