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 math
import torch.nn as nn
from torch.nn.parameter import Parameter
from torch.nn import Parameter
import torch.nn
import torch.autograd
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_add_cat_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 4
    x1 = xindex // 4
    x2 = xindex
    tmp11 = tl.load(in_ptr2 + x0, xmask, eviction_policy='evict_last')
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 2, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (2 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tl.full([1], 4, tl.int64)
    tmp9 = tl.load(in_ptr1 + (2 + 4 * x1 + (-2 + x0)), tmp6 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp10 = tl.where(tmp4, tmp5, tmp9)
    tmp12 = tmp10 + tmp11
    tl.store(out_ptr0 + x2, tmp12, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.mm(primals_2, primals_1, out=buf0)
        del primals_1
        buf1 = empty_strided_cuda((4, 2), (2, 1), torch.float32)
        extern_kernels.mm(primals_3, reinterpret_tensor(buf0, (4, 2), (4, 1
            ), 0), out=buf1)
        buf2 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_cat_0[grid(16)](buf1, buf0, primals_4, buf2, 
            16, XBLOCK=16, num_warps=1, num_stages=1)
        del buf0
        del buf1
        del primals_4
    return buf2, reinterpret_tensor(primals_3, (4, 4), (1, 4), 0
        ), reinterpret_tensor(primals_2, (4, 4), (1, 4), 0)


class SimpleGCNNew(nn.Module):
    """A simple graph convolution layer, similar to the one defined in
    Kipf et al. https://arxiv.org/abs/1609.02907

    .. note::

        If you use this code, please cite the original paper in addition to Kaolin.

        .. code-block::

            @article{kipf2016semi,
              title={Semi-Supervised Classification with Graph Convolutional Networks},
              author={Kipf, Thomas N and Welling, Max},
              journal={arXiv preprint arXiv:1609.02907},
              year={2016}
            }

    """

    def __init__(self, in_features, out_features, bias=True):
        super(SimpleGCNNew, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.weight1 = Parameter(torch.Tensor(in_features, out_features))
        if bias:
            self.bias = Parameter(torch.Tensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        stdv = 6.0 / math.sqrt(self.weight1.size(1) + self.weight1.size(0))
        stdv *= 0.6
        self.weight1.data.uniform_(-stdv, stdv)
        if self.bias is not None:
            self.bias.data.uniform_(-0.1, 0.1)

    def __repr__(self):
        return self.__class__.__name__ + ' (' + str(self.in_features
            ) + ' -> ' + str(self.out_features) + ')'

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


Measured latency_ms: 0.029662