You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to request the support of the torch.nn.Unfold function, or a numpy equivalent.
Motivation
I am trying to do some convolutions that do different operations than regular convolutions on each kernels, therefore I would need to use a way of reorganising the images into each kernel.
I am doing it with numpy but it is quite inefficient:
defconv2D_unfold_deep(image, ratio, ksize=(1, 1), pad=0, stride=1):
"""Return the indices used in the 2D convolution"""nfilters, height, width=image.shape# arr = np.array(list(range(height * width))).reshape((image.shape))kernel_height, kernel_width=ksizeoutput_height=int((height+2*pad-kernel_height) /stride) +1output_width=int((width+2*pad-kernel_width) /stride) +1out=fhe.zeros((nfilters//ratio, output_height, output_width, kernel_height*kernel_width*ratio))
forfinrange(0,nfilters,ratio):
forhinrange(output_height):
forwinrange(output_width):
h_start=h*strideh_end=h_start+kernel_heightw_start=w*stridew_end=w_start+kernel_width# Get the receptive_field# pad image # shape (B, 8, 10, 10)receptive_field=image[f:f+ratio, h_start:h_end, w_start:w_end].reshape(
(kernel_height*kernel_width*ratio)) # shape(B, 6) binaire# transform input 0/1 into int between [0 ; 2**n-1]out[f//ratio, h, w, :] =receptive_field# output_var_unfoldreturnout.astype(int)
which is very inefficient because of the three for loops.
I could do it with indexing but it is not supported by concrete:
Hello, here is the PR to implement fancy indexing zama-ai/concrete#640. It's ready to merge and will probably be merged soon! You'll have it in the next release of Concrete, v2.5.0 😉
Feature request
I would like to request the support of the torch.nn.Unfold function, or a numpy equivalent.
Motivation
I am trying to do some convolutions that do different operations than regular convolutions on each kernels, therefore I would need to use a way of reorganising the images into each kernel.
I am doing it with numpy but it is quite inefficient:
which is very inefficient because of the three for loops.
I could do it with indexing but it is not supported by concrete:
returns :
The text was updated successfully, but these errors were encountered: