I have a custom PyTorch model, the inputs are of the model as like this:
model(torch.randint(0, 10,(1,1)), torch.rand(1, 51, 2048), torch.randint(0, 10,(1, 1))).
I am trying to speed benchmark this model with Android, but I am unable to understand how I should use the “input_dims” and “input_type” parameters as this model involves a mix of float and integer types.
An update:
I checked the speed_benchmark_torch.cc file. It specifies “If multiple input needed, use semicolon to separate the dimension of different tensors.”
Therefore, I tried: --input_dims=“1,1;1,51,2048;1,1” --input_type=“int64;float;int64”.
This results in error:
terminating with uncaught exception of type c10::Error: [enforce fail at speed_benchmark_torch.cc:111] input_dims_list.size() == input_type_list.size(). 1 vs 0. Input dims and type should have the same number of items.
I had the same problem. The solution is to put an escape character before ;, so the parameters should look like --input_dims=“1,2\;1,2,3\;5,6,7” --input_type=“float\;float\;uint8_t” for example. Also, the script will require you to specify the memory format: --input_memory_format="contiguous_format\;contiguous_format\;contiguous_format", for example (contiguous_format is the default value).