Open phamkhactu opened 6 months ago
Hey @phamkhactu from the error message "indices element out of data bounds, idx=2 must be within the inclusive range [-2,1]" it seems that the model is sensitive to the input data provided since it uses that as an index for a Gather operation. Could you try manually making an input of all zeros and passing that in? You could also precisely set the input shapes using the input_shapes=
parameter
Hi @mgoin
With your suggestion I tried, but I don't know the way to pass input_shapes because input_shapes list[list[int]].
Here is my onnx model. And my code below procedures my convert to tts_model.onnx
dummy_input_length = 100
sequences = torch.randint(low=0, high=2, size=(1, dummy_input_length), dtype=torch.long)
sequence_lengths = torch.LongTensor([sequences.size(1)])
scales = torch.FloatTensor([0.68, 1.0, 1.0])
dummy_input = (sequences, sequence_lengths, scales)
input_names = ["input", "input_lengths", "scales"]
speaker_id = torch.LongTensor([0])
dummy_input += (speaker_id,)
input_names.append("sid")
torch.onnx.export(
model=self,
args=dummy_input,
opset_version=15,
f=output_path,
verbose=verbose,
input_names=input_names,
output_names=["output"],
dynamic_axes={
"input": {0: "batch_size", 1: "phonemes"},
"input_lengths": {0: "batch_size"},
"output": {0: "batch_size", 1: "time1", 2: "time2"},
},
)
I tried to test with deepsparse but getting error:
from deepsparse import compile_model
from deepsparse.utils import generate_random_inputs
import torch
import numpy as np
onnx_filepath = "tts_model.onnx"
batch_size = 1
# Generate random sample input
inputs = generate_random_inputs(onnx_filepath, batch_size)
# Compile and run
engine = compile_model(onnx_filepath, batch_size)
print(engine)
dummy_input_length = 100
sequences = torch.randint(low=0, high=2, size=(1, dummy_input_length), dtype=torch.long).cpu().numpy()
sequence_lengths = np.array([sequences.shape[1]], dtype=np.int64)
scales = np.array([0.68, 1.0, 1.0],dtype=np.float32,)
speaker_id = torch.tensor([0]).cpu().numpy()
outputs = engine.run([[sequences, sequence_lengths, scales, speaker_id]])
ValueError: array batch size of 3 must match the batch size the model was instantiated with 1
I am very happy with your help.
I tried to convert onnx model with dynamic batch size into deepsparse
I have error:
How can I use deepsparse?
Thank you very much!