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
import torch.nn
import torch.utils.data.distributed
import torch.nn as nn
import torch.nn.parallel
import torch.optim
import torch.utils.data
assert_size_stride = torch._C._dynamo.guards.assert_size_stride


@triton.jit
def triton_poi_fused_convolution_0(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 254016
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 3969 % 16
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


@triton.jit
def triton_poi_fused_convolution_1(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 492032
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 3844 % 32
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


@triton.jit
def triton_poi_fused_convolution_2(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 238144
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 3721 % 16
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


@triton.jit
def triton_poi_fused_convolution_3(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 115200
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 3600 % 8
    tmp0 = tl.load(in_out_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x3, tmp2, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9) = args
    args.clear()
    assert_size_stride(primals_1, (4, 8, 64, 64), (32768, 4096, 64, 1))
    assert_size_stride(primals_2, (16, 8, 2, 2), (32, 4, 2, 1))
    assert_size_stride(primals_3, (16,), (1,))
    assert_size_stride(primals_4, (32, 16, 2, 2), (64, 4, 2, 1))
    assert_size_stride(primals_5, (32,), (1,))
    assert_size_stride(primals_6, (16, 32, 2, 2), (128, 4, 2, 1))
    assert_size_stride(primals_7, (16,), (1,))
    assert_size_stride(primals_8, (8, 16, 2, 2), (64, 4, 2, 1))
    assert_size_stride(primals_9, (8,), (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, 16, 63, 63), (63504, 3969, 63, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_0[grid(254016)](buf1, primals_3, 
            254016, XBLOCK=512, num_warps=8, 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, 62, 62), (123008, 3844, 62, 1))
        buf3 = buf2
        del buf2
        triton_poi_fused_convolution_1[grid(492032)](buf3, primals_5, 
            492032, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_5
        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, 16, 61, 61), (59536, 3721, 61, 1))
        buf5 = buf4
        del buf4
        triton_poi_fused_convolution_2[grid(238144)](buf5, primals_7, 
            238144, XBLOCK=512, num_warps=8, 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, 8, 60, 60), (28800, 3600, 60, 1))
        buf7 = buf6
        del buf6
        triton_poi_fused_convolution_3[grid(115200)](buf7, primals_9, 
            115200, XBLOCK=1024, num_warps=4, num_stages=1)
        del primals_9
    return (buf7, primals_1, primals_2, primals_4, primals_6, primals_8,
        buf1, buf3, buf5)


class ConvNetNew(nn.Module):

    def __init__(self, gpus, layouts, dtypes):
        super(ConvNetNew, self).__init__()
        self.dtypes = dtypes
        if isinstance(gpus, list):
            self.layer_gpus = gpus
        else:
            gpus = [gpus] * 4
        self.conv0 = torch.nn.Conv2d(8, 16, (2, 2))
        self.conv1 = torch.nn.Conv2d(16, 32, (2, 2))
        self.conv2 = torch.nn.Conv2d(32, 16, (2, 2))
        self.conv3 = torch.nn.Conv2d(16, 8, (2, 2))

    def forward(self, input_0):
        primals_2 = self.conv0.weight
        primals_3 = self.conv0.bias
        primals_4 = self.conv1.weight
        primals_5 = self.conv1.bias
        primals_6 = self.conv2.weight
        primals_7 = self.conv2.bias
        primals_8 = self.conv3.weight
        primals_9 = self.conv3.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])
        return output[0]


Measured latency_ms: 0.091727