Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using slayer.block.cuba.Pool, input-output dimensions are not as expected. #293

Open
LjubicaCimesa opened this issue Mar 11, 2024 · 2 comments
Assignees
Labels
1-bug Something isn't working

Comments

@LjubicaCimesa
Copy link

Steps to reproduce the behavior:

  1. When I run this code
import torch
input = torch.randn(1,8,6,7,160)
CL= slayer.block.cuba.Pool(neuron_params, kernel_size =(2,2) , stride = 2, padding =0)
output = CL(input)
output.shape
  1. I get output of shape [1, 8, 3, 4, 160]

Expected behavior

After pooling, I expected to get the shape [1,8,3,3,160]

Environment (please complete the following information):

  • Device: Laptop MAC
  • OS: MAC Sonoma 14.3.1 (23D60)
  • Lava version [e.g. 0.5.0]
@PhilippPlank
Copy link
Contributor

Thank you for you question. @bamsumit Could you take a look at it?

@RinoReyns
Copy link

@LjubicaCimesa, I believe pooling does produce unexpected results, but the value that you expect is also incorrect. Let me explain what I understand and please correct me if I'm wrong.

  1. Slayer works on 3D Matrixes. Thus, underneath you have 3D pool implemented with 3D conv. See following link to implementation. So in fact the kernel would be kernel_size=(2,2,1)
  2. When you will use pytorch and run 3D pooling with tensor of the same shape that you proposed you will see result as follow:
 input_data = torch.randn(1,8,6,7,160)
 pool_3d = torch.nn.MaxPool3d(kernel_size=(2,2,1), stride=2, padding=0)
 output_pool= pool_3d (input)
 print(output_pool.shape)
>> torch.Size([1, 8, 3, 3, 80])
  1. I believe pytorch implementation is reference and I treat it like that.
  2. Since pooling is non-trainable operation and in slayer is implemented as a synapse, then is it pass to the neuron part, thus I believe instead of 3D conv it could be implemented with pytorch 3D pooling. Unless there are some restrictions of HW or model's export procedure that I'm not aware that requires 3D conv with given orientation. However, in that mater @bamsumit would need to explain why pooling in slayer is implemented with 3D conv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants