[BYOC] Problem about subgraph with TupleTypeNode inputs

Now, I want to use BYOC to run SSD-ResNet34 model and I met some problems. About the “concatenate” operator, if it is a subgraph, the partitioned graph is:

def @ssdnn_0(%ssdnn_0_i0: (Tensor[(64, 4, 5776), float32], Tensor[(64, 4, 2166), float32], Tensor[(64, 4, 600), float32], Tensor[(64, 4, 150), float32], Tensor[(64, 4, 36), float32], Tensor[(64, 4, 4), float32]), Compiler="ssdnn", Inline=1, Primitive=1, global_symbol="ssdnn_0") -> Tensor[(64, 4, 8732), float32] {
  concatenate(%ssdnn_0_i0, axis=2) /* ty=Tensor[(64, 4, 8732), float32] */
}

After codegen, the cSource code is generated:

extern “C” int ssdnn_0_wrapper_(DLTensor* arg0, DLTensor* arg1) { ssdnn_0_(static_cast<float*>(arg0->data), static_cast<float*>(arg1->data)); return 0; }

extern “C” void ssdnn_0_(float* ssdnn_0_i0, float* out) { … ssdnn_concat(1, buf_0, 0, 2, 3, 64, 4, 8732, 1, ssdnn_0_i0); std::memcpy(out, buf_0->data(), 4 * 2235392); … }

The parameter of “ssdnn_0_i0” is a tupleTypeNode, But I need to know each field’s data after codegen. I wonder if there is any idear to get the each element of TupeTypeNode after codegen, or after graph partition, not input the TupleTypeNode but give each element of the TupleTypeNode? @comaniac @manupa-arm

1 Like

At this moment we suggest your codegen flatting a tuple here:

In addition, when processing concatenate nodes, your codegen can retrieve the tuple information when processing concatenate nodes by accessing their args.

Apart from that, it’s not recommended offloading concatenate nodes especially this subgraph contains only one concatenate node.

@mbaret : you may find this interesting.

I will have a try. Thanks very much.

Hi, welcome to the forum :slight_smile: I’m working on fixing this exact issue at the moment. It comes about because constant tuples are not correctly propagated into the partitioned regions so you can’t see the data of the tuple, only its type. I hope to have a fix in review either later today or tomorrow.

I have a candidate fix with this PR: https://github.com/apache/incubator-tvm/pull/5476

@mbaret the PR you posted solved the issue of tuple constant propagation, but it seems not solving the tuple var node issue. In this particular case, for example, we will still have a tuple of data in the first argument.