mirror of
https://github.com/huggingface/candle.git
synced 2025-06-19 03:54:56 +00:00
Support dilation in conv-transpose2d. (#671)
This commit is contained in:
@ -1186,12 +1186,6 @@ impl<'a> Map2 for ConvTranspose2D<'a> {
|
||||
const OP: &'static str = "conv_transpose2d";
|
||||
fn f<T: WithDType>(&self, inp: &[T], inp_l: &Layout, k: &[T], k_l: &Layout) -> Result<Vec<T>> {
|
||||
let p = self.0;
|
||||
if p.dilation != 1 {
|
||||
crate::bail!(
|
||||
"dilation {} is not supported for conv-transpose2d",
|
||||
p.dilation
|
||||
)
|
||||
}
|
||||
let inp = &inp[inp_l.start_offset()..];
|
||||
let (inp_s0, inp_s1, inp_s2, inp_s3) = crate::shape::dims4(inp_l.stride())?;
|
||||
let k = &k[k_l.start_offset()..];
|
||||
@ -1235,8 +1229,8 @@ impl<'a> Map2 for ConvTranspose2D<'a> {
|
||||
for b_idx in 0..p.b_size {
|
||||
for inp_y in 0..p.i_h {
|
||||
for inp_x in 0..p.i_w {
|
||||
let out_x = inp_x * p.stride + k_x;
|
||||
let out_y = inp_y * p.stride + k_y;
|
||||
let out_x = inp_x * p.stride + k_x * p.dilation;
|
||||
let out_y = inp_y * p.stride + k_y * p.dilation;
|
||||
if out_x < p.padding || out_y < p.padding {
|
||||
continue;
|
||||
}
|
||||
|
@ -1046,12 +1046,6 @@ impl<'a> Map2 for ConvTranspose2D<'a> {
|
||||
// Kernel shape: (c_in_k, c_out, h_k, w_k)
|
||||
// Input shape: (b_size, c_in, h_in, w_in)
|
||||
let p = &self.0;
|
||||
if p.dilation != 1 {
|
||||
crate::bail!(
|
||||
"dilation {} is not supported for conv-transpose2d",
|
||||
p.dilation
|
||||
)
|
||||
}
|
||||
let (out_w, out_h) = (p.out_w(), p.out_h());
|
||||
let dst_el = p.c_out * out_w * out_h * p.b_size;
|
||||
let inp = &inp.slice(inp_l.start_offset()..);
|
||||
|
Reference in New Issue
Block a user