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 as nn
import torch.nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_convolution_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)
    x2 = xindex
    x1 = xindex // 64
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x2, tmp2, None)


@triton.jit
def triton_poi_fused_add_1(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 64
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr1 + x2, xmask)
    tmp4 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp6 = tmp2 + tmp5
    tl.store(in_out_ptr0 + x2, tmp6, 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, (256, 4, 1, 7, 1), (28, 7, 7, 1, 1))
    assert_size_stride(primals_2, (256,), (1,))
    assert_size_stride(primals_3, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_4, (4, 256, 1, 1, 7), (1792, 7, 7, 7, 1))
    assert_size_stride(primals_5, (4,), (1,))
    assert_size_stride(primals_6, (256, 4, 1, 1, 7), (28, 7, 7, 7, 1))
    assert_size_stride(primals_7, (256,), (1,))
    assert_size_stride(primals_8, (4, 256, 1, 7, 1), (1792, 7, 7, 1, 1))
    assert_size_stride(primals_9, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(reinterpret_tensor(primals_3, (1,
            4, 4, 4, 4), (256, 64, 16, 4, 1), 0), primals_1, stride=(1, 1, 
            1), padding=(0, 3, 0), dilation=(1, 1, 1), transposed=False,
            output_padding=(0, 0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (1, 256, 4, 4, 4), (16384, 64, 16, 4, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_0[grid(16384)](buf1, primals_2, 16384,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_2
        buf2 = extern_kernels.convolution(reinterpret_tensor(buf1, (1, 256,
            4, 4, 4), (0, 64, 16, 4, 1), 0), primals_4, stride=(1, 1, 1),
            padding=(0, 0, 3), dilation=(1, 1, 1), transposed=False,
            output_padding=(0, 0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (1, 4, 4, 4, 4), (256, 64, 16, 4, 1))
        buf3 = extern_kernels.convolution(reinterpret_tensor(primals_3, (1,
            4, 4, 4, 4), (256, 64, 16, 4, 1), 0), primals_6, stride=(1, 1, 
            1), padding=(0, 0, 3), dilation=(1, 1, 1), transposed=False,
            output_padding=(0, 0, 0), groups=1, bias=None)
        assert_size_stride(buf3, (1, 256, 4, 4, 4), (16384, 64, 16, 4, 1))
        buf4 = buf3
        del buf3
        triton_poi_fused_convolution_0[grid(16384)](buf4, primals_7, 16384,
            XBLOCK=128, num_warps=4, num_stages=1)
        del primals_7
        buf5 = extern_kernels.convolution(reinterpret_tensor(buf4, (1, 256,
            4, 4, 4), (0, 64, 16, 4, 1), 0), primals_8, stride=(1, 1, 1),
            padding=(0, 3, 0), dilation=(1, 1, 1), transposed=False,
            output_padding=(0, 0, 0), groups=1, bias=None)
        assert_size_stride(buf5, (1, 4, 4, 4, 4), (256, 64, 16, 4, 1))
        buf6 = reinterpret_tensor(buf2, (4, 4, 4, 4), (64, 16, 4, 1), 0)
        del buf2
        triton_poi_fused_add_1[grid(256)](buf6, primals_5, buf5, primals_9,
            256, XBLOCK=256, num_warps=4, num_stages=1)
        del buf5
        del primals_5
        del primals_9
    return (buf6, primals_1, primals_4, primals_6, primals_8,
        reinterpret_tensor(primals_3, (1, 4, 4, 4, 4), (256, 64, 16, 4, 1),
        0), buf1, buf4)


class GC3dNew(nn.Module):

    def __init__(self, inplanes, planes, kh=7, kw=7, mdim=256, which_conv=
        nn.Conv3d):
        super(GC3dNew, self).__init__()
        self.conv_l1 = which_conv(inplanes, mdim, kernel_size=(1, kh, 1),
            padding=(0, int(kh / 2), 0))
        self.conv_l2 = which_conv(mdim, planes, kernel_size=(1, 1, kw),
            padding=(0, 0, int(kw / 2)))
        self.conv_r1 = which_conv(inplanes, mdim, kernel_size=(1, 1, kw),
            padding=(0, 0, int(kw / 2)))
        self.conv_r2 = which_conv(mdim, planes, kernel_size=(1, kh, 1),
            padding=(0, int(kh / 2), 0))

    def forward(self, input_0):
        primals_1 = self.conv_l1.weight
        primals_2 = self.conv_l1.bias
        primals_4 = self.conv_l2.weight
        primals_5 = self.conv_l2.bias
        primals_6 = self.conv_r1.weight
        primals_7 = self.conv_r1.bias
        primals_8 = self.conv_r2.weight
        primals_9 = self.conv_r2.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])
        return output[0]


Measured latency_ms: 0.031225