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 M
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_relu_0(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_out_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr0 + 0)
    tmp2 = tl.broadcast_to(tmp1, [XBLOCK])
    tmp3 = tmp0 + tmp2
    tmp4 = tl.full([1], 0, tl.int32)
    tmp5 = triton_helpers.maximum(tmp4, tmp3)
    tl.store(in_out_ptr0 + x0, tmp5, xmask)


@triton.jit
def triton_poi_fused_add_convolution_relu_threshold_backward_1(in_out_ptr0,
    in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 4 % 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)
    tmp4 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp6 = tmp2 + tmp5
    tmp7 = tl.full([1], 0, tl.int32)
    tmp8 = triton_helpers.maximum(tmp7, tmp6)
    tmp9 = 0.0
    tmp10 = tmp8 <= tmp9
    tl.store(in_out_ptr0 + x3, tmp8, xmask)
    tl.store(out_ptr0 + x3, tmp10, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 1, 5, 5), (25, 25, 5, 1))
    assert_size_stride(primals_3, (1, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_4, (1,), (1,))
    assert_size_stride(primals_5, (1, 1, 5, 5), (25, 25, 5, 1))
    assert_size_stride(primals_6, (4, 1, 1, 1), (1, 1, 1, 1))
    assert_size_stride(primals_7, (4,), (1,))
    assert_size_stride(primals_8, (4, 1, 3, 3), (9, 9, 3, 1))
    assert_size_stride(primals_9, (4, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_10, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_1, primals_2, stride=(2, 
            2), padding=(2, 2), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=4, bias=None)
        assert_size_stride(buf0, (4, 4, 2, 2), (16, 4, 2, 1))
        buf1 = extern_kernels.convolution(buf0, primals_3, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf1, (4, 1, 2, 2), (4, 4, 2, 1))
        buf2 = buf1
        del buf1
        get_raw_stream(0)
        triton_poi_fused_convolution_relu_0[grid(16)](buf2, primals_4, 16,
            XBLOCK=16, num_warps=1, num_stages=1)
        del primals_4
        buf3 = extern_kernels.convolution(buf2, primals_5, stride=(1, 1),
            padding=(2, 2), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (4, 1, 2, 2), (4, 4, 2, 1))
        buf4 = extern_kernels.convolution(buf3, primals_6, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf4, (4, 4, 2, 2), (16, 4, 2, 1))
        buf5 = extern_kernels.convolution(primals_1, primals_8, stride=(2, 
            2), padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=4, bias=None)
        assert_size_stride(buf5, (4, 4, 2, 2), (16, 4, 2, 1))
        buf6 = extern_kernels.convolution(buf5, primals_9, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf6, (4, 4, 2, 2), (16, 4, 2, 1))
        buf7 = buf4
        del buf4
        buf8 = empty_strided_cuda((4, 4, 2, 2), (16, 4, 2, 1), torch.bool)
        triton_poi_fused_add_convolution_relu_threshold_backward_1[grid(64)](
            buf7, primals_7, buf6, primals_10, buf8, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf6
        del primals_10
        del primals_7
    return (buf7, primals_1, primals_2, primals_3, primals_5, primals_6,
        primals_8, primals_9, buf0, buf2, buf3, buf5, buf8)


def DepthwiseConv(in_channels, kernel_size, stride, padding):
    return M.Conv2d(in_channels=in_channels, out_channels=in_channels,
        kernel_size=kernel_size, stride=stride, padding=padding, groups=
        in_channels, bias=False)


def PointwiseConv(in_channels, out_channels):
    return M.Conv2d(in_channels=in_channels, out_channels=out_channels,
        kernel_size=1, padding=0, bias=True)


class CovSepBlock(M.Module):

    def __init__(self, in_channels, out_channels, kernel_size=5, stride=1,
        padding=2):
        super().__init__()
        self.dc = DepthwiseConv(in_channels, kernel_size, stride=stride,
            padding=padding)
        self.pc = PointwiseConv(in_channels, out_channels)

    def forward(self, x):
        x = self.dc(x)
        x = self.pc(x)
        return x


class DownsamplingNew(M.Module):

    def __init__(self, in_channels, out_channels):
        super().__init__()
        self.sepconv = CovSepBlock(in_channels=in_channels, out_channels=
            out_channels // 4, stride=2, padding=2)
        self.activate = M.ReLU(inplace=True)
        self.sepconv2 = CovSepBlock(in_channels=out_channels // 4,
            out_channels=out_channels, padding=2)
        self.branchconv = CovSepBlock(in_channels, out_channels,
            kernel_size=3, stride=2, padding=1)
        self.activate2 = M.ReLU(inplace=True)

    def forward(self, input_0):
        primals_2 = self.sepconv.dc.weight
        primals_3 = self.sepconv.pc.weight
        primals_4 = self.sepconv.pc.bias
        primals_5 = self.sepconv2.dc.weight
        primals_6 = self.sepconv2.pc.weight
        primals_7 = self.sepconv2.pc.bias
        primals_8 = self.branchconv.dc.weight
        primals_9 = self.branchconv.pc.weight
        primals_10 = self.branchconv.pc.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])
        return output[0]


Measured latency_ms: 0.077268