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 import 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_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 12
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    x2 = xindex
    y3 = yindex
    y0 = yindex % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 4096 * y3), ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 12288 * y1), tmp0, ymask)


@triton.jit
def triton_poi_fused_1(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 288
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 3
    y1 = yindex // 3
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask & ymask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + (y0 + 3 * x2 + 27 * y1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 96
    y1 = yindex // 96
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 96 * x2 + 864 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_3(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 96
    y1 = yindex // 96
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 96 * x2 + 864 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_4(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    xnumel = 9
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y3 = yindex
    y0 = yindex % 192
    y1 = yindex // 192
    tmp0 = tl.load(in_ptr0 + (x2 + 9 * y3), xmask, eviction_policy='evict_last'
        )
    tl.store(out_ptr0 + (y0 + 192 * x2 + 1728 * y1), tmp0, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_5(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)
    x2 = xindex
    x0 = xindex % 96
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, 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 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_convolution_relu_6(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)
    x2 = xindex
    x0 = xindex % 96
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, 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 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_convolution_relu_7(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)
    x2 = xindex
    x0 = xindex % 192
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, 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 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_convolution_relu_8(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)
    x2 = xindex
    x0 = xindex % 192
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x0, 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 + x2, tmp4, None)


@triton.jit
def triton_poi_fused_convolution_relu_9(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 150528
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 192
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, 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 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_convolution_relu_10(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 7840
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 10
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, 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 + x2, tmp4, xmask)


@triton.jit
def triton_poi_fused_squeeze_11(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK:
    tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 40
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 10
    y1 = yindex // 10
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 10 * x2 + 40 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask & ymask)


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, 3, 64, 64), (12288, 4096, 64, 1))
    assert_size_stride(primals_2, (96, 3, 3, 3), (27, 9, 3, 1))
    assert_size_stride(primals_3, (96,), (1,))
    assert_size_stride(primals_4, (96, 96, 3, 3), (864, 9, 3, 1))
    assert_size_stride(primals_5, (96,), (1,))
    assert_size_stride(primals_6, (96, 96, 3, 3), (864, 9, 3, 1))
    assert_size_stride(primals_7, (96,), (1,))
    assert_size_stride(primals_8, (192, 96, 3, 3), (864, 9, 3, 1))
    assert_size_stride(primals_9, (192,), (1,))
    assert_size_stride(primals_10, (192, 192, 3, 3), (1728, 9, 3, 1))
    assert_size_stride(primals_11, (192,), (1,))
    assert_size_stride(primals_12, (192, 192, 3, 3), (1728, 9, 3, 1))
    assert_size_stride(primals_13, (192,), (1,))
    assert_size_stride(primals_14, (192, 192, 3, 3), (1728, 9, 3, 1))
    assert_size_stride(primals_15, (192,), (1,))
    assert_size_stride(primals_16, (192, 192, 1, 1), (192, 1, 1, 1))
    assert_size_stride(primals_17, (192,), (1,))
    assert_size_stride(primals_18, (10, 192, 1, 1), (192, 1, 1, 1))
    assert_size_stride(primals_19, (10,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 3, 64, 64), (12288, 1, 192, 3), torch
            .float32)
        get_raw_stream(0)
        triton_poi_fused_0[grid(12, 4096)](primals_1, buf0, 12, 4096,
            XBLOCK=64, YBLOCK=16, num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((96, 3, 3, 3), (27, 1, 9, 3), torch.float32)
        triton_poi_fused_1[grid(288, 9)](primals_2, buf1, 288, 9, XBLOCK=16,
            YBLOCK=64, num_warps=4, num_stages=1)
        del primals_2
        buf2 = empty_strided_cuda((96, 96, 3, 3), (864, 1, 288, 96), torch.
            float32)
        triton_poi_fused_2[grid(9216, 9)](primals_4, buf2, 9216, 9, XBLOCK=
            16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_4
        buf3 = empty_strided_cuda((96, 96, 3, 3), (864, 1, 288, 96), torch.
            float32)
        triton_poi_fused_2[grid(9216, 9)](primals_6, buf3, 9216, 9, XBLOCK=
            16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_6
        buf4 = empty_strided_cuda((192, 96, 3, 3), (864, 1, 288, 96), torch
            .float32)
        triton_poi_fused_3[grid(18432, 9)](primals_8, buf4, 18432, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_8
        buf5 = empty_strided_cuda((192, 192, 3, 3), (1728, 1, 576, 192),
            torch.float32)
        triton_poi_fused_4[grid(36864, 9)](primals_10, buf5, 36864, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_10
        buf6 = empty_strided_cuda((192, 192, 3, 3), (1728, 1, 576, 192),
            torch.float32)
        triton_poi_fused_4[grid(36864, 9)](primals_12, buf6, 36864, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_12
        buf7 = empty_strided_cuda((192, 192, 3, 3), (1728, 1, 576, 192),
            torch.float32)
        triton_poi_fused_4[grid(36864, 9)](primals_14, buf7, 36864, 9,
            XBLOCK=16, YBLOCK=64, num_warps=4, num_stages=1)
        del primals_14
        buf8 = extern_kernels.convolution(buf0, buf1, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf8, (4, 96, 64, 64), (393216, 1, 6144, 96))
        buf9 = buf8
        del buf8
        triton_poi_fused_convolution_relu_5[grid(1572864)](buf9, primals_3,
            1572864, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_3
        buf10 = extern_kernels.convolution(buf9, buf2, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (4, 96, 64, 64), (393216, 1, 6144, 96))
        buf11 = buf10
        del buf10
        triton_poi_fused_convolution_relu_5[grid(1572864)](buf11, primals_5,
            1572864, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_5
        buf12 = extern_kernels.convolution(buf11, buf3, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf12, (4, 96, 32, 32), (98304, 1, 3072, 96))
        buf13 = buf12
        del buf12
        triton_poi_fused_convolution_relu_6[grid(393216)](buf13, primals_7,
            393216, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_7
        buf14 = extern_kernels.convolution(buf13, buf4, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf14, (4, 192, 32, 32), (196608, 1, 6144, 192))
        buf15 = buf14
        del buf14
        triton_poi_fused_convolution_relu_7[grid(786432)](buf15, primals_9,
            786432, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_9
        buf16 = extern_kernels.convolution(buf15, buf5, stride=(1, 1),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf16, (4, 192, 32, 32), (196608, 1, 6144, 192))
        buf17 = buf16
        del buf16
        triton_poi_fused_convolution_relu_7[grid(786432)](buf17, primals_11,
            786432, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_11
        buf18 = extern_kernels.convolution(buf17, buf6, stride=(2, 2),
            padding=(1, 1), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf18, (4, 192, 16, 16), (49152, 1, 3072, 192))
        buf19 = buf18
        del buf18
        triton_poi_fused_convolution_relu_8[grid(196608)](buf19, primals_13,
            196608, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_13
        buf20 = extern_kernels.convolution(buf19, buf7, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf20, (4, 192, 14, 14), (37632, 1, 2688, 192))
        buf21 = buf20
        del buf20
        triton_poi_fused_convolution_relu_9[grid(150528)](buf21, primals_15,
            150528, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_15
        buf22 = extern_kernels.convolution(buf21, primals_16, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf22, (4, 192, 14, 14), (37632, 1, 2688, 192))
        buf23 = buf22
        del buf22
        triton_poi_fused_convolution_relu_9[grid(150528)](buf23, primals_17,
            150528, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_17
        buf24 = extern_kernels.convolution(buf23, primals_18, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf24, (4, 10, 14, 14), (1960, 1, 140, 10))
        buf25 = buf24
        del buf24
        triton_poi_fused_convolution_relu_10[grid(7840)](buf25, primals_19,
            7840, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_19
        buf26 = torch.ops.aten.avg_pool2d.default(buf25, [6, 6], [6, 6], [0,
            0], False, True, None)
        buf27 = buf26
        del buf26
        buf28 = empty_strided_cuda((4, 10, 2, 2), (40, 4, 2, 1), torch.float32)
        triton_poi_fused_squeeze_11[grid(40, 4)](buf27, buf28, 40, 4,
            XBLOCK=4, YBLOCK=32, num_warps=4, num_stages=1)
        del buf27
    return (buf28, buf0, buf1, buf2, buf3, buf4, buf5, buf6, buf7,
        primals_16, primals_18, buf9, buf11, buf13, buf15, buf17, buf19,
        buf21, buf23, buf25)


class ALL_CNN_CNew(nn.Module):

    def __init__(self, num_classes=10):
        super(ALL_CNN_CNew, self).__init__()
        self.model_name = 'ALL_CNN_C'
        self.dp0 = nn.Dropout2d(p=0.2)
        self.conv1 = nn.Conv2d(3, 96, 3, padding=1)
        self.conv2 = nn.Conv2d(96, 96, 3, padding=1)
        self.conv3 = nn.Conv2d(96, 96, 3, stride=2, padding=1)
        self.dp1 = nn.Dropout2d(p=0.5)
        self.conv4 = nn.Conv2d(96, 192, 3, padding=1)
        self.conv5 = nn.Conv2d(192, 192, 3, padding=1)
        self.conv6 = nn.Conv2d(192, 192, 3, stride=2, padding=1)
        self.dp2 = nn.Dropout2d(p=0.5)
        self.conv7 = nn.Conv2d(192, 192, 3, padding=0)
        self.conv8 = nn.Conv2d(192, 192, 1)
        self.conv9 = nn.Conv2d(192, 10, 1)
        self.avg = nn.AvgPool2d(6)

    def forward(self, input_0):
        primals_2 = self.conv1.weight
        primals_3 = self.conv1.bias
        primals_4 = self.conv2.weight
        primals_5 = self.conv2.bias
        primals_6 = self.conv3.weight
        primals_7 = self.conv3.bias
        primals_8 = self.conv4.weight
        primals_9 = self.conv4.bias
        primals_10 = self.conv5.weight
        primals_11 = self.conv5.bias
        primals_12 = self.conv6.weight
        primals_13 = self.conv6.bias
        primals_14 = self.conv7.weight
        primals_15 = self.conv7.bias
        primals_16 = self.conv8.weight
        primals_17 = self.conv8.bias
        primals_18 = self.conv9.weight
        primals_19 = self.conv9.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])
        return output[0]


Measured latency_ms: 0.490008