TVM Runtime - Print Intermediate Outputs

How can I print output tensor values at different stages in the model during runtime?

Using get_output() on the GraphModule after run() gives the final output of the overall model. I was wondering if it was possible to dump the output of a specific operator (such as a specific convolution layer) in the graph during runtime?

You can use debug_executor to print all intermediate tensors.

1 Like

Thanks @comaniac! Can you please provide some more detail on how the debug_executor can be used to print all intermediate tensor values?

I see output_tensors.params being created in the dump folder. How can that file be read if it contains the intermediate values?

You can use follow snippet to load data from output_tensors.params into memory and then proceed analysis or dump in more suitable foprm

data = relay.load_param_dict(bytearray(open("./_tvmdbg_device_CPU_0/output_tensors.params", "rb").read()))

data will contain a map of output names to NDArray

1 Like

Thanks @elvin-n! This works.