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
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_bmm_repeat_0(in_ptr0, 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
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_repeat_1(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_repeat_2(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 512
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 128
    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_repeat_3(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 128
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 32
    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_bmm_4(in_ptr0, 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
    tmp0 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_bmm_5(in_ptr0, 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
    tmp0 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_bmm_6(in_ptr0, 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
    tmp0 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x0, tmp0, xmask)


@triton.jit
def triton_poi_fused_cat_7(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 4
    x0 = xindex % 4
    x2 = xindex // 16
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 1, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4 * x2), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 2, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (x0 + 4 * x2), tmp9 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 3, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (x0 + 4 * x2), tmp14 & xmask, eviction_policy
        ='evict_last', other=0.0)
    tmp16 = tmp0 >= tmp12
    tl.full([1], 4, tl.int64)
    tmp19 = tl.load(in_ptr3 + (x0 + 4 * x2), tmp16 & xmask, eviction_policy
        ='evict_last', other=0.0)
    tmp20 = tl.where(tmp14, tmp15, tmp19)
    tmp21 = tl.where(tmp9, tmp10, tmp20)
    tmp22 = tl.where(tmp4, tmp5, tmp21)
    tl.store(out_ptr0 + x3, tmp22, 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, (4, 16), (16, 1))
    assert_size_stride(primals_3, (16, 8), (8, 1))
    assert_size_stride(primals_4, (8, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 1, 4), (4, 16, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_bmm_repeat_0[grid(16)](primals_1, buf0, 16, XBLOCK
            =16, num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        triton_poi_fused_repeat_1[grid(256)](primals_2, buf1, 256, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_2
        buf2 = empty_strided_cuda((4, 1, 16), (16, 16, 1), torch.float32)
        extern_kernels.bmm(buf0, buf1, out=buf2)
        buf3 = empty_strided_cuda((4, 16, 8), (128, 8, 1), torch.float32)
        triton_poi_fused_repeat_2[grid(512)](primals_3, buf3, 512, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_3
        buf4 = empty_strided_cuda((4, 1, 8), (8, 8, 1), torch.float32)
        extern_kernels.bmm(buf2, buf3, out=buf4)
        buf5 = empty_strided_cuda((4, 8, 4), (32, 4, 1), torch.float32)
        triton_poi_fused_repeat_3[grid(128)](primals_4, buf5, 128, XBLOCK=
            128, num_warps=4, num_stages=1)
        del primals_4
        buf6 = reinterpret_tensor(buf0, (4, 1, 4), (4, 4, 1), 0)
        del buf0
        extern_kernels.bmm(buf4, buf5, out=buf6)
        buf7 = empty_strided_cuda((4, 1, 4), (4, 16, 1), torch.float32)
        triton_poi_fused_bmm_4[grid(16)](primals_1, buf7, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf8 = empty_strided_cuda((4, 1, 16), (16, 16, 1), torch.float32)
        extern_kernels.bmm(buf7, buf1, out=buf8)
        buf9 = empty_strided_cuda((4, 1, 8), (8, 8, 1), torch.float32)
        extern_kernels.bmm(buf8, buf3, out=buf9)
        buf10 = reinterpret_tensor(buf7, (4, 1, 4), (4, 4, 1), 0)
        del buf7
        extern_kernels.bmm(buf9, buf5, out=buf10)
        buf11 = empty_strided_cuda((4, 1, 4), (4, 16, 1), torch.float32)
        triton_poi_fused_bmm_5[grid(16)](primals_1, buf11, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf12 = empty_strided_cuda((4, 1, 16), (16, 16, 1), torch.float32)
        extern_kernels.bmm(buf11, buf1, out=buf12)
        buf13 = empty_strided_cuda((4, 1, 8), (8, 8, 1), torch.float32)
        extern_kernels.bmm(buf12, buf3, out=buf13)
        buf14 = reinterpret_tensor(buf11, (4, 1, 4), (4, 4, 1), 0)
        del buf11
        extern_kernels.bmm(buf13, buf5, out=buf14)
        buf15 = empty_strided_cuda((4, 1, 4), (4, 16, 1), torch.float32)
        triton_poi_fused_bmm_6[grid(16)](primals_1, buf15, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf16 = empty_strided_cuda((4, 1, 16), (16, 16, 1), torch.float32)
        extern_kernels.bmm(buf15, buf1, out=buf16)
        del buf1
        buf17 = empty_strided_cuda((4, 1, 8), (8, 8, 1), torch.float32)
        extern_kernels.bmm(buf16, buf3, out=buf17)
        buf18 = reinterpret_tensor(buf15, (4, 1, 4), (4, 4, 1), 0)
        del buf15
        extern_kernels.bmm(buf17, buf5, out=buf18)
        buf19 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_cat_7[grid(64)](buf6, buf10, buf14, buf18, buf19, 
            64, XBLOCK=64, num_warps=1, num_stages=1)
        del buf10
        del buf14
        del buf18
        del buf6
    return buf19, reinterpret_tensor(buf17, (4, 8, 1), (8, 1, 8), 0
        ), reinterpret_tensor(buf5, (4, 4, 8), (32, 1, 4), 0
        ), reinterpret_tensor(buf16, (4, 16, 1), (16, 1, 16), 0
        ), reinterpret_tensor(buf3, (4, 8, 16), (128, 1, 8), 0
        ), reinterpret_tensor(primals_1, (4, 4, 1), (16, 4, 16), 3
        ), reinterpret_tensor(buf13, (4, 8, 1), (8, 1, 8), 0
        ), reinterpret_tensor(buf12, (4, 16, 1), (16, 1, 16), 0
        ), reinterpret_tensor(primals_1, (4, 4, 1), (16, 4, 16), 2
        ), reinterpret_tensor(buf9, (4, 8, 1), (8, 1, 8), 0
        ), reinterpret_tensor(buf8, (4, 16, 1), (16, 1, 16), 0
        ), reinterpret_tensor(primals_1, (4, 4, 1), (16, 4, 16), 1
        ), reinterpret_tensor(buf4, (4, 8, 1), (8, 1, 8), 0
        ), reinterpret_tensor(buf2, (4, 16, 1), (16, 1, 16), 0
        ), reinterpret_tensor(primals_1, (4, 4, 1), (16, 4, 16), 0)


class GraphEmbeddingNew(nn.Module):

    def __init__(self, input_size, ebd_size, use_cuda=True, use_sdne=True,
        add_noise=False, is_training=True):
        super(GraphEmbeddingNew, self).__init__()
        self.use_cuda = use_cuda
        self.use_sdne = use_sdne
        self.add_noise = add_noise
        self.is_training = is_training
        ebd_size_1 = ebd_size * 4 if use_sdne else ebd_size
        ebd_size_2 = ebd_size * 2
        ebd_size_3 = ebd_size
        self.embedding_1 = nn.Parameter(torch.FloatTensor(input_size,
            ebd_size_1))
        if self.use_sdne:
            self.embedding_2 = nn.Parameter(torch.FloatTensor(ebd_size_1,
                ebd_size_2))
            self.embedding_3 = nn.Parameter(torch.FloatTensor(ebd_size_2,
                ebd_size_3))
        self.embedding_1.data.uniform_(-(1.0 / math.sqrt(ebd_size_1)), 1.0 /
            math.sqrt(ebd_size_1))
        if self.use_sdne:
            self.embedding_2.data.uniform_(-(1.0 / math.sqrt(ebd_size_2)), 
                1.0 / math.sqrt(ebd_size_2))
            self.embedding_3.data.uniform_(-(1.0 / math.sqrt(ebd_size_3)), 
                1.0 / math.sqrt(ebd_size_3))

    def forward(self, input_0):
        primals_2 = self.embedding_1
        primals_3 = self.embedding_2
        primals_4 = self.embedding_3
        primals_1 = input_0
        output = call([primals_1, primals_2, primals_3, primals_4])
        return output[0]


Measured latency_ms: 0.180862