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._inductor.runtime.triton_helpers import libdevice
import math
from torch.nn import Parameter
import torch.utils.data
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_index_put_lift_fresh_0(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_index_put_lift_fresh_1(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
    tmp0 = 1.0
    tl.store(out_ptr0 + (5 * x0 + 16 * x1), tmp0, xmask)


@triton.jit
def triton_poi_fused_mul_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex // 4
    x4 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + 4 * x3, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 4 * x3), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + 4 * x3), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + 4 * x3), xmask, eviction_policy='evict_last')
    tmp11 = tl.load(in_ptr0 + x4, xmask)
    tmp13 = tl.load(in_ptr0 + (4 * x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr0 + (1 + 4 * x0 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp16 = tl.load(in_ptr0 + (2 + 4 * x0 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp18 = tl.load(in_ptr0 + (3 + 4 * x0 + 16 * x2), xmask,
        eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp6 = tmp4 + tmp5
    tmp7 = 1.0
    tmp8 = triton_helpers.maximum(tmp6, tmp7)
    tmp9 = -0.5
    tmp10 = libdevice.pow(tmp8, tmp9)
    tmp12 = tmp10 * tmp11
    tmp15 = tmp13 + tmp14
    tmp17 = tmp15 + tmp16
    tmp19 = tmp17 + tmp18
    tmp20 = triton_helpers.maximum(tmp19, tmp7)
    tmp21 = libdevice.pow(tmp20, tmp9)
    tmp22 = tmp12 * tmp21
    tl.store(out_ptr0 + x4, tmp22, xmask)


@triton.jit
def triton_poi_fused_clone_3(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 64
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x2, tmp0, xmask)


@triton.jit
def triton_poi_fused_add_4(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(in_out_ptr0 + x2, tmp2, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4), (16, 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), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_index_put_lift_fresh_0[grid(64)](primals_2, buf0, 
            64, XBLOCK=64, num_warps=1, num_stages=1)
        del primals_2
        triton_poi_fused_index_put_lift_fresh_1[grid(16)](buf0, 16, XBLOCK=
            16, num_warps=1, num_stages=1)
        buf2 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (64, 4), (4, 1), 0),
            primals_3, out=buf2)
        del primals_3
        buf3 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_mul_2[grid(64)](buf0, buf3, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf0
        buf4 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_clone_3[grid(256)](buf3, buf4, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del buf3
        buf5 = empty_strided_cuda((16, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf4, (16, 4, 4), (16, 4, 1),
            0), reinterpret_tensor(buf2, (16, 4, 4), (16, 4, 1), 0), out=buf5)
        del buf2
        buf6 = reinterpret_tensor(buf5, (4, 4, 4, 4), (64, 16, 4, 1), 0)
        del buf5
        triton_poi_fused_add_4[grid(256)](buf6, primals_4, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        del primals_4
    return buf6, reinterpret_tensor(buf4, (16, 4, 4), (16, 1, 4), 0
        ), reinterpret_tensor(primals_1, (4, 64), (1, 4), 0)


def glorot(tensor):
    if tensor is not None:
        stdv = math.sqrt(6.0 / (tensor.size(-2) + tensor.size(-1)))
        tensor.data.uniform_(-stdv, stdv)


def zeros(tensor):
    if tensor is not None:
        tensor.data.fill_(0)


class DenseGCNConvNew(torch.nn.Module):
    """See :class:`torch_geometric.nn.conv.GCNConv`.

    :rtype: :class:`Tensor`
    """

    def __init__(self, in_channels, out_channels, improved=False, bias=True):
        super(DenseGCNConvNew, self).__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.improved = improved
        self.weight = Parameter(torch.Tensor(self.in_channels, out_channels))
        if bias:
            self.bias = Parameter(torch.Tensor(out_channels))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        glorot(self.weight)
        zeros(self.bias)

    def __repr__(self):
        return '{}({}, {})'.format(self.__class__.__name__, self.
            in_channels, self.out_channels)

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


Measured latency_ms: 0.077621