def __init__( self, in_channels: int, out_channels: int, kernel_size: _size_3_t, stride: _size_3_t = 1, padding: _size_3_t = 0, output_padding: _size_3_t = 0, groups: int = 1, bias: bool = True, dilation: _size_3_t = 1, padding_mode: str = "zeros", ) -> None: super().__init__() assert padding_mode == "zeros", "Only `zeros` padding mode is supported" self.kernel_size = _triple(kernel_size) self.stride = _triple(stride) self.padding = _triple(padding) self.dilation = _triple(dilation) self.output_padding = _triple(output_padding) self.groups = groups assert in_channels % groups == 0 assert out_channels % groups == 0 self.weight = flow.nn.Parameter( flow.Tensor(in_channels, out_channels // groups, *self.kernel_size) ) self.filters = out_channels self.bias = None self._bias_add_op = None if bias: self.bias = flow.nn.Parameter(flow.Tensor(out_channels)) self.reset_parameters()
def __init__( self, in_channels: int, out_channels: int, kernel_size: _size_3_t, stride: _size_3_t = 1, padding: _size_3_t = 0, dilation: _size_3_t = 1, groups: int = 1, bias: bool = True, padding_mode: str = "zeros", # TODO: refine this type ): super().__init__() assert padding_mode == "zeros" self.padding_mode = padding_mode self.kernel_size = _triple(kernel_size) self.stride = _triple(stride) self.padding = _triple(padding) self.dilation = _triple(dilation) self.groups = groups self.channel_pos = "channels_first" assert in_channels % groups == 0, "in_channels must be divisible by groups" assert out_channels % groups == 0, "out_channels must be divisible by groups" self.in_channels = in_channels self.out_channels = out_channels self.weight = flow.nn.Parameter( flow.Tensor(out_channels, in_channels // groups, *self.kernel_size) ) self.out_channel_groups = out_channels // groups self.bias = None if bias: self.bias = flow.nn.Parameter(flow.Tensor(out_channels)) self.reset_parameters()
def __init__( self, kernel_size: _size_3_t, stride: Optional[_size_3_t] = None, padding: _size_3_t = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int = 0, ): super().__init__() self.kernel_size = _triple(kernel_size) data_format = "NCHW" # only support "NCHW" for now ! self.channel_pos = ("channels_first" if data_format == "NCHW" else "channels_last") self.stride = _triple(stride) if ( stride is not None) else _triple(kernel_size) self.ceil_mode = ceil_mode self.count_include_pad = count_include_pad self.divisor_override = int(divisor_override) self.padding = _triple(padding)
def __init__( self, kernel_size: _size_3_t, stride: Optional[_size_3_t] = None, padding: _size_3_t = 0, dilation: _size_3_t = 1, return_indices: bool = False, ceil_mode: bool = False, ): super().__init__() self.kernel_size = _triple(kernel_size) self.stride = _triple(stride) if ( stride is not None) else _triple(kernel_size) data_format = "NCDHW" self.channel_pos = ("channels_last" if data_format == "NDHWC" else "channels_first") self.dilation = _triple(dilation) self.padding = _triple(padding) self.return_indices = return_indices self.ceil_mode = ceil_mode
def __init__(self, output_size) -> None: super().__init__() assert output_size is not None, "'output_size' cannot be NoneType" self.output_size = _triple(output_size)