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
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice
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_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 3
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


@triton.jit
def triton_poi_fused_convolution_relu_1(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 32
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x3, tmp4, None)


@triton.jit
def triton_poi_fused_convolution_2(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 32
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


@triton.jit
def triton_poi_fused_cat_3(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x1 = xindex // 4096 % 64
    x0 = xindex % 4096
    x2 = xindex // 262144
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 32, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4096 * x1 + 131072 * x2), tmp4, other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 64, tl.int64)
    tmp9 = tl.load(in_ptr1 + (x0 + 4096 * (-32 + x1) + 131072 * x2), tmp6,
        other=0.0)
    tmp10 = tl.load(in_ptr2 + (-32 + x1), tmp6, eviction_policy=
        'evict_last', other=0.0)
    tmp11 = tmp9 + tmp10
    tmp12 = tl.full([1], 0, tl.int32)
    tmp13 = triton_helpers.maximum(tmp12, tmp11)
    tmp14 = tl.full(tmp13.shape, 0.0, tmp13.dtype)
    tmp15 = tl.where(tmp6, tmp13, tmp14)
    tmp16 = tl.where(tmp4, tmp5, tmp15)
    tl.store(out_ptr0 + x3, tmp16, None)


@triton.jit
def triton_poi_fused_convolution_4(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 64
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, None)


@triton.jit
def triton_poi_fused_add_convolution_mul_pow_sub_tanh_5(in_out_ptr0,
    in_out_ptr1, in_ptr0, in_ptr1, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 3
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + x3, None)
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tmp5 = tmp4 * tmp4
    tmp6 = tmp5 - tmp4
    tmp7 = tmp3 * tmp6
    tmp8 = tmp4 + tmp7
    tmp9 = tmp8 * tmp8
    tmp10 = tmp9 - tmp8
    tmp11 = tmp3 * tmp10
    tmp12 = tmp8 + tmp11
    tmp13 = tmp12 * tmp12
    tmp14 = tmp13 - tmp12
    tmp15 = tmp3 * tmp14
    tmp16 = tmp12 + tmp15
    tmp17 = tmp16 * tmp16
    tmp18 = tmp17 - tmp16
    tmp19 = tmp3 * tmp18
    tmp20 = tmp16 + tmp19
    tmp21 = tmp20 * tmp20
    tmp22 = tmp21 - tmp20
    tmp23 = tmp3 * tmp22
    tmp24 = tmp20 + tmp23
    tmp25 = tmp24 * tmp24
    tmp26 = tmp25 - tmp24
    tmp27 = tmp3 * tmp26
    tmp28 = tmp24 + tmp27
    tmp29 = tmp28 * tmp28
    tmp30 = tmp29 - tmp28
    tmp31 = tmp3 * tmp30
    tmp32 = tmp28 + tmp31
    tmp33 = tmp32 * tmp32
    tmp34 = tmp33 - tmp32
    tmp35 = tmp3 * tmp34
    tmp36 = tmp32 + tmp35
    tl.store(in_out_ptr0 + x3, tmp3, None)
    tl.store(in_out_ptr1 + x3, tmp36, None)


@triton.jit
def triton_poi_fused_convolution_relu_threshold_backward_6(in_ptr0, in_ptr1,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x3 = xindex
    x1 = xindex // 4096 % 32
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr1 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(out_ptr0 + x3, tmp6, None)


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, primals_20, primals_21, primals_22,
        primals_23, primals_24, primals_25, primals_26, primals_27,
        primals_28, primals_29) = args
    args.clear()
    assert_size_stride(primals_1, (4, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_2, (3, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_3, (3,), (1,))
    assert_size_stride(primals_4, (32, 3, 1, 1), (3, 1, 1, 1))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (32, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_7, (32,), (1,))
    assert_size_stride(primals_8, (32, 32, 1, 1), (32, 1, 1, 1))
    assert_size_stride(primals_9, (32,), (1,))
    assert_size_stride(primals_10, (32, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_11, (32,), (1,))
    assert_size_stride(primals_12, (32, 32, 1, 1), (32, 1, 1, 1))
    assert_size_stride(primals_13, (32,), (1,))
    assert_size_stride(primals_14, (32, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_15, (32,), (1,))
    assert_size_stride(primals_16, (32, 32, 1, 1), (32, 1, 1, 1))
    assert_size_stride(primals_17, (32,), (1,))
    assert_size_stride(primals_18, (64, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_19, (64,), (1,))
    assert_size_stride(primals_20, (32, 64, 1, 1), (64, 1, 1, 1))
    assert_size_stride(primals_21, (32,), (1,))
    assert_size_stride(primals_22, (64, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_23, (64,), (1,))
    assert_size_stride(primals_24, (32, 64, 1, 1), (64, 1, 1, 1))
    assert_size_stride(primals_25, (32,), (1,))
    assert_size_stride(primals_26, (64, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_27, (64,), (1,))
    assert_size_stride(primals_28, (3, 64, 1, 1), (64, 1, 1, 1))
    assert_size_stride(primals_29, (3,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_1, primals_2, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=3, bias=None)
        assert_size_stride(buf0, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_0[grid(49152)](buf1, primals_3, 49152,
            XBLOCK=512, num_warps=4, num_stages=1)
        del primals_3
        buf2 = extern_kernels.convolution(buf1, primals_4, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf3 = buf2
        del buf2
        triton_poi_fused_convolution_relu_1[grid(524288)](buf3, primals_5, 
            524288, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_5
        buf4 = extern_kernels.convolution(buf3, primals_6, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=32, bias=None)
        assert_size_stride(buf4, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf5 = buf4
        del buf4
        triton_poi_fused_convolution_2[grid(524288)](buf5, primals_7, 
            524288, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_7
        buf6 = extern_kernels.convolution(buf5, primals_8, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf7 = buf6
        del buf6
        triton_poi_fused_convolution_relu_1[grid(524288)](buf7, primals_9, 
            524288, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_9
        buf8 = extern_kernels.convolution(buf7, primals_10, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=32, bias=None)
        assert_size_stride(buf8, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf9 = buf8
        del buf8
        triton_poi_fused_convolution_2[grid(524288)](buf9, primals_11, 
            524288, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_11
        buf10 = extern_kernels.convolution(buf9, primals_12, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf11 = buf10
        del buf10
        triton_poi_fused_convolution_relu_1[grid(524288)](buf11, primals_13,
            524288, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_13
        buf12 = extern_kernels.convolution(buf11, primals_14, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=32, bias=None)
        assert_size_stride(buf12, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf13 = buf12
        del buf12
        triton_poi_fused_convolution_2[grid(524288)](buf13, primals_15, 
            524288, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_15
        buf14 = extern_kernels.convolution(buf13, primals_16, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf14, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf15 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_3[grid(1048576)](buf11, buf14, primals_17,
            buf15, 1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        buf16 = extern_kernels.convolution(buf15, primals_18, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=64, bias=None)
        assert_size_stride(buf16, (4, 64, 64, 64), (262144, 4096, 64, 1))
        buf17 = buf16
        del buf16
        triton_poi_fused_convolution_4[grid(1048576)](buf17, primals_19, 
            1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_19
        buf18 = extern_kernels.convolution(buf17, primals_20, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf18, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf19 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_3[grid(1048576)](buf7, buf18, primals_21,
            buf19, 1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        buf20 = extern_kernels.convolution(buf19, primals_22, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=64, bias=None)
        assert_size_stride(buf20, (4, 64, 64, 64), (262144, 4096, 64, 1))
        buf21 = buf20
        del buf20
        triton_poi_fused_convolution_4[grid(1048576)](buf21, primals_23, 
            1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_23
        buf22 = extern_kernels.convolution(buf21, primals_24, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf22, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf23 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_3[grid(1048576)](buf3, buf22, primals_25,
            buf23, 1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        buf24 = extern_kernels.convolution(buf23, primals_26, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=64, bias=None)
        assert_size_stride(buf24, (4, 64, 64, 64), (262144, 4096, 64, 1))
        buf25 = buf24
        del buf24
        triton_poi_fused_convolution_4[grid(1048576)](buf25, primals_27, 
            1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_27
        buf26 = extern_kernels.convolution(buf25, primals_28, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf26, (4, 3, 64, 64), (12288, 4096, 64, 1))
        buf27 = buf26
        del buf26
        buf28 = empty_strided_cuda((4, 3, 64, 64), (12288, 4096, 64, 1),
            torch.float32)
        buf29 = buf28
        del buf28
        buf30 = buf29
        del buf29
        triton_poi_fused_add_convolution_mul_pow_sub_tanh_5[grid(49152)](buf27,
            buf30, primals_29, primals_1, 49152, XBLOCK=256, num_warps=4,
            num_stages=1)
        del primals_29
        buf31 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_6[grid(524288)](
            buf22, primals_25, buf31, 524288, XBLOCK=1024, num_warps=4,
            num_stages=1)
        del buf22
        del primals_25
        buf32 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_6[grid(524288)](
            buf18, primals_21, buf32, 524288, XBLOCK=1024, num_warps=4,
            num_stages=1)
        del buf18
        del primals_21
        buf33 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_6[grid(524288)](
            buf14, primals_17, buf33, 524288, XBLOCK=1024, num_warps=4,
            num_stages=1)
        del buf14
        del primals_17
    return (buf30, buf27, primals_1, primals_2, primals_4, primals_6,
        primals_8, primals_10, primals_12, primals_14, primals_16,
        primals_18, primals_20, primals_22, primals_24, primals_26,
        primals_28, buf1, buf3, buf5, buf7, buf9, buf11, buf13, buf15,
        buf17, buf19, buf21, buf23, buf25, buf27, buf31, buf32, buf33)


class CSDN_Tem(nn.Module):

    def __init__(self, in_ch, out_ch):
        super(CSDN_Tem, self).__init__()
        self.depth_conv = nn.Conv2d(in_channels=in_ch, out_channels=in_ch,
            kernel_size=3, padding=1, groups=in_ch)
        self.point_conv = nn.Conv2d(in_channels=in_ch, out_channels=out_ch,
            kernel_size=1)

    def forward(self, input):
        out = self.depth_conv(input)
        out = self.point_conv(out)
        return out


class enhance_net_nopoolNew(nn.Module):

    def __init__(self, scale_factor):
        super(enhance_net_nopoolNew, self).__init__()
        self.relu = nn.ReLU(inplace=True)
        self.scale_factor = scale_factor
        self.upsample = nn.UpsamplingBilinear2d(scale_factor=self.scale_factor)
        number_f = 32
        self.e_conv1 = CSDN_Tem(3, number_f)
        self.e_conv2 = CSDN_Tem(number_f, number_f)
        self.e_conv3 = CSDN_Tem(number_f, number_f)
        self.e_conv4 = CSDN_Tem(number_f, number_f)
        self.e_conv5 = CSDN_Tem(number_f * 2, number_f)
        self.e_conv6 = CSDN_Tem(number_f * 2, number_f)
        self.e_conv7 = CSDN_Tem(number_f * 2, 3)

    def enhance(self, x, x_r):
        for _ in range(8):
            x = x + x_r * (torch.pow(x, 2) - x)
        return x

    def forward(self, input_0):
        primals_2 = self.e_conv1.depth_conv.weight
        primals_3 = self.e_conv1.depth_conv.bias
        primals_4 = self.e_conv1.point_conv.weight
        primals_5 = self.e_conv1.point_conv.bias
        primals_6 = self.e_conv2.depth_conv.weight
        primals_7 = self.e_conv2.depth_conv.bias
        primals_8 = self.e_conv2.point_conv.weight
        primals_9 = self.e_conv2.point_conv.bias
        primals_10 = self.e_conv3.depth_conv.weight
        primals_11 = self.e_conv3.depth_conv.bias
        primals_12 = self.e_conv3.point_conv.weight
        primals_13 = self.e_conv3.point_conv.bias
        primals_14 = self.e_conv4.depth_conv.weight
        primals_15 = self.e_conv4.depth_conv.bias
        primals_16 = self.e_conv4.point_conv.weight
        primals_17 = self.e_conv4.point_conv.bias
        primals_18 = self.e_conv5.depth_conv.weight
        primals_19 = self.e_conv5.depth_conv.bias
        primals_20 = self.e_conv5.point_conv.weight
        primals_21 = self.e_conv5.point_conv.bias
        primals_22 = self.e_conv6.depth_conv.weight
        primals_23 = self.e_conv6.depth_conv.bias
        primals_24 = self.e_conv6.point_conv.weight
        primals_25 = self.e_conv6.point_conv.bias
        primals_26 = self.e_conv7.depth_conv.weight
        primals_27 = self.e_conv7.depth_conv.bias
        primals_28 = self.e_conv7.point_conv.weight
        primals_29 = self.e_conv7.point_conv.bias
        primals_1 = 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,
            primals_20, primals_21, primals_22, primals_23, primals_24,
            primals_25, primals_26, primals_27, primals_28, primals_29])
        return output[0], output[1]


Measured latency_ms: 0.339987