mirror of
https://github.com/huggingface/candle.git
synced 2025-06-15 10:26:33 +00:00
Add some group parameter to convolutions. (#566)
* Add some group parameter to convolutions. * Avoid some unnecessary groups checks. * Move the tensor convolution bits. * Properh handling of groups. * Bump the crate version. * And add a changelog.
This commit is contained in:
@ -66,6 +66,7 @@ impl ResnetBlock2D {
|
||||
let conv_cfg = nn::Conv2dConfig {
|
||||
stride: 1,
|
||||
padding: 1,
|
||||
groups: 1,
|
||||
};
|
||||
let norm1 = nn::group_norm(config.groups, in_channels, config.eps, vs.pp("norm1"))?;
|
||||
let conv1 = conv2d(in_channels, out_channels, 3, conv_cfg, vs.pp("conv1"))?;
|
||||
@ -79,6 +80,7 @@ impl ResnetBlock2D {
|
||||
let conv_cfg = nn::Conv2dConfig {
|
||||
stride: 1,
|
||||
padding: 0,
|
||||
groups: 1,
|
||||
};
|
||||
Some(conv2d(
|
||||
in_channels,
|
||||
|
@ -112,8 +112,8 @@ impl UNet2DConditionModel {
|
||||
let bl_attention_head_dim = config.blocks.last().unwrap().attention_head_dim;
|
||||
let time_embed_dim = b_channels * 4;
|
||||
let conv_cfg = nn::Conv2dConfig {
|
||||
stride: 1,
|
||||
padding: 1,
|
||||
..Default::default()
|
||||
};
|
||||
let conv_in = conv2d(in_channels, b_channels, 3, conv_cfg, vs.pp("conv_in"))?;
|
||||
|
||||
|
@ -24,7 +24,11 @@ impl Downsample2D {
|
||||
padding: usize,
|
||||
) -> Result<Self> {
|
||||
let conv = if use_conv {
|
||||
let config = nn::Conv2dConfig { stride: 2, padding };
|
||||
let config = nn::Conv2dConfig {
|
||||
stride: 2,
|
||||
padding,
|
||||
..Default::default()
|
||||
};
|
||||
let conv = conv2d(in_channels, out_channels, 3, config, vs.pp("conv"))?;
|
||||
Some(conv)
|
||||
} else {
|
||||
|
@ -51,8 +51,8 @@ impl Encoder {
|
||||
config: EncoderConfig,
|
||||
) -> Result<Self> {
|
||||
let conv_cfg = nn::Conv2dConfig {
|
||||
stride: 1,
|
||||
padding: 1,
|
||||
..Default::default()
|
||||
};
|
||||
let conv_in = nn::conv2d(
|
||||
in_channels,
|
||||
@ -182,8 +182,8 @@ impl Decoder {
|
||||
let n_block_out_channels = config.block_out_channels.len();
|
||||
let last_block_out_channels = *config.block_out_channels.last().unwrap();
|
||||
let conv_cfg = nn::Conv2dConfig {
|
||||
stride: 1,
|
||||
padding: 1,
|
||||
..Default::default()
|
||||
};
|
||||
let conv_in = nn::conv2d(
|
||||
in_channels,
|
||||
|
Reference in New Issue
Block a user