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))
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)
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)
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)
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)
def __init__(self, *args, **kwargs): super(TorchMul, self).__init__(NNDCT_OP.MULTIPLY, *args, **kwargs) utils.op_register(NNDCT_OP.MULTIPLY, 'mul')
def __init__(self): super().__init__(NNDCT_OP.CONST) utils.op_register(NNDCT_OP.CONST, 'tensor')
def __init__(self, *args, **kwargs): super(TorchHardTanh, self).__init__(NNDCT_OP.HARDTANH, *args, **kwargs) utils.op_register(NNDCT_OP.HARDTANH, 'Hardtanh')
def __init__(self, *args, **kwargs): super(TorchChunk, self).__init__(NNDCT_OP.CHUNK, *args, **kwargs) utils.op_register(NNDCT_OP.CHUNK, 'chunk')
def __init__(self, *args, **kwargs): super(TorchTanh, self).__init__(NNDCT_OP.TANH, *args, **kwargs) utils.op_register(NNDCT_OP.TANH, 'Tanh')
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
def __init__(self, *args, **kwargs): super(TorchAdd, self).__init__(NNDCT_OP.ADD, *args, **kwargs) utils.op_register(NNDCT_OP.ADD, 'add')
def __init__(self, nndct_op_type, *args, **kwargs): super().__init__(nndct_op_type, *args, **kwargs) utils.op_register(nndct_op_type, "ConvTranspose3d")
def __init__(self, nndct_op_type, *args, **kwargs): super(TorchConv2d, self).__init__(nndct_op_type, *args, **kwargs) utils.op_register(nndct_op_type, "Conv2d")
def __init__(self, *args, **kwargs): super(TorchFlatten, self).__init__(NNDCT_OP.FLATTEN, *args, **kwargs) utils.op_register(NNDCT_OP.FLATTEN, 'flatten')
def __init__(self): super(TorchView, self).__init__(NNDCT_OP.RESHAPE) utils.op_register(NNDCT_OP.RESHAPE, 'reshape')
def __init__(self, *args, **kwargs): super(TorchDropout, self).__init__(NNDCT_OP.DROPOUT, *args, **kwargs) utils.op_register(NNDCT_OP.DROPOUT, 'Dropout')
def __init__(self, *args, **kwargs): super(TorchMaxPool1d, self).__init__(NNDCT_OP.MAX_POOL1D, *args, **kwargs) utils.op_register(NNDCT_OP.MAX_POOL1D, "MaxPool1d")
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
def __init__(self, *args, **kwargs): super(TorchAvgPool, self).__init__(NNDCT_OP.AVG_POOL, *args, **kwargs) utils.op_register(NNDCT_OP.AVG_POOL, "AvgPool2d")
def __init__(self, *args, **kwargs): super(TorchContiguous, self).__init__(NNDCT_OP.CONTIGUOUS, *args, **kwargs) utils.op_register(NNDCT_OP.CONTIGUOUS, 'contiguous')
def __init__(self, *args, **kwargs): super(TorchReLU, self).__init__(NNDCT_OP.RELU, *args, **kwargs) utils.op_register(NNDCT_OP.RELU, 'ReLU')
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.")
def __init__(self, *args, **kwargs): super(TorchAdaptiveAvgPool, self).__init__(NNDCT_OP.ADAPTIVEAVGPOOL2D, *args, **kwargs) utils.op_register(NNDCT_OP.ADAPTIVEAVGPOOL2D, "AdaptiveAvgPool2d")
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
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
def __init__(self): super().__init__(NNDCT_OP.TENSOR) utils.op_register(NNDCT_OP.TENSOR, 'tensor')
def __init__(self): super().__init__() utils.op_register(NNDCT_OP.LEAKY_RELU, 'LeakyReLU') self._negative_slope = 0.01
def __init__(self, *args, **kwargs): super(TorchDiv, self).__init__(NNDCT_OP.DIV, *args, **kwargs) utils.op_register(NNDCT_OP.DIV, 'div')
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