Beispiel #1
0
 def get_flops(self, x):
   flop1 = utils.count_conv_flop(self.inverted_bottleneck.conv, x)
   x = self.inverted_bottleneck(x)
   flop2 = utils.count_conv_flop(self.depth_wise.conv, x)
   x = self.depth_wise(x)
   flop3 = utils.count_conv_flop(self.point_wise.conv, x)
   x = self.point_wise(x)
   return flop1 + flop2 + flop3, x 
Beispiel #2
0
    def get_flops(self, input_size):
        flop_1 = count_conv_flop(self.conv_1, input_size)
        if self.stride > 1:
            input_size = (input_size[0] // self.stride,
                          input_size[1] // self.stride)
        flop_2 = count_conv_flop(self.conv_2, input_size)
        print(
            'DilConv:   Flops:  {:.2e}, input_size: {} ,in_c : {} , out_c: {} , kernel: {} , stride: {} '
            .format(flop_1 + flop_2, input_size, self.in_channels,
                    self.out_channels, self.kernel_size, self.stride))

        return flop_1 + flop_2
Beispiel #3
0
    def get_flops(self, x):
        if self.inverted_bottleneck:
            flop1 = count_conv_flop(self.inverted_bottleneck.conv, x)
            x = self.inverted_bottleneck(x)
        else:
            flop1 = 0

        flop2 = count_conv_flop(self.depth_conv.conv, x)
        x = self.depth_conv(x)

        flop3 = count_conv_flop(self.point_linear.conv, x)
        x = self.point_linear(x)
        return flop1 + flop2 + flop3, x
Beispiel #4
0
 def get_flops(self, input_size):
     f_depth_1 = count_conv_flop(self.conv_1_1, input_size)
     if self.stride > 1:
         input_size = (input_size[0] // self.stride,
                       input_size[1] // self.stride)
     f_point_1 = count_conv_flop(self.conv_1_2, input_size)
     f_depth_2 = count_conv_flop(self.conv_2_1, input_size)
     f_point_2 = count_conv_flop(self.conv_2_2, input_size)
     f_sum = f_depth_1 + f_depth_2 + f_point_1 + f_point_2
     print(
         'SepConv:   Flops:  {:.2e}, input_size: {} ,in_c : {} , out_c: {} , kernel: {} , stride: {} '
         .format(f_sum, input_size, self.in_channels, self.out_channels,
                 self.kernel_size, self.stride))
     return f_sum
Beispiel #5
0
 def get_flops(self, input_size):
     flop = count_conv_flop(self.conv, input_size)
     print(
         'ReLBN:   Flops:  {:.2e}, input_size: {} ,in_c : {} , out_c: {} , kernel: {} , stride: {} '
         .format(flop, input_size, self.in_channels, self.out_channels,
                 self.kernel_size, self.stride))
     return flop
Beispiel #6
0
 def get_flops(self, x):
     flop = utils.count_conv_flop(self.first_conv, x)
     x = self.first_conv(x)
     x = self.stem(x)
     mb_flop, x = self.mbconv3.get_flops(x)
     flop += mb_flop
     for model in self.layers:
         layer = model.MixedOp
         layer_flop, x = layer.active_op.get_flops(x)
         flop += layer_flop
     post_flop, x = self.post.get_flops(x)
     flop += post_flop
     x = self.global_pooling(x)
     flop += self.classifier.weight.numel()
     x = self.classifier(x.view(x.size(0), -1))
     return flop
Beispiel #7
0
 def get_flops(self, input_size):
     f_1 = count_conv_flop(self.conv_1, input_size)
     f_2 = count_conv_flop(self.conv_2, input_size)
     return f_1 + f_2
Beispiel #8
0
 def get_flops(self, x):
     depth_flop = count_conv_flop(self.depth_conv, x)
     point_flop = count_conv_flop(self.point_conv, self.depth_conv(x))
     return depth_flop + point_flop, self.forward(x)
Beispiel #9
0
 def get_flops(self, x):
     return count_conv_flop(self.conv, x), self.forward(x)