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
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_convolution_0(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 4 * x2 + 64 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_1(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (16 + y0 + 4 * x2 + 64 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_convolution_2(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (32 + y0 + 4 * x2 + 64 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_cat_3(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 48
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 12
    x1 = xindex // 12
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 8, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.full([1], 4, tl.int64)
    tmp6 = tmp0 < tmp5
    tmp7 = tmp6 & tmp4
    tmp8 = tl.load(in_ptr0 + (4 * x1 + x0), tmp7 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp9 = tl.load(in_ptr1 + x0, tmp7 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp10 = tmp8 + tmp9
    tmp11 = tl.full([1], 0, tl.int32)
    tmp12 = triton_helpers.maximum(tmp11, tmp10)
    tmp13 = tl.full(tmp12.shape, 0.0, tmp12.dtype)
    tmp14 = tl.where(tmp7, tmp12, tmp13)
    tmp15 = tmp0 >= tmp5
    tmp16 = tmp15 & tmp4
    tmp17 = tl.load(in_ptr2 + (4 * x1 + (-4 + x0)), tmp16 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp18 = tl.load(in_ptr1 + (-4 + x0), tmp16 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp19 = tmp17 + tmp18
    tmp20 = triton_helpers.maximum(tmp11, tmp19)
    tmp21 = tl.full(tmp20.shape, 0.0, tmp20.dtype)
    tmp22 = tl.where(tmp16, tmp20, tmp21)
    tmp23 = tl.where(tmp6, tmp14, tmp22)
    tmp24 = tl.full(tmp23.shape, 0.0, tmp23.dtype)
    tmp25 = tl.where(tmp4, tmp23, tmp24)
    tmp26 = tmp0 >= tmp3
    tl.full([1], 12, tl.int64)
    tmp29 = tl.load(in_ptr3 + (4 * x1 + (-8 + x0)), tmp26 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp30 = tl.load(in_ptr1 + (-8 + x0), tmp26 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp31 = tmp29 + tmp30
    tmp32 = triton_helpers.maximum(tmp11, tmp31)
    tmp33 = tl.full(tmp32.shape, 0.0, tmp32.dtype)
    tmp34 = tl.where(tmp26, tmp32, tmp33)
    tmp35 = tl.where(tmp4, tmp25, tmp34)
    tl.store(out_ptr0 + (x0 + 16 * x1), tmp35, xmask)


@triton.jit
def triton_poi_fused_convolution_4(in_ptr0, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    ynumel = 16
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x2 = xindex
    y0 = yindex % 4
    y1 = yindex // 4
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (48 + y0 + 4 * x2 + 64 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 4 * y3), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_relu_threshold_backward_5(in_ptr0, in_ptr1, in_ptr2,
    in_ptr3, in_ptr4, out_ptr0, out_ptr1, out_ptr2, out_ptr3, out_ptr4,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 4
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr2 + x2, xmask)
    tmp11 = tl.load(in_ptr3 + x2, xmask)
    tmp15 = tl.load(in_ptr4 + x2, xmask)
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tmp8 = tmp7 + tmp1
    tmp9 = triton_helpers.maximum(tmp3, tmp8)
    tmp10 = tmp9 <= tmp5
    tmp12 = tmp11 + tmp1
    tmp13 = triton_helpers.maximum(tmp3, tmp12)
    tmp14 = tmp13 <= tmp5
    tmp16 = tmp15 + tmp1
    tmp17 = triton_helpers.maximum(tmp3, tmp16)
    tmp18 = tmp17 <= tmp5
    tl.store(out_ptr0 + (x0 + 16 * x1), tmp4, xmask)
    tl.store(out_ptr1 + x2, tmp6, xmask)
    tl.store(out_ptr2 + x2, tmp10, xmask)
    tl.store(out_ptr3 + x2, tmp14, xmask)
    tl.store(out_ptr4 + x2, tmp18, xmask)


@triton.jit
def triton_poi_fused_max_6(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)
    tmp1 = tl.load(in_ptr0 + (4 + x0 + 16 * x1), xmask)
    tmp3 = tl.load(in_ptr0 + (8 + x0 + 16 * x1), xmask)
    tmp5 = tl.load(in_ptr0 + (12 + x0 + 16 * x1), xmask)
    tmp2 = triton_helpers.maximum(tmp0, tmp1)
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp7 = tmp0 > tmp1
    tmp8 = tmp0 == tmp1
    tmp9 = tmp0 != tmp0
    tmp10 = tmp1 != tmp1
    tmp11 = tmp9 > tmp10
    tmp12 = tmp7 | tmp11
    tmp13 = tmp9 & tmp10
    tmp14 = tmp8 | tmp13
    tmp15 = tl.full([1], 0, tl.int64)
    tmp16 = tl.full([1], 1, tl.int64)
    tmp17 = tmp15 < tmp16
    tmp18 = tmp14 & tmp17
    tmp19 = tmp12 | tmp18
    tmp20 = tl.where(tmp19, tmp0, tmp1)
    tmp21 = tl.where(tmp19, tmp15, tmp16)
    tmp22 = tmp20 > tmp3
    tmp23 = tmp20 == tmp3
    tmp24 = tmp20 != tmp20
    tmp25 = tmp3 != tmp3
    tmp26 = tmp24 > tmp25
    tmp27 = tmp22 | tmp26
    tmp28 = tmp24 & tmp25
    tmp29 = tmp23 | tmp28
    tmp30 = tl.full([1], 2, tl.int64)
    tmp31 = tmp21 < tmp30
    tmp32 = tmp29 & tmp31
    tmp33 = tmp27 | tmp32
    tmp34 = tl.where(tmp33, tmp20, tmp3)
    tmp35 = tl.where(tmp33, tmp21, tmp30)
    tmp36 = tmp34 > tmp5
    tmp37 = tmp34 == tmp5
    tmp38 = tmp34 != tmp34
    tmp39 = tmp5 != tmp5
    tmp40 = tmp38 > tmp39
    tmp41 = tmp36 | tmp40
    tmp42 = tmp38 & tmp39
    tmp43 = tmp37 | tmp42
    tmp44 = tl.full([1], 3, tl.int64)
    tmp45 = tmp35 < tmp44
    tmp46 = tmp43 & tmp45
    tmp47 = tmp41 | tmp46
    tl.where(tmp47, tmp34, tmp5)
    tmp49 = tl.where(tmp47, tmp35, tmp44)
    tl.store(out_ptr0 + x2, tmp6, xmask)
    tl.store(out_ptr1 + x2, tmp49, xmask)


def call(args):
    primals_1, primals_2, primals_3 = 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,), (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_convolution_0[grid(16, 4)](primals_1, buf0, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf1 = extern_kernels.convolution(buf0, primals_2, stride=(1,),
            padding=(0,), dilation=(1,), transposed=False, output_padding=(
            0,), groups=1, bias=None)
        assert_size_stride(buf1, (4, 4, 1), (4, 1, 1))
        buf2 = buf0
        del buf0
        triton_poi_fused_convolution_1[grid(16, 4)](primals_1, buf2, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf3 = extern_kernels.convolution(buf2, primals_2, stride=(1,),
            padding=(0,), dilation=(1,), transposed=False, output_padding=(
            0,), groups=1, bias=None)
        assert_size_stride(buf3, (4, 4, 1), (4, 1, 1))
        buf4 = buf2
        del buf2
        triton_poi_fused_convolution_2[grid(16, 4)](primals_1, buf4, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf5 = extern_kernels.convolution(buf4, primals_2, stride=(1,),
            padding=(0,), dilation=(1,), transposed=False, output_padding=(
            0,), groups=1, bias=None)
        assert_size_stride(buf5, (4, 4, 1), (4, 1, 1))
        buf10 = reinterpret_tensor(buf4, (4, 1, 16), (16, 16, 1), 0)
        del buf4
        buf6 = reinterpret_tensor(buf10, (4, 1, 12), (16, 16, 1), 0)
        triton_poi_fused_cat_3[grid(48)](buf1, primals_3, buf3, buf5, buf6,
            48, XBLOCK=64, num_warps=1, num_stages=1)
        buf7 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        triton_poi_fused_convolution_4[grid(16, 4)](primals_1, buf7, 16, 4,
            XBLOCK=4, YBLOCK=16, num_warps=1, num_stages=1)
        buf8 = extern_kernels.convolution(buf7, primals_2, stride=(1,),
            padding=(0,), dilation=(1,), transposed=False, output_padding=(
            0,), groups=1, bias=None)
        assert_size_stride(buf8, (4, 4, 1), (4, 1, 1))
        del buf7
        buf9 = reinterpret_tensor(buf10, (4, 1, 4), (16, 16, 1), 12)
        buf13 = empty_strided_cuda((4, 1, 4), (4, 4, 1), torch.bool)
        buf14 = empty_strided_cuda((4, 1, 4), (4, 4, 1), torch.bool)
        buf15 = empty_strided_cuda((4, 1, 4), (4, 4, 1), torch.bool)
        buf16 = empty_strided_cuda((4, 1, 4), (4, 4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_5[grid(16)](buf8,
            primals_3, buf5, buf3, buf1, buf9, buf13, buf14, buf15, buf16, 
            16, XBLOCK=16, num_warps=1, num_stages=1)
        del buf1
        del buf3
        del buf5
        del primals_3
        buf11 = reinterpret_tensor(buf8, (4, 1, 4), (4, 4, 1), 0)
        del buf8
        buf12 = empty_strided_cuda((4, 1, 4), (4, 4, 1), torch.int64)
        triton_poi_fused_max_6[grid(16)](buf10, buf11, buf12, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        del buf10
        del buf6
        del buf9
    return buf11, primals_2, reinterpret_tensor(primals_1, (4, 4, 4), (64, 
        1, 4), 0), reinterpret_tensor(primals_1, (4, 4, 4), (64, 1, 4), 16
        ), reinterpret_tensor(primals_1, (4, 4, 4), (64, 1, 4), 32
        ), reinterpret_tensor(primals_1, (4, 4, 4), (64, 1, 4), 48
        ), buf12, buf13, buf14, buf15, buf16


class MetaPathEmbeddingNew(nn.Module):

    def __init__(self, path_num, hop_num, feature_size, latent_dim):
        super(MetaPathEmbeddingNew, self).__init__()
        self.path_num = path_num
        self.hop_num = hop_num
        self.feature_size = feature_size
        self.latent_dim = latent_dim
        self.lam = lambda x, index: x[:, index, :, :]
        if hop_num == 3:
            kernel_size = 3
        elif hop_num == 4:
            kernel_size = 4
        else:
            raise Exception('Only support 3-hop or 4-hop metapaths, hop %d' %
                hop_num)
        self.conv1D = nn.Conv1d(in_channels=self.feature_size, out_channels
            =self.latent_dim, kernel_size=kernel_size, stride=1, padding=0)
        nn.init.xavier_uniform_(self.conv1D.weight.data)
        self.dropout = nn.Dropout(p=0.5)

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


Measured latency_ms: 0.148857