Example #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))
Example #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)
Example #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)
Example #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)
Example #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)
Example #6
0
 def __init__(self, *args, **kwargs):
     super(TorchMul, self).__init__(NNDCT_OP.MULTIPLY, *args, **kwargs)
     utils.op_register(NNDCT_OP.MULTIPLY, 'mul')
Example #7
0
 def __init__(self):
     super().__init__(NNDCT_OP.CONST)
     utils.op_register(NNDCT_OP.CONST, 'tensor')
Example #8
0
 def __init__(self, *args, **kwargs):
     super(TorchHardTanh, self).__init__(NNDCT_OP.HARDTANH, *args, **kwargs)
     utils.op_register(NNDCT_OP.HARDTANH, 'Hardtanh')
Example #9
0
 def __init__(self, *args, **kwargs):
     super(TorchChunk, self).__init__(NNDCT_OP.CHUNK, *args, **kwargs)
     utils.op_register(NNDCT_OP.CHUNK, 'chunk')
Example #10
0
 def __init__(self, *args, **kwargs):
     super(TorchTanh, self).__init__(NNDCT_OP.TANH, *args, **kwargs)
     utils.op_register(NNDCT_OP.TANH, 'Tanh')
Example #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
Example #12
0
 def __init__(self, *args, **kwargs):
     super(TorchAdd, self).__init__(NNDCT_OP.ADD, *args, **kwargs)
     utils.op_register(NNDCT_OP.ADD, 'add')
Example #13
0
 def __init__(self, nndct_op_type, *args, **kwargs):
     super().__init__(nndct_op_type, *args, **kwargs)
     utils.op_register(nndct_op_type, "ConvTranspose3d")
Example #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")
Example #15
0
 def __init__(self, *args, **kwargs):
     super(TorchFlatten, self).__init__(NNDCT_OP.FLATTEN, *args, **kwargs)
     utils.op_register(NNDCT_OP.FLATTEN, 'flatten')
Example #16
0
 def __init__(self):
     super(TorchView, self).__init__(NNDCT_OP.RESHAPE)
     utils.op_register(NNDCT_OP.RESHAPE, 'reshape')
Example #17
0
 def __init__(self, *args, **kwargs):
     super(TorchDropout, self).__init__(NNDCT_OP.DROPOUT, *args, **kwargs)
     utils.op_register(NNDCT_OP.DROPOUT, 'Dropout')
Example #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")
Example #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
Example #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")
Example #21
0
 def __init__(self, *args, **kwargs):
     super(TorchContiguous, self).__init__(NNDCT_OP.CONTIGUOUS, *args,
                                           **kwargs)
     utils.op_register(NNDCT_OP.CONTIGUOUS, 'contiguous')
Example #22
0
 def __init__(self, *args, **kwargs):
     super(TorchReLU, self).__init__(NNDCT_OP.RELU, *args, **kwargs)
     utils.op_register(NNDCT_OP.RELU, 'ReLU')
Example #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.")
Example #24
0
 def __init__(self, *args, **kwargs):
     super(TorchAdaptiveAvgPool, self).__init__(NNDCT_OP.ADAPTIVEAVGPOOL2D,
                                                *args, **kwargs)
     utils.op_register(NNDCT_OP.ADAPTIVEAVGPOOL2D, "AdaptiveAvgPool2d")
Example #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
Example #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
Example #27
0
 def __init__(self):
     super().__init__(NNDCT_OP.TENSOR)
     utils.op_register(NNDCT_OP.TENSOR, 'tensor')
Example #28
0
 def __init__(self):
     super().__init__()
     utils.op_register(NNDCT_OP.LEAKY_RELU, 'LeakyReLU')
     self._negative_slope = 0.01
Example #29
0
 def __init__(self, *args, **kwargs):
     super(TorchDiv, self).__init__(NNDCT_OP.DIV, *args, **kwargs)
     utils.op_register(NNDCT_OP.DIV, 'div')
Example #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