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
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_relu_0(in_out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + x0, None)
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tl.store(in_out_ptr0 + x0, tmp2, None)


@triton.jit
def triton_poi_fused_cat_1(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)
    x1 = xindex // 16 % 64
    x0 = xindex % 16
    x2 = xindex // 1024
    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 + 16 * x1 + 512 * x2), tmp4, other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 64, tl.int64)
    tmp9 = tl.load(in_ptr1 + (x0 + 16 * (-32 + x1) + 512 * x2), tmp6, other=0.0
        )
    tmp10 = tl.full([1], 0, tl.int32)
    tmp11 = triton_helpers.maximum(tmp10, tmp9)
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp6, tmp11, tmp12)
    tmp14 = tl.where(tmp4, tmp5, tmp13)
    tl.store(out_ptr0 + x3, tmp14, None)


@triton.jit
def triton_poi_fused_cat_2(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)
    x1 = xindex // 16 % 96
    x0 = xindex % 16
    x2 = xindex // 1536
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 64, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 16 * x1 + 1024 * x2), tmp4, other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 96, tl.int64)
    tmp9 = tl.load(in_ptr1 + (x0 + 16 * (-64 + x1) + 512 * x2), tmp6, other=0.0
        )
    tmp10 = tl.full([1], 0, tl.int32)
    tmp11 = triton_helpers.maximum(tmp10, tmp9)
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp6, tmp11, tmp12)
    tmp14 = tl.where(tmp4, tmp5, tmp13)
    tl.store(out_ptr0 + x3, tmp14, None)


@triton.jit
def triton_poi_fused_add_cat_relu_threshold_backward_3(in_ptr0, in_ptr1,
    in_ptr2, out_ptr0, out_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 // 16 % 128
    x0 = xindex % 16
    x2 = xindex // 2048
    tmp0 = tl.load(in_ptr0 + x3, None)
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = x1
    tl.full([1], 0, tl.int64)
    tmp6 = tl.full([1], 96, tl.int64)
    tmp7 = tmp3 < tmp6
    tmp8 = tl.load(in_ptr1 + (x0 + 16 * x1 + 1536 * x2), tmp7, other=0.0)
    tmp9 = tmp3 >= tmp6
    tl.full([1], 128, tl.int64)
    tmp12 = tl.load(in_ptr2 + (x0 + 16 * (-96 + x1) + 512 * x2), tmp9,
        other=0.0)
    tmp13 = triton_helpers.maximum(tmp1, tmp12)
    tmp14 = tl.full(tmp13.shape, 0.0, tmp13.dtype)
    tmp15 = tl.where(tmp9, tmp13, tmp14)
    tmp16 = tl.where(tmp7, tmp8, tmp15)
    tmp17 = tmp2 + tmp16
    tmp18 = 0.0
    tmp19 = tmp2 <= tmp18
    tl.store(out_ptr0 + x3, tmp17, None)
    tl.store(out_ptr1 + x3, tmp19, None)


@triton.jit
def triton_poi_fused_relu_threshold_backward_4(in_out_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)
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + x0, None)
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = 0.0
    tmp4 = tmp2 <= tmp3
    tl.store(in_out_ptr0 + x0, tmp2, None)
    tl.store(out_ptr0 + x0, tmp4, None)


@triton.jit
def triton_poi_fused_relu_threshold_backward_5(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)
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, None)
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = 0.0
    tmp4 = tmp2 <= tmp3
    tl.store(out_ptr0 + x0, tmp4, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (128, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_3, (32, 4, 3, 3), (36, 9, 3, 1))
    assert_size_stride(primals_4, (32, 32, 3, 3), (288, 9, 3, 1))
    assert_size_stride(primals_5, (32, 64, 3, 3), (576, 9, 3, 1))
    assert_size_stride(primals_6, (32, 96, 3, 3), (864, 9, 3, 1))
    assert_size_stride(primals_7, (64, 128, 1, 1), (128, 1, 1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_1, primals_2, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 128, 4, 4), (2048, 16, 4, 1))
        buf1 = extern_kernels.convolution(primals_1, primals_3, stride=(1, 
            1), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 32, 4, 4), (512, 16, 4, 1))
        buf2 = buf1
        del buf1
        get_raw_stream(0)
        triton_poi_fused_relu_0[grid(2048)](buf2, 2048, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf3 = extern_kernels.convolution(buf2, primals_4, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 32, 4, 4), (512, 16, 4, 1))
        buf4 = empty_strided_cuda((4, 64, 4, 4), (1024, 16, 4, 1), torch.
            float32)
        triton_poi_fused_cat_1[grid(4096)](buf2, buf3, buf4, 4096, XBLOCK=
            256, num_warps=4, num_stages=1)
        buf5 = extern_kernels.convolution(buf4, primals_5, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (4, 32, 4, 4), (512, 16, 4, 1))
        buf6 = empty_strided_cuda((4, 96, 4, 4), (1536, 16, 4, 1), torch.
            float32)
        triton_poi_fused_cat_2[grid(6144)](buf4, buf5, buf6, 6144, XBLOCK=
            128, num_warps=4, num_stages=1)
        buf7 = extern_kernels.convolution(buf6, primals_6, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (4, 32, 4, 4), (512, 16, 4, 1))
        buf8 = empty_strided_cuda((4, 128, 4, 4), (2048, 16, 4, 1), torch.
            float32)
        buf15 = empty_strided_cuda((4, 128, 4, 4), (2048, 16, 4, 1), torch.bool
            )
        triton_poi_fused_add_cat_relu_threshold_backward_3[grid(8192)](buf0,
            buf6, buf7, buf8, buf15, 8192, XBLOCK=128, num_warps=4,
            num_stages=1)
        del buf0
        buf9 = extern_kernels.convolution(buf8, primals_7, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf9, (4, 64, 4, 4), (1024, 16, 4, 1))
        buf10 = buf9
        del buf9
        buf11 = empty_strided_cuda((4, 64, 4, 4), (1024, 16, 4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_4[grid(4096)](buf10, buf11,
            4096, XBLOCK=256, num_warps=4, num_stages=1)
        buf12 = empty_strided_cuda((4, 32, 4, 4), (512, 16, 4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_5[grid(2048)](buf7, buf12,
            2048, XBLOCK=128, num_warps=4, num_stages=1)
        del buf7
        buf13 = empty_strided_cuda((4, 32, 4, 4), (512, 16, 4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_5[grid(2048)](buf5, buf13,
            2048, XBLOCK=128, num_warps=4, num_stages=1)
        del buf5
        buf14 = empty_strided_cuda((4, 32, 4, 4), (512, 16, 4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_5[grid(2048)](buf3, buf14,
            2048, XBLOCK=128, num_warps=4, num_stages=1)
        del buf3
    return (buf10, primals_1, primals_2, primals_3, primals_4, primals_5,
        primals_6, primals_7, buf2, buf4, buf6, buf8, buf11, buf12, buf13,
        buf14, buf15)


class Conv_ReLU_BlockNew(nn.Module):

    def __init__(self, channel_in):
        super(Conv_ReLU_BlockNew, self).__init__()
        self.conv_0 = nn.Conv2d(in_channels=channel_in, out_channels=128,
            kernel_size=1, stride=1, padding=0, bias=False)
        self.conv_1 = nn.Conv2d(in_channels=channel_in, out_channels=32,
            kernel_size=3, stride=1, padding=1, bias=False)
        self.conv_2 = nn.Conv2d(in_channels=32, out_channels=32,
            kernel_size=3, stride=1, padding=1, bias=False)
        self.conv_3 = nn.Conv2d(in_channels=64, out_channels=32,
            kernel_size=3, stride=1, padding=1, bias=False)
        self.conv_4 = nn.Conv2d(in_channels=96, out_channels=32,
            kernel_size=3, stride=1, padding=1, bias=False)
        self.conv_5 = nn.Conv2d(in_channels=128, out_channels=64,
            kernel_size=1, stride=1, padding=0, bias=False)
        self.relu = nn.ReLU(inplace=True)

    def forward(self, input_0):
        primals_2 = self.conv_0.weight
        primals_3 = self.conv_1.weight
        primals_4 = self.conv_2.weight
        primals_5 = self.conv_3.weight
        primals_6 = self.conv_4.weight
        primals_7 = self.conv_5.weight
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7])
        return output[0]


Measured latency_ms: 0.188561