import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
import torch.utils.data
import torch.nn as nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_convolution_leaky_relu_0(in_ptr0, in_ptr1, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tl.store(out_ptr0 + x3, tmp4, xmask)


@triton.jit
def triton_poi_fused_add_convolution_leaky_relu_1(in_ptr0, in_ptr1, in_ptr2,
    out_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr2 + x3, xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = 0.0
    tmp6 = tmp4 > tmp5
    tmp7 = 0.2
    tmp8 = tmp4 * tmp7
    tmp9 = tl.where(tmp6, tmp4, tmp8)
    tl.store(out_ptr0 + x3, tmp6, xmask)
    tl.store(out_ptr1 + x3, tmp9, xmask)


@triton.jit
def triton_poi_fused_cat_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    in_ptr5, in_ptr6, in_ptr7, in_ptr8, in_ptr9, in_ptr10, in_ptr11,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 16 % 16
    x0 = xindex % 16
    x2 = xindex // 256
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 16 * x1 + 64 * x2), tmp4 & xmask, other=0.0
        ).to(tl.int1)
    tmp6 = tl.load(in_ptr1 + (x0 + 16 * x1 + 64 * x2), tmp4 & xmask, other=0.0)
    tmp7 = tl.load(in_ptr2 + x1, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp8 = tmp6 + tmp7
    tmp9 = 0.2
    tmp10 = tmp8 * tmp9
    tmp11 = tl.where(tmp5, tmp8, tmp10)
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp4, tmp11, tmp12)
    tmp14 = tmp0 >= tmp3
    tmp15 = tl.full([1], 8, tl.int64)
    tmp16 = tmp0 < tmp15
    tmp17 = tmp14 & tmp16
    tmp18 = tl.load(in_ptr3 + (x0 + 16 * (-4 + x1) + 64 * x2), tmp17 &
        xmask, other=0.0).to(tl.int1)
    tmp19 = tl.load(in_ptr4 + (x0 + 16 * (-4 + x1) + 64 * x2), tmp17 &
        xmask, other=0.0)
    tmp20 = tl.load(in_ptr5 + (-4 + x1), tmp17 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp21 = tmp19 + tmp20
    tmp22 = tmp21 * tmp9
    tmp23 = tl.where(tmp18, tmp21, tmp22)
    tmp24 = tl.full(tmp23.shape, 0.0, tmp23.dtype)
    tmp25 = tl.where(tmp17, tmp23, tmp24)
    tmp26 = tmp0 >= tmp15
    tmp27 = tl.full([1], 12, tl.int64)
    tmp28 = tmp0 < tmp27
    tmp29 = tmp26 & tmp28
    tmp30 = tl.load(in_ptr6 + (x0 + 16 * (-8 + x1) + 64 * x2), tmp29 &
        xmask, other=0.0).to(tl.int1)
    tmp31 = tl.load(in_ptr7 + (x0 + 16 * (-8 + x1) + 64 * x2), tmp29 &
        xmask, other=0.0)
    tmp32 = tl.load(in_ptr8 + (-8 + x1), tmp29 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp33 = tmp31 + tmp32
    tmp34 = tmp33 * tmp9
    tmp35 = tl.where(tmp30, tmp33, tmp34)
    tmp36 = tl.full(tmp35.shape, 0.0, tmp35.dtype)
    tmp37 = tl.where(tmp29, tmp35, tmp36)
    tmp38 = tmp0 >= tmp27
    tl.full([1], 16, tl.int64)
    tmp41 = tl.load(in_ptr9 + (x0 + 16 * (-12 + x1) + 64 * x2), tmp38 &
        xmask, other=0.0).to(tl.int1)
    tmp42 = tl.load(in_ptr10 + (x0 + 16 * (-12 + x1) + 64 * x2), tmp38 &
        xmask, other=0.0)
    tmp43 = tl.load(in_ptr11 + (-12 + x1), tmp38 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp44 = tmp42 + tmp43
    tmp45 = tmp44 * tmp9
    tmp46 = tl.where(tmp41, tmp44, tmp45)
    tmp47 = tl.full(tmp46.shape, 0.0, tmp46.dtype)
    tmp48 = tl.where(tmp38, tmp46, tmp47)
    tmp49 = tl.where(tmp29, tmp37, tmp48)
    tmp50 = tl.where(tmp17, tmp25, tmp49)
    tmp51 = tl.where(tmp4, tmp13, tmp50)
    tl.store(out_ptr0 + x3, tmp51, xmask)


@triton.jit
def triton_poi_fused_convolution_3(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


@triton.jit
def triton_poi_fused_convolution_mul_sigmoid_4(in_out_ptr0, in_ptr0,
    in_ptr1, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 16 % 4
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr1 + x3, xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tl.sigmoid(tmp2)
    tmp5 = tmp3 * tmp4
    tl.store(in_out_ptr0 + x3, tmp2, xmask)
    tl.store(out_ptr0 + x3, tmp5, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_2, (4,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (4, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_5, (4,), (1,))
    assert_size_stride(primals_6, (4, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_7, (4,), (1,))
    assert_size_stride(primals_8, (4, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_9, (4,), (1,))
    assert_size_stride(primals_10, (4, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_11, (4,), (1,))
    assert_size_stride(primals_12, (4, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_13, (4,), (1,))
    assert_size_stride(primals_14, (4, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_15, (4,), (1,))
    assert_size_stride(primals_16, (4, 16, 1, 1), (16, 1, 1, 1))
    assert_size_stride(primals_17, (4,), (1,))
    assert_size_stride(primals_18, (4, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_19, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 4, 4, 4), (64, 16, 4, 1))
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        get_raw_stream(0)
        triton_poi_fused_convolution_leaky_relu_0[grid(256)](buf0,
            primals_2, buf1, 256, XBLOCK=256, num_warps=4, num_stages=1)
        buf2 = extern_kernels.convolution(primals_3, primals_4, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 4, 4, 4), (64, 16, 4, 1))
        buf3 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        buf4 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_add_convolution_leaky_relu_1[grid(256)](buf2,
            primals_5, primals_3, buf3, buf4, 256, XBLOCK=128, num_warps=4,
            num_stages=1)
        del primals_5
        buf5 = extern_kernels.convolution(buf4, primals_6, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (4, 4, 4, 4), (64, 16, 4, 1))
        buf6 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        triton_poi_fused_convolution_leaky_relu_0[grid(256)](buf5,
            primals_7, buf6, 256, XBLOCK=256, num_warps=4, num_stages=1)
        buf7 = extern_kernels.convolution(buf4, primals_8, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 4, 4, 4), (64, 16, 4, 1))
        buf8 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        buf9 = buf2
        del buf2
        triton_poi_fused_add_convolution_leaky_relu_1[grid(256)](buf7,
            primals_9, buf4, buf8, buf9, 256, XBLOCK=128, num_warps=4,
            num_stages=1)
        del primals_9
        buf10 = extern_kernels.convolution(buf9, primals_10, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 4, 4, 4), (64, 16, 4, 1))
        buf11 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        triton_poi_fused_convolution_leaky_relu_0[grid(256)](buf10,
            primals_11, buf11, 256, XBLOCK=256, num_warps=4, num_stages=1)
        buf12 = extern_kernels.convolution(buf9, primals_12, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf12, (4, 4, 4, 4), (64, 16, 4, 1))
        buf13 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        buf14 = buf7
        del buf7
        triton_poi_fused_add_convolution_leaky_relu_1[grid(256)](buf12,
            primals_13, buf9, buf13, buf14, 256, XBLOCK=128, num_warps=4,
            num_stages=1)
        del buf12
        del primals_13
        buf15 = extern_kernels.convolution(buf14, primals_14, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf15, (4, 4, 4, 4), (64, 16, 4, 1))
        buf16 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        triton_poi_fused_convolution_leaky_relu_0[grid(256)](buf15,
            primals_15, buf16, 256, XBLOCK=256, num_warps=4, num_stages=1)
        buf17 = empty_strided_cuda((4, 16, 4, 4), (256, 16, 4, 1), torch.
            float32)
        triton_poi_fused_cat_2[grid(1024)](buf1, buf0, primals_2, buf6,
            buf5, primals_7, buf11, buf10, primals_11, buf16, buf15,
            primals_15, buf17, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        del buf0
        del buf10
        del buf15
        del primals_11
        del primals_15
        del primals_2
        del primals_7
        buf18 = extern_kernels.convolution(buf17, primals_16, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf18, (4, 4, 4, 4), (64, 16, 4, 1))
        buf19 = buf18
        del buf18
        triton_poi_fused_convolution_3[grid(256)](buf19, primals_17, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_17
        buf20 = extern_kernels.convolution(buf19, primals_18, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf20, (4, 4, 4, 4), (64, 16, 4, 1))
        buf21 = buf20
        del buf20
        buf22 = buf5
        del buf5
        triton_poi_fused_convolution_mul_sigmoid_4[grid(256)](buf21,
            primals_19, buf19, buf22, 256, XBLOCK=128, num_warps=4,
            num_stages=1)
        del primals_19
    return (buf22, primals_1, primals_3, primals_4, primals_6, primals_8,
        primals_10, primals_12, primals_14, primals_16, primals_18, buf1,
        buf3, buf4, buf6, buf8, buf9, buf11, buf13, buf14, buf16, buf17,
        buf19, buf21)


class PA(nn.Module):

    def __init__(self, nf):
        super(PA, self).__init__()
        self.conv = nn.Conv2d(nf, nf, 1)
        self.sigmoid = nn.Sigmoid()

    def forward(self, x):
        y = self.conv(x)
        y = self.sigmoid(y)
        out = torch.mul(x, y)
        return out


class PADBNew(nn.Module):

    def __init__(self, in_channels, out_channels, c_weight=1):
        super(PADBNew, self).__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.dc = int(in_channels * c_weight)
        self.c_weight = c_weight
        expand_dim = in_channels
        if c_weight > 1:
            expand_dim = self.dc
            self.expandconv = nn.Conv2d(in_channels, expand_dim, 3, padding=1)
        self.c1_d = nn.Conv2d(expand_dim, self.dc, 1)
        self.c1_r = nn.Conv2d(expand_dim, expand_dim, 3, padding=1)
        self.c2_d = nn.Conv2d(expand_dim, self.dc, 1)
        self.c2_r = nn.Conv2d(expand_dim, expand_dim, 3, padding=1)
        self.c3_d = nn.Conv2d(expand_dim, self.dc, 1)
        self.c3_r = nn.Conv2d(expand_dim, expand_dim, 3, padding=1)
        self.c4 = nn.Conv2d(expand_dim, self.dc, 3, padding=1)
        self.act = nn.LeakyReLU(0.2)
        self.c5 = nn.Conv2d(self.dc * 4, out_channels, 1)
        self.PA = PA(out_channels)

    def forward(self, input_0):
        primals_1 = self.c1_d.weight
        primals_2 = self.c1_d.bias
        primals_4 = self.c1_r.weight
        primals_5 = self.c1_r.bias
        primals_6 = self.c2_d.weight
        primals_7 = self.c2_d.bias
        primals_8 = self.c2_r.weight
        primals_9 = self.c2_r.bias
        primals_10 = self.c3_d.weight
        primals_11 = self.c3_d.bias
        primals_12 = self.c3_r.weight
        primals_13 = self.c3_r.bias
        primals_14 = self.c4.weight
        primals_15 = self.c4.bias
        primals_16 = self.c5.weight
        primals_17 = self.c5.bias
        primals_18 = self.PA.conv.weight
        primals_19 = self.PA.conv.bias
        primals_3 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19])
        return output[0]


Measured latency_ms: 0.028036