コード例 #1
0
    def forward(self, x, out_channel=None):
        if out_channel is None:
            out_channel = self.active_out_channel
        in_channel = x.size(1)
        filters = self.conv.weight[:out_channel, :in_channel, :, :].contiguous()

        padding = get_same_padding(self.kernel_size)
        y = F.conv2d(x, filters, None, self.stride, padding, self.dilation, 1)
        return y
コード例 #2
0
    def forward(self, x, kernel_size=None):
        if kernel_size is None:
            kernel_size = self.active_kernel_size
        in_channel = x.size(1)

        filters = self.get_active_filter(in_channel, kernel_size).contiguous()

        padding = get_same_padding(kernel_size)
        y = F.conv2d(x, filters, None, self.stride, padding, self.dilation,
                     in_channel)
        return y
コード例 #3
0
    def forward(self, x, kernel_size=None):
        if kernel_size is None:
            kernel_size = self.active_kernel_size
        in_channel = x.size(1)

        filters = self.get_active_filter(in_channel, kernel_size).contiguous()
        inputs, weight, bias = self._quantize(inputs=x, weight=filters, bias=None)

        padding = get_same_padding(kernel_size)
        y = F.conv2d(
            inputs, weight, None, self.stride, padding, self.dilation, in_channel
        )
        return y
コード例 #4
0
    def forward(self, x, out_channel=None):
        if out_channel is None:
            out_channel = self.active_out_channel
        in_channel = x.size(1)
        filters = self.conv.weight[:out_channel, :in_channel, :, :].contiguous(
        )

        x_quant, w_quant = self.conv.get_quant_x_w(x, filters)
        padding = get_same_padding(self.kernel_size)
        #if hvd.rank()==0:
        #    print('point',x.size(),filters.size(),x_quant[0][0][0][0].detach()/self.conv.sa.detach(),w_quant[0][0][0][0].detach()/self.conv.sw.detach())
        y = F.conv2d(x_quant, w_quant, None, self.stride, padding,
                     self.dilation, 1)
        return y
コード例 #5
0
    def forward(self, x, kernel_size=None):
        if kernel_size is None:
            kernel_size = self.active_kernel_size
        in_channel = x.size(1)

        filters = self.get_active_filter(in_channel, kernel_size).contiguous()

        padding = get_same_padding(kernel_size)
        x_quant, w_quant = self.conv.get_quant_x_w(x, filters)

        #if hvd.rank() == 0:
        #    print('depth',x.size(),filters.size(),x_quant[0][0][0][0].detach()/self.conv.sa.detach(),w_quant[0][0][0][0].detach()/self.conv.sw.detach())
        y = F.conv2d(x_quant, w_quant, None, self.stride, padding,
                     self.dilation, in_channel)
        return y