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, math as tl_math
import torch.nn as nn
from torch.nn import functional as F
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, 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 % 16
    x2 = xindex // 64
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_poi_fused_clone_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_clone_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
    x0 = xindex % 16
    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_leaky_relu_3(in_ptr0, in_ptr1, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex // 4
    x0 = xindex % 4
    x2 = xindex // 16
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + x3, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tl.store(out_ptr0 + x4, tmp4, xmask)


@triton.jit
def triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_4(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
    x0 = xindex % 4
    x2 = xindex // 16
    x3 = xindex // 4
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr1 + (x0 + 16 * x3), xmask).to(tl.int1)
    tmp4 = tl.load(in_ptr2 + 4 * x3, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + x4, xmask)
    tmp12 = tl.load(in_ptr0 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp14 = tl.load(in_ptr1 + (4 + x0 + 16 * x3), xmask).to(tl.int1)
    tmp15 = tl.load(in_ptr2 + (1 + 4 * x3), xmask, eviction_policy='evict_last'
        )
    tmp21 = tl.load(in_ptr0 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp23 = tl.load(in_ptr1 + (8 + x0 + 16 * x3), xmask).to(tl.int1)
    tmp24 = tl.load(in_ptr2 + (2 + 4 * x3), xmask, eviction_policy='evict_last'
        )
    tmp30 = tl.load(in_ptr0 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp32 = tl.load(in_ptr1 + (12 + x0 + 16 * x3), xmask).to(tl.int1)
    tmp33 = tl.load(in_ptr2 + (3 + 4 * x3), xmask, eviction_policy='evict_last'
        )
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp6 = tmp4 + tmp5
    tmp7 = 4.0
    tmp8 = tmp6 * tmp7
    tmp9 = tl.where(tmp3, tmp6, tmp8)
    tmp10 = -8999999815811072.0
    tmp11 = tl.where(tmp2, tmp9, tmp10)
    tmp13 = tmp12 > tmp1
    tmp16 = tmp15 + tmp5
    tmp17 = tmp16 * tmp7
    tmp18 = tl.where(tmp14, tmp16, tmp17)
    tmp19 = tl.where(tmp13, tmp18, tmp10)
    tmp20 = triton_helpers.maximum(tmp11, tmp19)
    tmp22 = tmp21 > tmp1
    tmp25 = tmp24 + tmp5
    tmp26 = tmp25 * tmp7
    tmp27 = tl.where(tmp23, tmp25, tmp26)
    tmp28 = tl.where(tmp22, tmp27, tmp10)
    tmp29 = triton_helpers.maximum(tmp20, tmp28)
    tmp31 = tmp30 > tmp1
    tmp34 = tmp33 + tmp5
    tmp35 = tmp34 * tmp7
    tmp36 = tl.where(tmp32, tmp34, tmp35)
    tmp37 = tl.where(tmp31, tmp36, tmp10)
    tmp38 = triton_helpers.maximum(tmp29, tmp37)
    tl.store(out_ptr0 + x4, tmp38, xmask)


@triton.jit
def triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_5(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex // 64
    x4 = xindex % 16
    x5 = xindex
    x6 = xindex // 4
    x0 = xindex % 4
    x7 = xindex // 16
    tmp0 = tl.load(in_ptr0 + (x4 + 16 * x3), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr1 + x5, xmask).to(tl.int1)
    tmp4 = tl.load(in_ptr2 + x6, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + (x0 + 4 * x7), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr4 + (x0 + 4 * x7), xmask, eviction_policy=
        'evict_last')
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp6 = tmp4 + tmp5
    tmp7 = 4.0
    tmp8 = tmp6 * tmp7
    tmp9 = tl.where(tmp3, tmp6, tmp8)
    tmp10 = -8999999815811072.0
    tmp11 = tl.where(tmp2, tmp9, tmp10)
    tmp13 = tmp11 - tmp12
    tmp14 = tl_math.exp(tmp13)
    tl.store(out_ptr0 + x5, tmp14, xmask)


@triton.jit
def triton_poi_fused__softmax_6(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
    x3 = xindex
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp4 = tl.load(in_ptr0 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + x3, tmp8, xmask)


@triton.jit
def triton_poi_fused_elu_7(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 % 16
    x1 = xindex // 16 % 4
    x2 = xindex // 64
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + (4 * x1 + 16 * (x0 // 4) + 64 * x2 + x0 % 4),
        xmask)
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp3 = 1.0
    tmp4 = tmp0 * tmp3
    tmp5 = libdevice.expm1(tmp4)
    tmp6 = tmp5 * tmp3
    tmp7 = tl.where(tmp2, tmp4, tmp6)
    tl.store(out_ptr0 + x3, tmp7, xmask)


@triton.jit
def triton_poi_fused_add_leaky_relu_8(in_ptr0, in_ptr1, 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
    x0 = xindex % 4
    x2 = xindex // 16
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + x3, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp2 = tmp0 + tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tl.store(out_ptr0 + x4, tmp4, xmask)


@triton.jit
def triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_9(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, 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
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x1), xmask)
    tmp3 = tl.load(in_ptr1 + (x0 + 16 * x1), xmask).to(tl.int1)
    tmp4 = tl.load(in_ptr2 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + x2, xmask)
    tmp12 = tl.load(in_ptr0 + (4 + x0 + 16 * x1), xmask)
    tmp14 = tl.load(in_ptr1 + (4 + x0 + 16 * x1), xmask).to(tl.int1)
    tmp15 = tl.load(in_ptr2 + (1 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp21 = tl.load(in_ptr0 + (8 + x0 + 16 * x1), xmask)
    tmp23 = tl.load(in_ptr1 + (8 + x0 + 16 * x1), xmask).to(tl.int1)
    tmp24 = tl.load(in_ptr2 + (2 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp30 = tl.load(in_ptr0 + (12 + x0 + 16 * x1), xmask)
    tmp32 = tl.load(in_ptr1 + (12 + x0 + 16 * x1), xmask).to(tl.int1)
    tmp33 = tl.load(in_ptr2 + (3 + 4 * x1), xmask, eviction_policy='evict_last'
        )
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp6 = tmp4 + tmp5
    tmp7 = 4.0
    tmp8 = tmp6 * tmp7
    tmp9 = tl.where(tmp3, tmp6, tmp8)
    tmp10 = -8999999815811072.0
    tmp11 = tl.where(tmp2, tmp9, tmp10)
    tmp13 = tmp12 > tmp1
    tmp16 = tmp15 + tmp5
    tmp17 = tmp16 * tmp7
    tmp18 = tl.where(tmp14, tmp16, tmp17)
    tmp19 = tl.where(tmp13, tmp18, tmp10)
    tmp20 = triton_helpers.maximum(tmp11, tmp19)
    tmp22 = tmp21 > tmp1
    tmp25 = tmp24 + tmp5
    tmp26 = tmp25 * tmp7
    tmp27 = tl.where(tmp23, tmp25, tmp26)
    tmp28 = tl.where(tmp22, tmp27, tmp10)
    tmp29 = triton_helpers.maximum(tmp20, tmp28)
    tmp31 = tmp30 > tmp1
    tmp34 = tmp33 + tmp5
    tmp35 = tmp34 * tmp7
    tmp36 = tl.where(tmp32, tmp34, tmp35)
    tmp37 = tl.where(tmp31, tmp36, tmp10)
    tmp38 = triton_helpers.maximum(tmp29, tmp37)
    tl.store(out_ptr0 + x2, tmp38, xmask)


@triton.jit
def triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_10(in_ptr0,
    in_ptr1, in_ptr2, in_ptr3, in_ptr4, 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
    x4 = xindex // 4
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp3 = tl.load(in_ptr1 + x3, xmask).to(tl.int1)
    tmp4 = tl.load(in_ptr2 + x4, xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr3 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp12 = tl.load(in_ptr4 + (x0 + 4 * x2), xmask, eviction_policy=
        'evict_last')
    tmp1 = 0.0
    tmp2 = tmp0 > tmp1
    tmp6 = tmp4 + tmp5
    tmp7 = 4.0
    tmp8 = tmp6 * tmp7
    tmp9 = tl.where(tmp3, tmp6, tmp8)
    tmp10 = -8999999815811072.0
    tmp11 = tl.where(tmp2, tmp9, tmp10)
    tmp13 = tmp11 - tmp12
    tmp14 = tl_math.exp(tmp13)
    tl.store(out_ptr0 + x3, tmp14, xmask)


@triton.jit
def triton_poi_fused__softmax_11(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
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (4 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp4 = tl.load(in_ptr0 + (8 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (12 + x0 + 16 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp0 / tmp7
    tl.store(out_ptr0 + x3, tmp8, xmask)


@triton.jit
def triton_poi_fused__log_softmax_elu_mean_squeeze_12(in_ptr0, out_ptr0,
    out_ptr1, 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
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x1), xmask)
    tmp9 = tl.load(in_ptr0 + (4 + x0 + 16 * x1), xmask)
    tmp17 = tl.load(in_ptr0 + (8 + x0 + 16 * x1), xmask)
    tmp25 = tl.load(in_ptr0 + (12 + x0 + 16 * x1), xmask)
    tmp1 = 1.0
    tmp2 = tmp0 / tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = tmp2 * tmp1
    tmp6 = libdevice.expm1(tmp5)
    tmp7 = tmp6 * tmp1
    tmp8 = tl.where(tmp4, tmp5, tmp7)
    tmp10 = tmp9 / tmp1
    tmp11 = tmp10 > tmp3
    tmp12 = tmp10 * tmp1
    tmp13 = libdevice.expm1(tmp12)
    tmp14 = tmp13 * tmp1
    tmp15 = tl.where(tmp11, tmp12, tmp14)
    tmp16 = triton_helpers.maximum(tmp8, tmp15)
    tmp18 = tmp17 / tmp1
    tmp19 = tmp18 > tmp3
    tmp20 = tmp18 * tmp1
    tmp21 = libdevice.expm1(tmp20)
    tmp22 = tmp21 * tmp1
    tmp23 = tl.where(tmp19, tmp20, tmp22)
    tmp24 = triton_helpers.maximum(tmp16, tmp23)
    tmp26 = tmp25 / tmp1
    tmp27 = tmp26 > tmp3
    tmp28 = tmp26 * tmp1
    tmp29 = libdevice.expm1(tmp28)
    tmp30 = tmp29 * tmp1
    tmp31 = tl.where(tmp27, tmp28, tmp30)
    tmp32 = triton_helpers.maximum(tmp24, tmp31)
    tmp33 = tmp8 - tmp32
    tmp34 = tl_math.exp(tmp33)
    tmp35 = tmp15 - tmp32
    tmp36 = tl_math.exp(tmp35)
    tmp37 = tmp34 + tmp36
    tmp38 = tmp23 - tmp32
    tmp39 = tl_math.exp(tmp38)
    tmp40 = tmp37 + tmp39
    tmp41 = tmp31 - tmp32
    tmp42 = tl_math.exp(tmp41)
    tmp43 = tmp40 + tmp42
    tl.store(out_ptr0 + x2, tmp32, xmask)
    tl.store(out_ptr1 + x2, tmp43, xmask)


@triton.jit
def triton_poi_fused__log_softmax_elu_mean_squeeze_13(in_ptr0, in_ptr1,
    in_ptr2, 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
    x0 = xindex % 4
    x2 = xindex // 16
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp9 = tl.load(in_ptr1 + (x0 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp11 = tl.load(in_ptr2 + (x0 + 4 * x2), xmask, eviction_policy=
        'evict_last')
    tmp1 = 1.0
    tmp2 = tmp0 / tmp1
    tmp3 = 0.0
    tmp4 = tmp2 > tmp3
    tmp5 = tmp2 * tmp1
    tmp6 = libdevice.expm1(tmp5)
    tmp7 = tmp6 * tmp1
    tmp8 = tl.where(tmp4, tmp5, tmp7)
    tmp10 = tmp8 - tmp9
    tmp12 = tl_math.log(tmp11)
    tmp13 = tmp10 - tmp12
    tl.store(out_ptr0 + x3, tmp13, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_3, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_4, (4, 4, 1), (4, 1, 1))
    assert_size_stride(primals_5, (4, 4, 1), (4, 1, 1))
    assert_size_stride(primals_6, (1, 16, 4), (64, 4, 1))
    assert_size_stride(primals_7, (1, 4, 1), (4, 1, 1))
    assert_size_stride(primals_8, (1, 4, 1), (4, 1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_clone_0[grid(256)](primals_1, buf0, 256, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_clone_1[grid(256)](primals_3, buf1, 256, XBLOCK=
            256, num_warps=4, num_stages=1)
        del primals_3
        buf2 = empty_strided_cuda((16, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (16, 4, 4), (16, 4, 1),
            0), reinterpret_tensor(buf1, (16, 4, 4), (16, 4, 1), 0), out=buf2)
        buf3 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 1), torch.float32)
        triton_poi_fused_clone_2[grid(64)](primals_4, buf3, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del primals_4
        buf4 = empty_strided_cuda((16, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(buf2, reinterpret_tensor(buf3, (16, 4, 1), (4, 1,
            0), 0), out=buf4)
        buf5 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 1), torch.float32)
        triton_poi_fused_clone_2[grid(64)](primals_5, buf5, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del primals_5
        buf6 = empty_strided_cuda((16, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(buf2, reinterpret_tensor(buf5, (16, 4, 1), (4, 1,
            0), 0), out=buf6)
        buf7 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        triton_poi_fused_add_leaky_relu_3[grid(256)](buf4, buf6, buf7, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf8 = empty_strided_cuda((4, 4, 1, 4), (16, 4, 64, 1), torch.float32)
        triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_4[grid(64)](
            primals_2, buf7, buf4, buf6, buf8, 64, XBLOCK=64, num_warps=1,
            num_stages=1)
        buf9 = buf1
        del buf1
        triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_5[grid(256)](
            primals_2, buf7, buf4, buf6, buf8, buf9, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf10 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused__softmax_6[grid(256)](buf9, buf10, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf11 = reinterpret_tensor(buf9, (16, 4, 4), (16, 4, 1), 0)
        del buf9
        extern_kernels.bmm(reinterpret_tensor(buf10, (16, 4, 4), (16, 4, 1),
            0), buf2, out=buf11)
        buf12 = empty_strided_cuda((4, 4, 16), (64, 16, 1), torch.float32)
        triton_poi_fused_elu_7[grid(256)](buf11, buf12, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
        buf13 = reinterpret_tensor(buf8, (4, 4, 4), (16, 4, 1), 0)
        del buf8
        extern_kernels.bmm(buf12, reinterpret_tensor(primals_6, (4, 16, 4),
            (0, 4, 1), 0), out=buf13)
        buf14 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(buf13, reinterpret_tensor(primals_7, (4, 4, 1),
            (0, 1, 0), 0), out=buf14)
        buf15 = empty_strided_cuda((4, 4, 1), (4, 1, 1), torch.float32)
        extern_kernels.bmm(buf13, reinterpret_tensor(primals_8, (4, 4, 1),
            (0, 1, 0), 0), out=buf15)
        buf16 = empty_strided_cuda((4, 1, 4, 4), (16, 16, 4, 1), torch.bool)
        triton_poi_fused_add_leaky_relu_8[grid(64)](buf14, buf15, buf16, 64,
            XBLOCK=64, num_warps=1, num_stages=1)
        buf17 = empty_strided_cuda((4, 1, 1, 4), (4, 16, 16, 1), torch.float32)
        triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_9[grid(16)](
            primals_2, buf16, buf14, buf15, buf17, 16, XBLOCK=16, num_warps
            =1, num_stages=1)
        buf18 = reinterpret_tensor(buf6, (4, 1, 4, 4), (16, 64, 4, 1), 0)
        del buf6
        triton_poi_fused__softmax_add_gt_leaky_relu_mul_where_10[grid(64)](
            primals_2, buf16, buf14, buf15, buf17, buf18, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del buf14
        buf19 = reinterpret_tensor(buf4, (4, 1, 4, 4), (16, 16, 4, 1), 0)
        del buf4
        triton_poi_fused__softmax_11[grid(64)](buf18, buf19, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        buf20 = reinterpret_tensor(buf18, (4, 4, 4), (16, 4, 1), 0)
        del buf18
        extern_kernels.bmm(reinterpret_tensor(buf19, (4, 4, 4), (16, 4, 1),
            0), buf13, out=buf20)
        buf21 = reinterpret_tensor(buf17, (4, 1, 4), (4, 16, 1), 0)
        del buf17
        buf22 = reinterpret_tensor(buf15, (4, 1, 4), (4, 16, 1), 0)
        del buf15
        triton_poi_fused__log_softmax_elu_mean_squeeze_12[grid(16)](buf20,
            buf21, buf22, 16, XBLOCK=16, num_warps=1, num_stages=1)
        buf23 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused__log_softmax_elu_mean_squeeze_13[grid(64)](buf20,
            buf21, buf22, buf23, 64, XBLOCK=64, num_warps=1, num_stages=1)
        del buf21
        del buf22
    return (buf23, primals_2, primals_6, primals_7, primals_8, buf7, buf10,
        buf11, buf16, buf19, buf20, buf23, reinterpret_tensor(buf13, (4, 4,
        4), (16, 1, 4), 0), reinterpret_tensor(buf12, (4, 16, 4), (64, 1, 
        16), 0), reinterpret_tensor(buf2, (16, 4, 4), (16, 1, 4), 0),
        reinterpret_tensor(buf5, (16, 1, 4), (4, 1, 1), 0),
        reinterpret_tensor(buf3, (16, 1, 4), (4, 1, 1), 0),
        reinterpret_tensor(buf0, (16, 4, 4), (16, 1, 4), 0))


class GATMutiHeadAttLayer(nn.Module):

    def __init__(self, in_features, out_features, heads, dropout=0.4, alpha
        =0.2, concat=True):
        super(GATMutiHeadAttLayer, self).__init__()
        self.dropout = dropout
        self.in_features = in_features
        self.out_features = out_features
        self.heads = heads
        self.alpha = alpha
        self.concat = concat
        self.gain = nn.init.calculate_gain('leaky_relu', self.alpha)
        self.leakyrelu = nn.LeakyReLU(self.alpha)
        self.W = nn.Parameter(torch.zeros(size=(heads, in_features,
            out_features)))
        nn.init.xavier_uniform_(self.W.data, self.gain)
        self.a_1 = nn.Parameter(torch.zeros(size=(heads, out_features, 1)))
        nn.init.xavier_uniform_(self.a_1.data, self.gain)
        self.a_2 = nn.Parameter(torch.zeros(size=(heads, out_features, 1)))
        nn.init.xavier_uniform_(self.a_2.data, self.gain)

    def forward(self, input_seq, adj):
        if len(input_seq.size()) == 2:
            input_seq = torch.unsqueeze(input_seq, 0)
            adj = torch.unsqueeze(adj, 0)
        input_seq = torch.unsqueeze(input_seq, 1)
        adj = torch.unsqueeze(adj, 1)
        in_size = input_seq.size()
        nbatchs = in_size[0]
        slen = in_size[2]
        h = torch.matmul(input_seq, self.W)
        f_1 = torch.matmul(h, self.a_1)
        f_2 = torch.matmul(h, self.a_2)
        e = f_1.expand(nbatchs, self.heads, slen, slen) + f_2.expand(nbatchs,
            self.heads, slen, slen).transpose(2, 3)
        e = self.leakyrelu(e)
        zero_vec = -9000000000000000.0 * torch.ones_like(e)
        attention = torch.where(adj.expand(nbatchs, self.heads, slen, slen) >
            0, e, zero_vec)
        attention = F.softmax(attention, dim=2)
        attention = F.dropout(attention, self.dropout, training=self.training)
        node_out = torch.matmul(attention, h)
        if self.concat:
            node_out = node_out.transpose(1, 2).contiguous().view(nbatchs,
                slen, -1)
            node_out = F.elu(node_out)
        else:
            node_out = node_out.mean(1)
        return node_out.squeeze()


class GATNew(nn.Module):

    def __init__(self, nfeat, nhid, nclass, dropout, alpha, nheads):
        """Dense version of GAT."""
        super(GATNew, self).__init__()
        self.dropout = dropout
        self.MHAlayer1 = GATMutiHeadAttLayer(nfeat, nhid, nheads, dropout,
            alpha)
        self.out_att = GATMutiHeadAttLayer(nhid * nheads, nclass, 1,
            dropout, alpha, concat=False)

    def forward(self, input_0, input_1):
        primals_1 = self.MHAlayer1.W
        primals_4 = self.MHAlayer1.a_1
        primals_5 = self.MHAlayer1.a_2
        primals_6 = self.out_att.W
        primals_7 = self.out_att.a_1
        primals_8 = self.out_att.a_2
        primals_2 = input_0
        primals_3 = input_1
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8])
        return output[0]


Measured latency_ms: 0.291335