示例#1
0
 def __init__(self, input_ndim, *args, **kwargs):
   super(TorchTranspose, self).__init__(NNDCT_OP.TRANSPOSE, *args, **kwargs)
   utils.op_register(NNDCT_OP.TRANSPOSE, 'transpose')
   self._input_ndim = input_ndim
   self._dim0 = None
   self._dim1 = None
   self._attr_value_mem[self.AttrName.ORDER][:] = list(range(input_ndim))
示例#2
0
 def __init__(self, *args, **kwargs):
   super(TorchAdaptiveAvgPool, self).__init__(NNDCT_OP.ADAPTIVEAVGPOOL2D,
                                              *args, **kwargs)
   utils.op_register(NNDCT_OP.ADAPTIVEAVGPOOL2D, 'AdaptiveAvgPool2d')
   # set default value
   self.set_attr(self.AttrName.KERNEL, [1, 1])
   self.set_attr(self.AttrName.STRIDE, [1, 1])
   self.set_attr(self.AttrName.PAD_MODE, 0)
示例#3
0
 def __init__(self,
              nndct_op_type,
              torch_op_type=None,
              force_to_primitive=False):
     super().__init__(nndct_op_type)
     if torch_op_type is not None:
         utils.op_register(nndct_op_type,
                           torch_op_type,
                           force_to_primitive=force_to_primitive)
示例#4
0
 def __init__(self,
              nndct_op_type,
              torch_op_type,
              force_to_primitive=False,
              schema=None,
              *args,
              **kwargs):
     super().__init__(nndct_op_type, *args, **kwargs)
     utils.op_register(nndct_op_type,
                       torch_op_type,
                       force_to_primitive=force_to_primitive,
                       schema=schema)
示例#5
0
    def __init__(self, dim):
        if dim == 2 or dim == 3:
            nndct_op_type = NNDCT_OP.BATCH_NORM1D
            torch_op_type = "BatchNorm1d"
        elif dim == 4:
            nndct_op_type = NNDCT_OP.BATCH_NORM
            torch_op_type = "BatchNorm2d"
        else:
            nndct_op_type = NNDCT_OP.BATCH_NORM3D
            torch_op_type = "BatchNorm3d"

        super().__init__(nndct_op_type)
        utils.op_register(nndct_op_type, torch_op_type)
示例#6
0
 def __init__(self, *args, **kwargs):
     super(TorchMul, self).__init__(NNDCT_OP.MULTIPLY, *args, **kwargs)
     utils.op_register(NNDCT_OP.MULTIPLY, 'mul')
示例#7
0
 def __init__(self):
     super().__init__(NNDCT_OP.CONST)
     utils.op_register(NNDCT_OP.CONST, 'tensor')
示例#8
0
 def __init__(self, *args, **kwargs):
     super(TorchHardTanh, self).__init__(NNDCT_OP.HARDTANH, *args, **kwargs)
     utils.op_register(NNDCT_OP.HARDTANH, 'Hardtanh')
示例#9
0
 def __init__(self, *args, **kwargs):
     super(TorchChunk, self).__init__(NNDCT_OP.CHUNK, *args, **kwargs)
     utils.op_register(NNDCT_OP.CHUNK, 'chunk')
示例#10
0
 def __init__(self, *args, **kwargs):
     super(TorchTanh, self).__init__(NNDCT_OP.TANH, *args, **kwargs)
     utils.op_register(NNDCT_OP.TANH, 'Tanh')
示例#11
0
 def __init__(self, input_ndim, nndct_op_type, torch_op_type, *args,
              **kwargs):
     super().__init__(nndct_op_type, *args, **kwargs)
     utils.op_register(nndct_op_type, torch_op_type)
     self._input_ndim = input_ndim
示例#12
0
 def __init__(self, *args, **kwargs):
     super(TorchAdd, self).__init__(NNDCT_OP.ADD, *args, **kwargs)
     utils.op_register(NNDCT_OP.ADD, 'add')
示例#13
0
 def __init__(self, nndct_op_type, *args, **kwargs):
     super().__init__(nndct_op_type, *args, **kwargs)
     utils.op_register(nndct_op_type, "ConvTranspose3d")
示例#14
0
 def __init__(self, nndct_op_type, *args, **kwargs):
     super(TorchConv2d, self).__init__(nndct_op_type, *args, **kwargs)
     utils.op_register(nndct_op_type, "Conv2d")
示例#15
0
 def __init__(self, *args, **kwargs):
     super(TorchFlatten, self).__init__(NNDCT_OP.FLATTEN, *args, **kwargs)
     utils.op_register(NNDCT_OP.FLATTEN, 'flatten')
示例#16
0
 def __init__(self):
     super(TorchView, self).__init__(NNDCT_OP.RESHAPE)
     utils.op_register(NNDCT_OP.RESHAPE, 'reshape')
示例#17
0
 def __init__(self, *args, **kwargs):
     super(TorchDropout, self).__init__(NNDCT_OP.DROPOUT, *args, **kwargs)
     utils.op_register(NNDCT_OP.DROPOUT, 'Dropout')
示例#18
0
 def __init__(self, *args, **kwargs):
     super(TorchMaxPool1d, self).__init__(NNDCT_OP.MAX_POOL1D, *args,
                                          **kwargs)
     utils.op_register(NNDCT_OP.MAX_POOL1D, "MaxPool1d")
示例#19
0
 def __init__(self, input_ndim, *args, **kwargs):
     super(TorchPermute, self).__init__(NNDCT_OP.PERMUTE, *args, **kwargs)
     utils.op_register(NNDCT_OP.PERMUTE, 'permute')
     self._input_ndim = input_ndim
示例#20
0
 def __init__(self, *args, **kwargs):
     super(TorchAvgPool, self).__init__(NNDCT_OP.AVG_POOL, *args, **kwargs)
     utils.op_register(NNDCT_OP.AVG_POOL, "AvgPool2d")
示例#21
0
 def __init__(self, *args, **kwargs):
     super(TorchContiguous, self).__init__(NNDCT_OP.CONTIGUOUS, *args,
                                           **kwargs)
     utils.op_register(NNDCT_OP.CONTIGUOUS, 'contiguous')
示例#22
0
 def __init__(self, *args, **kwargs):
     super(TorchReLU, self).__init__(NNDCT_OP.RELU, *args, **kwargs)
     utils.op_register(NNDCT_OP.RELU, 'ReLU')
示例#23
0
 def __init__(self, input_ndim):
     super().__init__()
     utils.op_register(NNDCT_OP.RESIZE, 'interpolate')
     # self._scale_factor_bc = [1.0, 1.0]
     if input_ndim != 4:
         raise RuntimeError("Only support 2D unsampling.")
示例#24
0
 def __init__(self, *args, **kwargs):
     super(TorchAdaptiveAvgPool, self).__init__(NNDCT_OP.ADAPTIVEAVGPOOL2D,
                                                *args, **kwargs)
     utils.op_register(NNDCT_OP.ADAPTIVEAVGPOOL2D, "AdaptiveAvgPool2d")
示例#25
0
 def __init__(self, input_ndim):
     super().__init__()
     utils.op_register(NNDCT_OP.RESIZE_3D, 'interpolate')
     # self._scale_factor_bc = [1.0, 1.0]
     assert input_ndim == 5
示例#26
0
 def __init__(self, input_ndim, *args, **kwargs):
     super(TorchSize, self).__init__(NNDCT_OP.SHAPE, *args, **kwargs)
     utils.op_register(NNDCT_OP.SHAPE, 'size')
     self._input_ndim = input_ndim
示例#27
0
 def __init__(self):
     super().__init__(NNDCT_OP.TENSOR)
     utils.op_register(NNDCT_OP.TENSOR, 'tensor')
示例#28
0
 def __init__(self):
     super().__init__()
     utils.op_register(NNDCT_OP.LEAKY_RELU, 'LeakyReLU')
     self._negative_slope = 0.01
示例#29
0
 def __init__(self, *args, **kwargs):
     super(TorchDiv, self).__init__(NNDCT_OP.DIV, *args, **kwargs)
     utils.op_register(NNDCT_OP.DIV, 'div')
示例#30
0
 def __init__(self, input_ndim, *args, **kwargs):
     super(TorchCat, self).__init__(NNDCT_OP.CONCAT, *args, **kwargs)
     utils.op_register(NNDCT_OP.CONCAT, 'cat')
     self._input_ndim = input_ndim