MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / fw_conv

Function fw_conv

utils/resize_right/resize_right.py:403–414  ·  view source on GitHub ↗
(input, filter, stride)

Source from the content-addressed store, hash-verified

401
402
403def fw_conv(input, filter, stride):
404 # we want to apply 1d conv to any nd array. the way to do it is to reshape
405 # the input to a 4D tensor. first two dims are singeletons, 3rd dim stores
406 # all the spatial dims that we are not convolving along now. then we can
407 # apply conv2d with a 1xK filter. This convolves the same way all the other
408 # dims stored in the 3d dim. like depthwise conv over these.
409 # TODO: numpy support
410 reshaped_input = input.reshape(1, 1, -1, input.shape[-1])
411 reshaped_output = torch.nn.functional.conv2d(reshaped_input,
412 filter.view(1, 1, 1, -1),
413 stride=(1, stride))
414 return reshaped_output.reshape(*input.shape[:-1], -1)
415
416
417def fw_arange(upper_bound, fw, device):

Callers 1

apply_convsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected