예제 #1
0
    def DeepArchNet(self, tensor):
        tensor1 = self.Conv2d(tensor, out_c=50, size=(
            8, 1), stride=(1, 1), padding=0)
        tensor2 = self.Conv2d(tensor1, out_c=50, size=(
            8, 1), stride=(1, 1), padding=0)
        tensor3 = self.Conv2d(tensor2, out_c=50, size=(
            8, 1), stride=(1, 1), padding=0)
        tensor1 = Tensor(tensor1.h, tensor1.c, tensor1.w)
        tensor3 = Tensor(tensor3.h, tensor3.c, tensor3.w)
        tensor = self.Concat([tensor1, tensor3])
        tensor_after_concat = Tensor(1, tensor.h*tensor.w, tensor.c)
        tensor = self.LSTM(tensor_after_concat, 11, 0)

        return tensor
예제 #2
0
 def calculate(self):
     '''
     This function calculates the FLOPs
     '''
     tensor = Tensor(1, 128, 2)
     tensor = self.IntroNet(tensor)
     print('params: {}, flops: {}'.format(self.params, self.flops))
예제 #3
0
 def calculate(self):
     tensor = Tensor(1, 128, 2)
     tensor = self.DeepArchNet(tensor)
     print('params: {}, flops: {}'.format(self.params, self.flops))
예제 #4
0
 def calculate(self):
     tensor = Tensor(1, 2000, 600)
     tensor = self.DistLearnWscNet(tensor)
     print('params: {}, flops: {}'.format(self.params, self.flops))
예제 #5
0
 def calculate(self):
     tensor = Tensor(1, 64, 64)
     tensor = self.SpecMonitorForRadarNet(tensor)
     print('params: {}, flops: {}'.format(self.params, self.flops))
예제 #6
0
        out.w *= self.num_heads
        return self.Linear(out, 768)

    def OutputEmbedding(self, input):
        intermediate = self.Linear(input, 3072)
        act = self.ReLU(intermediate)
        out = self.Linear(act, 768)
        return out

    def BertLayer(self, embeddings):
        att = self.SelfAttention(embeddings)
        residual_att = self.Add(att, embeddings)
        norm_att = self.LayerNorm(residual_att)
        out = self.OutputEmbedding(norm_att)
        residual_out = self.Add(out, norm_att)
        norm_out = self.LayerNorm(residual_out)
        return norm_out

    def pipeline(self, embeddings):
        for i in range(12):
            embeddings = self.BertLayer(embeddings)

        return embeddings


if __name__ == '__main__':

    cal = BERTCalc(only_mac=True)
    res = cal.pipeline(Tensor(1, 320, 768))
    res.peek()
    print("flops: ", cal.flops / 1e6)
예제 #7
0
 def calculate(self):
     tensor = Tensor(1, 128, 2)
     tensor = self.ConvRadioModRecogNet(tensor)
     print('params: {}, flops: {}'.format(self.params, self.flops))