Closed jiangwei221 closed 9 months ago
@jiangwei221 Thanks for reporting! I can repro the error. Will look into it and circle back.
@jiangwei221 So the error you're getting is due to the way reshape
is implemented in AIT.
To resolve the error, replace this line
sample = reshape()(sample, [batch_size * num_frames, channel, height, width])
with this line
sample = reshape()(sample, [-1, channel, height, width])
This makes compilation run successfully. However, the outputs of your PT and AIT models don't match. So, I assume, something is not equivalent in the implementation. Let me know if you need help figuring that out.
I see, thanks a lot! A follow-up question is that if I want to do something like:
sample = reshape()(sample, [batch_size * num_frames, height * width, channel])
Where 1st & 2nd dims are merged, and 3rd&4th dims are also merged. In this case, what should I do?
Good question. I believe, it should work in general. The issue in your case may be related to the batch_size
being an IntImm
(fixed / static dim) and num_frames
being an IntVar
(dynamic dim). Although it should work. I'll look into it and let you know what's happening there.
Ok, so here's what is happening. aitemplate.Tensor.shape()
method is actually meant to be used in the IR, and not in the AIT model code hand-written by the user. What I'd suggest using instead is the size
operator. So if you from aitemplate.compiler.ops import reshape, permute, size
and do this in the MyConvNetAit.forward
:
batch_size, num_frames, channel, height, width = size()(sample)
your original code will work just fine. And then you can do any (basic: +, -, *, //) arithmetics on the dims, static or dynamic. Hope this helps.
Hey @aakhundov , after I changed all x.shape()
to size()(x)
, everything works now!
Except for certain model it will return a gcc internal error as mentioned in #980 , but it can be easily solved by upgrading gcc9 to gcc10.
Thanks a lot for your help!
Hi AIT team:
I'm working on a video model based on stable diffusion, and my input tensor is in shape [batch, frame, channel, height, width]. In order to pass this tensor to the conv2d layer, I have to first merge
batch
andframe
dimensions, and permute the channel to the 4th position. Following is the minimum code to reproduce theUnsupported workload for this conv2d specialization
error.Do you have any ideas why I can't execute this model? Could it be a hardware/environment issue or a limitation of current version of AIT? Thanks a lot!