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
import torch.nn as nn
import torch.nn.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_stack_0(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 80
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4 * x1), tmp4 & xmask, other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 8, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (x0 + 4 * (-4 + x1)), tmp9 & xmask, other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 12, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (x0 + 4 * (-8 + x1)), tmp14 & xmask, other=0.0)
    tmp16 = tmp0 >= tmp12
    tmp17 = tl.full([1], 16, tl.int64)
    tmp18 = tmp0 < tmp17
    tmp19 = tmp16 & tmp18
    tmp20 = tl.load(in_ptr2 + (x0 + 4 * (-12 + x1)), tmp19 & xmask, other=0.0)
    tmp21 = tmp0 >= tmp17
    tl.full([1], 20, tl.int64)
    tmp24 = tl.load(in_ptr1 + (x0 + 4 * (-16 + x1)), tmp21 & xmask, other=0.0)
    tmp25 = tl.where(tmp19, tmp20, tmp24)
    tmp26 = tl.where(tmp14, tmp15, tmp25)
    tmp27 = tl.where(tmp9, tmp10, tmp26)
    tmp28 = tl.where(tmp4, tmp5, tmp27)
    tl.store(out_ptr0 + x2, tmp28, xmask)


@triton.jit
def triton_poi_fused_stack_1(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 80
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4
    x0 = xindex % 4
    x2 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4 * x1), tmp4 & xmask, other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 8, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (x0 + 4 * (-4 + x1)), tmp9 & xmask, other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 12, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (x0 + 4 * (-8 + x1)), tmp14 & xmask, other=0.0)
    tmp16 = tmp0 >= tmp12
    tmp17 = tl.full([1], 16, tl.int64)
    tmp18 = tmp0 < tmp17
    tmp19 = tmp16 & tmp18
    tmp20 = tl.load(in_ptr3 + (x0 + 4 * (-12 + x1)), tmp19 & xmask, other=0.0)
    tmp21 = tmp0 >= tmp17
    tl.full([1], 20, tl.int64)
    tmp24 = tl.load(in_ptr4 + (x0 + 4 * (-16 + x1)), tmp21 & xmask, other=0.0)
    tmp25 = tl.where(tmp19, tmp20, tmp24)
    tmp26 = tl.where(tmp14, tmp15, tmp25)
    tmp27 = tl.where(tmp9, tmp10, tmp26)
    tmp28 = tl.where(tmp4, tmp5, tmp27)
    tl.store(out_ptr0 + x2, tmp28, xmask)


@triton.jit
def triton_poi_fused_stack_2(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 20
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + x0, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp6 = tmp0 >= tmp3
    tmp7 = tl.full([1], 8, tl.int64)
    tmp8 = tmp0 < tmp7
    tmp9 = tmp6 & tmp8
    tmp10 = tl.load(in_ptr1 + (-4 + x0), tmp9 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp11 = tmp0 >= tmp7
    tmp12 = tl.full([1], 12, tl.int64)
    tmp13 = tmp0 < tmp12
    tmp14 = tmp11 & tmp13
    tmp15 = tl.load(in_ptr2 + (-8 + x0), tmp14 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp16 = tmp0 >= tmp12
    tmp17 = tl.full([1], 16, tl.int64)
    tmp18 = tmp0 < tmp17
    tmp19 = tmp16 & tmp18
    tmp20 = tl.load(in_ptr3 + (-12 + x0), tmp19 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp21 = tmp0 >= tmp17
    tl.full([1], 20, tl.int64)
    tmp24 = tl.load(in_ptr4 + (-16 + x0), tmp21 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp25 = tl.where(tmp19, tmp20, tmp24)
    tmp26 = tl.where(tmp14, tmp15, tmp25)
    tmp27 = tl.where(tmp9, tmp10, tmp26)
    tmp28 = tl.where(tmp4, tmp5, tmp27)
    tl.store(out_ptr0 + x0, tmp28, xmask)


@triton.jit
def triton_poi_fused_zeros_3(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 = 0.0
    tl.store(out_ptr0 + x0, tmp0, xmask)


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


@triton.jit
def triton_poi_fused_add_mul_relu_threshold_backward_5(in_ptr0, in_ptr1,
    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
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask)
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.5
    tmp6 = tmp4 * tmp5
    tmp7 = 0.0
    tmp8 = tmp4 <= tmp7
    tl.store(out_ptr0 + x0, tmp6, xmask)
    tl.store(out_ptr1 + x0, tmp8, xmask)


@triton.jit
def triton_poi_fused_add_mul_relu_threshold_backward_6(in_ptr0, in_ptr1,
    in_ptr2, 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
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask)
    tmp3 = tl.load(in_ptr2 + x0, xmask)
    tmp2 = tmp0 + tmp1
    tmp4 = tmp2 + tmp3
    tmp5 = tl.full([1], 0, tl.int32)
    tmp6 = triton_helpers.maximum(tmp5, tmp4)
    tmp7 = 0.3333333333333333
    tmp8 = tmp6 * tmp7
    tmp9 = 0.0
    tmp10 = tmp6 <= tmp9
    tl.store(out_ptr0 + x0, tmp8, xmask)
    tl.store(out_ptr1 + x0, tmp10, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21, primals_22,
        primals_23, primals_24) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4,), (1,))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (4, 4), (4, 1))
    assert_size_stride(primals_5, (4, 4), (4, 1))
    assert_size_stride(primals_6, (4,), (1,))
    assert_size_stride(primals_7, (4, 4), (4, 1))
    assert_size_stride(primals_8, (4, 4), (4, 1))
    assert_size_stride(primals_9, (4,), (1,))
    assert_size_stride(primals_10, (4, 4), (4, 1))
    assert_size_stride(primals_11, (4, 4), (4, 1))
    assert_size_stride(primals_12, (4, 4), (4, 1))
    assert_size_stride(primals_13, (4,), (1,))
    assert_size_stride(primals_14, (4, 4), (4, 1))
    assert_size_stride(primals_15, (4, 4), (4, 1))
    assert_size_stride(primals_16, (4,), (1,))
    assert_size_stride(primals_17, (4, 4), (4, 1))
    assert_size_stride(primals_18, (4, 4), (4, 1))
    assert_size_stride(primals_19, (4,), (1,))
    assert_size_stride(primals_20, (4, 4), (4, 1))
    assert_size_stride(primals_21, (4, 4), (4, 1))
    assert_size_stride(primals_22, (4, 4), (4, 1))
    assert_size_stride(primals_23, (4,), (1,))
    assert_size_stride(primals_24, (4, 4), (4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((20, 4), (4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_stack_0[grid(80)](primals_3, primals_10,
            primals_20, buf0, 80, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_20
        buf1 = empty_strided_cuda((20, 4), (4, 1), torch.float32)
        triton_poi_fused_stack_1[grid(80)](primals_1, primals_8, primals_22,
            primals_18, primals_15, buf1, 80, XBLOCK=128, num_warps=4,
            num_stages=1)
        del primals_1
        del primals_15
        del primals_18
        del primals_22
        del primals_8
        buf2 = empty_strided_cuda((20,), (1,), torch.float32)
        triton_poi_fused_stack_2[grid(20)](primals_2, primals_9, primals_23,
            primals_19, primals_16, buf2, 20, XBLOCK=32, num_warps=1,
            num_stages=1)
        del primals_16
        del primals_19
        del primals_2
        del primals_23
        del primals_9
        buf3 = empty_strided_cuda((5, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf0, (5, 4, 4), (16, 4, 1), 
            0), reinterpret_tensor(buf1, (5, 4, 4), (16, 1, 4), 0), out=buf3)
        del buf1
        buf4 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        triton_poi_fused_zeros_3[grid(16)](buf4, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        buf5 = buf3
        del buf3
        triton_poi_fused_baddbmm_4[grid(80)](buf5, buf2, 80, XBLOCK=128,
            num_warps=4, num_stages=1)
        del buf2
        buf6 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(buf4,
            (4, 4), (1, 4), 0), reinterpret_tensor(buf5, (4, 4), (1, 4), 0),
            reinterpret_tensor(primals_4, (4, 4), (1, 4), 0), beta=0)
        buf7 = buf6
        del buf6
        buf8 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_6, primals_3, reinterpret_tensor(
            primals_5, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf8)
        del primals_5
        del primals_6
        buf9 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(buf4,
            (4, 4), (1, 4), 0), reinterpret_tensor(buf8, (4, 4), (1, 4), 0),
            reinterpret_tensor(primals_7, (4, 4), (1, 4), 0), beta=0)
        buf10 = buf9
        del buf9
        buf11 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(
            buf4, (4, 4), (1, 4), 0), reinterpret_tensor(buf5, (4, 4), (1, 
            4), 16), reinterpret_tensor(primals_11, (4, 4), (1, 4), 0), beta=0)
        buf12 = buf11
        del buf11
        buf13 = buf8
        del buf8
        extern_kernels.addmm(primals_13, primals_10, reinterpret_tensor(
            primals_12, (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf13)
        del primals_12
        del primals_13
        buf14 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(
            buf4, (4, 4), (1, 4), 0), reinterpret_tensor(buf13, (4, 4), (1,
            4), 0), reinterpret_tensor(primals_14, (4, 4), (1, 4), 0), beta=0)
        del buf13
        buf15 = buf14
        del buf14
        buf16 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(
            buf4, (4, 4), (1, 4), 0), reinterpret_tensor(buf5, (4, 4), (1, 
            4), 64), reinterpret_tensor(primals_17, (4, 4), (1, 4), 0), beta=0)
        buf17 = buf16
        del buf16
        buf18 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(
            buf4, (4, 4), (1, 4), 0), reinterpret_tensor(buf5, (4, 4), (1, 
            4), 48), reinterpret_tensor(primals_21, (4, 4), (1, 4), 0), beta=0)
        buf19 = buf18
        del buf18
        buf20 = torch.ops.aten._sparse_addmm.default(reinterpret_tensor(
            buf4, (4, 4), (1, 4), 0), reinterpret_tensor(buf5, (4, 4), (1, 
            4), 32), reinterpret_tensor(primals_24, (4, 4), (1, 4), 0), beta=0)
        del buf5
        buf21 = buf20
        del buf20
        buf22 = reinterpret_tensor(buf4, (4, 4), (1, 4), 0)
        del buf4
        buf27 = empty_strided_cuda((4, 4), (1, 4), torch.bool)
        triton_poi_fused_add_mul_relu_threshold_backward_5[grid(16)](buf7,
            buf12, buf22, buf27, 16, XBLOCK=16, num_warps=1, num_stages=1)
        del buf12
        buf23 = reinterpret_tensor(buf7, (4, 4), (1, 4), 0)
        del buf7
        buf26 = empty_strided_cuda((4, 4), (1, 4), torch.bool)
        triton_poi_fused_add_mul_relu_threshold_backward_6[grid(16)](buf15,
            buf10, buf21, buf23, buf26, 16, XBLOCK=16, num_warps=1,
            num_stages=1)
        del buf10
        del buf15
        buf24 = reinterpret_tensor(buf21, (4, 4), (1, 4), 0)
        del buf21
        buf25 = empty_strided_cuda((4, 4), (1, 4), torch.bool)
        triton_poi_fused_add_mul_relu_threshold_backward_5[grid(16)](buf19,
            buf17, buf24, buf25, 16, XBLOCK=16, num_warps=1, num_stages=1)
        del buf17
        del buf19
    return (buf22, buf23, buf24, primals_3, primals_10, buf25, buf26, buf27,
        primals_24, primals_21, primals_17, primals_14, primals_11,
        primals_7, primals_4, reinterpret_tensor(buf0, (5, 4, 4), (16, 1, 4
        ), 0))


class SCConv_LayerNew(nn.Module):

    def __init__(self, num_node_feats, num_edge_feats, num_triangle_feats,
        output_size, bias=True, f=F.relu):
        super().__init__()
        self.n2n_weights = nn.Linear(num_node_feats, output_size, bias=bias)
        self.n2e_weights = nn.Linear(num_node_feats, output_size, bias=bias)
        self.e2e_weights = nn.Linear(num_edge_feats, output_size, bias=bias)
        self.e2n_weights = nn.Linear(num_edge_feats, output_size, bias=bias)
        self.e2t_weights = nn.Linear(num_edge_feats, output_size, bias=bias)
        self.t2e_weights = nn.Linear(num_triangle_feats, output_size, bias=bias
            )
        self.t2t_weights = nn.Linear(num_triangle_feats, output_size, bias=bias
            )
        self.w = f

    def forward(self, input_0, input_1, input_2, input_3, input_4, input_5,
        input_6, input_7, input_8, input_9):
        primals_1 = self.n2n_weights.weight
        primals_2 = self.n2n_weights.bias
        primals_3 = self.n2e_weights.weight
        primals_6 = self.n2e_weights.bias
        primals_4 = self.e2e_weights.weight
        primals_9 = self.e2e_weights.bias
        primals_5 = self.e2n_weights.weight
        primals_13 = self.e2n_weights.bias
        primals_7 = self.e2t_weights.weight
        primals_16 = self.e2t_weights.bias
        primals_8 = self.t2e_weights.weight
        primals_19 = self.t2e_weights.bias
        primals_10 = self.t2t_weights.weight
        primals_23 = self.t2t_weights.bias
        primals_11 = input_0
        primals_12 = input_1
        primals_14 = input_2
        primals_15 = input_3
        primals_17 = input_4
        primals_18 = input_5
        primals_20 = input_6
        primals_21 = input_7
        primals_22 = input_8
        primals_24 = input_9
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21, primals_22, primals_23, primals_24])
        return output[0], output[1], output[2]


Measured latency_ms: 0.035317