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
import torch.optim
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_convolution_relu_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 % 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_cat_1(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_tanh_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 % 24
    tmp0 = tl.load(in_out_ptr0 + x3, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = libdevice.tanh(tmp2)
    tl.store(in_out_ptr0 + x3, tmp3, None)


@triton.jit
def triton_poi_fused_add_mul_pow_sub_3(in_ptr0, in_ptr1, out_ptr0, out_ptr1,
    out_ptr2, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 12288
    x1 = xindex // 12288
    tmp0 = tl.load(in_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr1 + (x0 + 98304 * x1), None)
    tmp6 = tl.load(in_ptr1 + (12288 + x0 + 98304 * x1), None)
    tmp11 = tl.load(in_ptr1 + (24576 + x0 + 98304 * x1), None)
    tmp16 = tl.load(in_ptr1 + (36864 + x0 + 98304 * x1), None)
    tmp21 = tl.load(in_ptr1 + (49152 + x0 + 98304 * x1), None)
    tmp26 = tl.load(in_ptr1 + (61440 + x0 + 98304 * x1), None)
    tmp31 = tl.load(in_ptr1 + (73728 + x0 + 98304 * x1), None)
    tmp36 = tl.load(in_ptr1 + (86016 + x0 + 98304 * x1), None)
    tmp2 = tmp0 * tmp0
    tmp3 = tmp2 - tmp0
    tmp4 = tmp1 * tmp3
    tmp5 = tmp0 + tmp4
    tmp7 = tmp5 * tmp5
    tmp8 = tmp7 - tmp5
    tmp9 = tmp6 * tmp8
    tmp10 = tmp5 + tmp9
    tmp12 = tmp10 * tmp10
    tmp13 = tmp12 - tmp10
    tmp14 = tmp11 * tmp13
    tmp15 = tmp10 + tmp14
    tmp17 = tmp15 * tmp15
    tmp18 = tmp17 - tmp15
    tmp19 = tmp16 * tmp18
    tmp20 = tmp15 + tmp19
    tmp22 = tmp20 * tmp20
    tmp23 = tmp22 - tmp20
    tmp24 = tmp21 * tmp23
    tmp25 = tmp20 + tmp24
    tmp27 = tmp25 * tmp25
    tmp28 = tmp27 - tmp25
    tmp29 = tmp26 * tmp28
    tmp30 = tmp25 + tmp29
    tmp32 = tmp30 * tmp30
    tmp33 = tmp32 - tmp30
    tmp34 = tmp31 * tmp33
    tmp35 = tmp30 + tmp34
    tmp37 = tmp35 * tmp35
    tmp38 = tmp37 - tmp35
    tmp39 = tmp36 * tmp38
    tmp40 = tmp35 + tmp39
    tl.store(out_ptr0 + x2, tmp5, None)
    tl.store(out_ptr1 + x2, tmp20, None)
    tl.store(out_ptr2 + x2, tmp40, None)


@triton.jit
def triton_poi_fused_cat_4(in_ptr0, 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 % 24
    x0 = xindex % 4096
    x2 = xindex // 98304
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 3, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4096 * x1 + 98304 * x2), tmp4, other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 6, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr0 + (12288 + x0 + 4096 * (-3 + x1) + 98304 * x2),
        tmp9, other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 9, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr0 + (24576 + x0 + 4096 * (-6 + x1) + 98304 * x2),
        tmp14, other=0.0)
    tmp16 = tmp0 >= tmp12
    tmp17 = tl.full([1], 12, tl.int64)
    tmp18 = tmp0 < tmp17
    tmp19 = tmp16 & tmp18
    tmp20 = tl.load(in_ptr0 + (36864 + x0 + 4096 * (-9 + x1) + 98304 * x2),
        tmp19, other=0.0)
    tmp21 = tmp0 >= tmp17
    tmp22 = tl.full([1], 15, tl.int64)
    tmp23 = tmp0 < tmp22
    tmp24 = tmp21 & tmp23
    tmp25 = tl.load(in_ptr0 + (49152 + x0 + 4096 * (-12 + x1) + 98304 * x2),
        tmp24, other=0.0)
    tmp26 = tmp0 >= tmp22
    tmp27 = tl.full([1], 18, tl.int64)
    tmp28 = tmp0 < tmp27
    tmp29 = tmp26 & tmp28
    tmp30 = tl.load(in_ptr0 + (61440 + x0 + 4096 * (-15 + x1) + 98304 * x2),
        tmp29, other=0.0)
    tmp31 = tmp0 >= tmp27
    tmp32 = tl.full([1], 21, tl.int64)
    tmp33 = tmp0 < tmp32
    tmp34 = tmp31 & tmp33
    tmp35 = tl.load(in_ptr0 + (73728 + x0 + 4096 * (-18 + x1) + 98304 * x2),
        tmp34, other=0.0)
    tmp36 = tmp0 >= tmp32
    tl.full([1], 24, tl.int64)
    tmp39 = tl.load(in_ptr0 + (86016 + x0 + 4096 * (-21 + x1) + 98304 * x2),
        tmp36, other=0.0)
    tmp40 = tl.where(tmp34, tmp35, tmp39)
    tmp41 = tl.where(tmp29, tmp30, tmp40)
    tmp42 = tl.where(tmp24, tmp25, tmp41)
    tmp43 = tl.where(tmp19, tmp20, tmp42)
    tmp44 = tl.where(tmp14, tmp15, tmp43)
    tmp45 = tl.where(tmp9, tmp10, tmp44)
    tmp46 = tl.where(tmp4, tmp5, tmp45)
    tl.store(out_ptr0 + x3, tmp46, None)


@triton.jit
def triton_poi_fused_convolution_relu_threshold_backward_5(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) = args
    args.clear()
    assert_size_stride(primals_1, (32, 3, 3, 3), (27, 9, 3, 1))
    assert_size_stride(primals_2, (32,), (1,))
    assert_size_stride(primals_3, (4, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_4, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_7, (32,), (1,))
    assert_size_stride(primals_8, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_9, (32,), (1,))
    assert_size_stride(primals_10, (32, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_11, (32,), (1,))
    assert_size_stride(primals_12, (32, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_13, (32,), (1,))
    assert_size_stride(primals_14, (24, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_15, (24,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_relu_0[grid(524288)](buf1, primals_2, 
            524288, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_2
        buf2 = extern_kernels.convolution(buf1, 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, 32, 64, 64), (131072, 4096, 64, 1))
        buf3 = buf2
        del buf2
        triton_poi_fused_convolution_relu_0[grid(524288)](buf3, primals_5, 
            524288, XBLOCK=512, num_warps=8, 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=1, bias=None)
        assert_size_stride(buf4, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf5 = buf4
        del buf4
        triton_poi_fused_convolution_relu_0[grid(524288)](buf5, primals_7, 
            524288, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_7
        buf6 = extern_kernels.convolution(buf5, primals_8, stride=(1, 1),
            padding=(1, 1), 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 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_1[grid(1048576)](buf5, buf6, primals_9, buf7, 
            1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        buf8 = extern_kernels.convolution(buf7, primals_10, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf8, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf9 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_1[grid(1048576)](buf3, buf8, primals_11, buf9,
            1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        buf10 = 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(buf10, (4, 32, 64, 64), (131072, 4096, 64, 1))
        buf11 = empty_strided_cuda((4, 64, 64, 64), (262144, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_1[grid(1048576)](buf1, buf10, primals_13,
            buf11, 1048576, XBLOCK=1024, num_warps=4, num_stages=1)
        buf12 = extern_kernels.convolution(buf11, primals_14, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf12, (4, 24, 64, 64), (98304, 4096, 64, 1))
        buf13 = buf12
        del buf12
        triton_poi_fused_convolution_tanh_2[grid(393216)](buf13, primals_15,
            393216, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_15
        buf14 = empty_strided_cuda((4, 3, 64, 64), (12288, 4096, 64, 1),
            torch.float32)
        buf15 = empty_strided_cuda((4, 3, 64, 64), (12288, 4096, 64, 1),
            torch.float32)
        buf16 = empty_strided_cuda((4, 3, 64, 64), (12288, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_add_mul_pow_sub_3[grid(49152)](primals_3, buf13,
            buf14, buf15, buf16, 49152, XBLOCK=256, num_warps=4, num_stages=1)
        buf17 = empty_strided_cuda((4, 24, 64, 64), (98304, 4096, 64, 1),
            torch.float32)
        triton_poi_fused_cat_4[grid(393216)](buf13, buf17, 393216, XBLOCK=
            1024, num_warps=4, num_stages=1)
        buf18 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_5[grid(524288)](
            buf10, primals_13, buf18, 524288, XBLOCK=512, num_warps=8,
            num_stages=1)
        del buf10
        del primals_13
        buf19 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_5[grid(524288)](
            buf8, primals_11, buf19, 524288, XBLOCK=512, num_warps=8,
            num_stages=1)
        del buf8
        del primals_11
        buf20 = empty_strided_cuda((4, 32, 64, 64), (131072, 4096, 64, 1),
            torch.bool)
        triton_poi_fused_convolution_relu_threshold_backward_5[grid(524288)](
            buf6, primals_9, buf20, 524288, XBLOCK=512, num_warps=8,
            num_stages=1)
        del buf6
        del primals_9
    return (buf15, buf16, buf17, primals_1, primals_3, primals_4, primals_6,
        primals_8, primals_10, primals_12, primals_14, buf1, buf3, buf5,
        buf7, buf9, buf11, buf13, reinterpret_tensor(buf13, (4, 3, 64, 64),
        (98304, 4096, 64, 1), 12288), reinterpret_tensor(buf13, (4, 3, 64, 
        64), (98304, 4096, 64, 1), 24576), reinterpret_tensor(buf13, (4, 3,
        64, 64), (98304, 4096, 64, 1), 36864), reinterpret_tensor(buf13, (4,
        3, 64, 64), (98304, 4096, 64, 1), 49152), reinterpret_tensor(buf13,
        (4, 3, 64, 64), (98304, 4096, 64, 1), 61440), reinterpret_tensor(
        buf13, (4, 3, 64, 64), (98304, 4096, 64, 1), 73728),
        reinterpret_tensor(buf13, (4, 3, 64, 64), (98304, 4096, 64, 1), 
        86016), buf14, buf15, buf18, buf19, buf20)


class enhance_net_nopoolNew(nn.Module):

    def __init__(self):
        super(enhance_net_nopoolNew, self).__init__()
        self.relu = nn.ReLU(inplace=True)
        number_f = 32
        self.e_conv1 = nn.Conv2d(3, number_f, 3, 1, 1, bias=True)
        self.e_conv2 = nn.Conv2d(number_f, number_f, 3, 1, 1, bias=True)
        self.e_conv3 = nn.Conv2d(number_f, number_f, 3, 1, 1, bias=True)
        self.e_conv4 = nn.Conv2d(number_f, number_f, 3, 1, 1, bias=True)
        self.e_conv5 = nn.Conv2d(number_f * 2, number_f, 3, 1, 1, bias=True)
        self.e_conv6 = nn.Conv2d(number_f * 2, number_f, 3, 1, 1, bias=True)
        self.e_conv7 = nn.Conv2d(number_f * 2, 24, 3, 1, 1, bias=True)
        self.maxpool = nn.MaxPool2d(2, stride=2, return_indices=False,
            ceil_mode=False)
        self.upsample = nn.UpsamplingBilinear2d(scale_factor=2)

    def forward(self, input_0):
        primals_1 = self.e_conv1.weight
        primals_2 = self.e_conv1.bias
        primals_4 = self.e_conv2.weight
        primals_5 = self.e_conv2.bias
        primals_6 = self.e_conv3.weight
        primals_7 = self.e_conv3.bias
        primals_8 = self.e_conv4.weight
        primals_9 = self.e_conv4.bias
        primals_10 = self.e_conv5.weight
        primals_11 = self.e_conv5.bias
        primals_12 = self.e_conv6.weight
        primals_13 = self.e_conv6.bias
        primals_14 = self.e_conv7.weight
        primals_15 = self.e_conv7.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])
        return output[0], output[1], output[2]


Measured latency_ms: 0.014008