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
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_clone_0(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = xindex // 4 % 4
    x4 = xindex // 256
    x5 = xindex // 16 % 16
    x3 = xindex // 64 % 4
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 4 * x5 + 64 * x1 + 256 * x4), xmask)
    tmp1 = tl.load(in_ptr1 + (x3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + x6, tmp2, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (16, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_3, (16,), (1,))
    assert_size_stride(primals_4, (4, 4, 4, 4), (64, 16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_4, 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, 4, 4), (256, 16, 4, 1))
        buf1 = empty_strided_cuda((4, 4, 4, 4, 4, 1), (256, 64, 16, 4, 1, 1
            ), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_clone_0[grid(1024)](buf0, primals_3, buf1, 1024,
            XBLOCK=128, num_warps=4, num_stages=1)
        del buf0
        del primals_3
        buf2 = empty_strided_cuda((1, 64, 4), (256, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf1, (1, 64, 16), (0, 16, 1),
            0), reinterpret_tensor(primals_1, (1, 16, 4), (64, 4, 1), 0),
            out=buf2)
        del buf1
    return reinterpret_tensor(buf2, (4, 4, 4, 4), (64, 16, 4, 1), 0
        ), primals_2, primals_4, reinterpret_tensor(primals_1, (1, 4, 16),
        (64, 1, 4), 0)


class ConvTemporalGraphicalNew(nn.Module):
    """The basic module for applying a graph convolution.
    Args:
        in_channels (int): Number of channels in the input sequence data
        out_channels (int): Number of channels produced by the convolution
        kernel_size (int): Size of the graph convolving kernel
        t_kernel_size (int): Size of the temporal convolving kernel
        t_stride (int, optional): Stride of the temporal convolution. Default: 1
        t_padding (int, optional): Temporal zero-padding added to both sides of
            the input. Default: 0
        t_dilation (int, optional): Spacing between temporal kernel elements.
            Default: 1
        bias (bool, optional): If ``True``, adds a learnable bias to the output.
            Default: ``True``
    Shape:
        - Input[0]: Input graph sequence in :math:`(N, in_channels, T_{in}, V)` format
        - Input[1]: Input graph adjacency matrix in :math:`(K, V, V)` format
        - Output[0]: Outpu graph sequence in :math:`(N, out_channels, T_{out}, V)` format
        - Output[1]: Graph adjacency matrix for output data in :math:`(K, V, V)` format
        where
            :math:`N` is a batch size,
            :math:`K` is the spatial kernel size, as :math:`K == kernel_size[1]`,
            :math:`T_{in}/T_{out}` is a length of input/output sequence,
            :math:`V` is the number of graph nodes.
    """

    def __init__(self, in_channels, out_channels, kernel_size,
        t_kernel_size=1, t_stride=1, t_padding=0, t_dilation=1, bias=True):
        super().__init__()
        self.kernel_size = kernel_size
        self.conv = nn.Conv2d(in_channels, out_channels * kernel_size,
            kernel_size=(t_kernel_size, 1), padding=(t_padding, 0), stride=
            (t_stride, 1), dilation=(t_dilation, 1), bias=bias)

    def forward(self, input_0, input_1):
        primals_2 = self.conv.weight
        primals_3 = self.conv.bias
        primals_4 = input_0
        primals_1 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4])
        return output[0], output[1]


Measured latency_ms: 0.015792