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 math as tl_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_relu_threshold_backward_0(in_out_ptr0, in_ptr0,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_out_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr0 + x1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + x2, tmp4, None)
    tl.store(out_ptr0 + x2, tmp6, None)


@triton.jit
def triton_poi_fused_relu_threshold_backward_1(in_out_ptr0, in_ptr0,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + x2, tmp4, xmask)
    tl.store(out_ptr0 + x2, tmp6, xmask)


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


@triton.jit
def triton_poi_fused__softmax_3(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 8
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + 4 * x1, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr0 + (1 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (2 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr0 + (3 + 4 * x1), xmask, eviction_policy='evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tmp9 = tl_math.exp(tmp8)
    tl.store(out_ptr0 + x2, tmp9, xmask)


@triton.jit
def triton_poi_fused_mean_4(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 2
    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')
    tmp1 = tl.load(in_ptr1 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp2 = tl.load(in_ptr1 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr1 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp6 = tl.load(in_ptr1 + (3 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp14 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp18 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp3 = tmp1 + tmp2
    tmp5 = tmp3 + tmp4
    tmp7 = tmp5 + tmp6
    tmp8 = tmp1 / tmp7
    tmp9 = tmp0 * tmp8
    tmp11 = tmp2 / tmp7
    tmp12 = tmp10 * tmp11
    tmp13 = tmp9 + tmp12
    tmp15 = tmp4 / tmp7
    tmp16 = tmp14 * tmp15
    tmp17 = tmp13 + tmp16
    tmp19 = tmp6 / tmp7
    tmp20 = tmp18 * tmp19
    tmp21 = tmp17 + tmp20
    tmp22 = 4.0
    tmp23 = tmp21 / tmp22
    tl.store(out_ptr0 + x0, tmp23, 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) = args
    args.clear()
    assert_size_stride(primals_1, (512, 4, 1), (4, 1, 1))
    assert_size_stride(primals_2, (512,), (1,))
    assert_size_stride(primals_3, (4, 4), (4, 1))
    assert_size_stride(primals_4, (256, 512, 1), (512, 1, 1))
    assert_size_stride(primals_5, (256,), (1,))
    assert_size_stride(primals_6, (2, 256, 1), (256, 1, 1))
    assert_size_stride(primals_7, (2,), (1,))
    assert_size_stride(primals_8, (512, 4, 1), (4, 1, 1))
    assert_size_stride(primals_9, (512,), (1,))
    assert_size_stride(primals_10, (256, 256, 1), (256, 1, 1))
    assert_size_stride(primals_11, (256,), (1,))
    assert_size_stride(primals_12, (256, 128, 1), (128, 1, 1))
    assert_size_stride(primals_13, (256,), (1,))
    assert_size_stride(primals_14, (2, 128, 1), (128, 1, 1))
    assert_size_stride(primals_15, (2,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(reinterpret_tensor(primals_3, (1,
            4, 4), (16, 4, 1), 0), primals_1, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=1,
            bias=None)
        assert_size_stride(buf0, (1, 512, 4), (2048, 4, 1))
        buf1 = reinterpret_tensor(buf0, (512, 4), (4, 1), 0)
        del buf0
        buf20 = empty_strided_cuda((512, 4), (4, 1), torch.bool)
        get_raw_stream(0)
        triton_poi_fused_relu_threshold_backward_0[grid(2048)](buf1,
            primals_2, buf20, 2048, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_2
        buf2 = extern_kernels.convolution(reinterpret_tensor(buf1, (1, 512,
            4), (0, 4, 1), 0), primals_4, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=1,
            bias=None)
        assert_size_stride(buf2, (1, 256, 4), (1024, 4, 1))
        buf3 = reinterpret_tensor(buf2, (256, 4), (4, 1), 0)
        del buf2
        buf19 = empty_strided_cuda((256, 4), (4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_1[grid(1024)](buf3,
            primals_5, buf19, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_5
        buf4 = extern_kernels.convolution(reinterpret_tensor(buf3, (1, 256,
            4), (0, 4, 1), 0), primals_6, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=1,
            bias=None)
        assert_size_stride(buf4, (1, 2, 4), (8, 4, 1))
        buf5 = buf4
        del buf4
        triton_poi_fused_convolution_2[grid(8)](buf5, primals_7, 8, XBLOCK=
            8, num_warps=1, num_stages=1)
        del primals_7
        buf6 = empty_strided_cuda((2, 4), (4, 1), torch.float32)
        triton_poi_fused__softmax_3[grid(8)](buf5, buf6, 8, XBLOCK=8,
            num_warps=1, num_stages=1)
        buf7 = extern_kernels.convolution(reinterpret_tensor(primals_3, (1,
            4, 4), (16, 4, 1), 0), primals_8, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=1,
            bias=None)
        assert_size_stride(buf7, (1, 512, 4), (2048, 4, 1))
        buf8 = reinterpret_tensor(buf7, (512, 4), (4, 1), 0)
        del buf7
        buf18 = empty_strided_cuda((512, 4), (4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_0[grid(2048)](buf8,
            primals_9, buf18, 2048, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_9
        buf9 = extern_kernels.convolution(reinterpret_tensor(buf8, (1, 512,
            4), (0, 4, 1), 0), primals_10, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=2,
            bias=None)
        assert_size_stride(buf9, (1, 256, 4), (1024, 4, 1))
        buf10 = reinterpret_tensor(buf9, (256, 4), (4, 1), 0)
        del buf9
        buf17 = empty_strided_cuda((256, 4), (4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_1[grid(1024)](buf10,
            primals_11, buf17, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_11
        buf11 = extern_kernels.convolution(reinterpret_tensor(buf10, (1, 
            256, 4), (0, 4, 1), 0), primals_12, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=2,
            bias=None)
        assert_size_stride(buf11, (1, 256, 4), (1024, 4, 1))
        buf12 = reinterpret_tensor(buf11, (256, 4), (4, 1), 0)
        del buf11
        buf16 = empty_strided_cuda((256, 4), (4, 1), torch.bool)
        triton_poi_fused_relu_threshold_backward_1[grid(1024)](buf12,
            primals_13, buf16, 1024, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_13
        buf13 = extern_kernels.convolution(reinterpret_tensor(buf12, (1, 
            256, 4), (0, 4, 1), 0), primals_14, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=2,
            bias=None)
        assert_size_stride(buf13, (1, 2, 4), (8, 4, 1))
        buf14 = buf13
        del buf13
        triton_poi_fused_convolution_2[grid(8)](buf14, primals_15, 8,
            XBLOCK=8, num_warps=1, num_stages=1)
        del primals_15
        buf15 = empty_strided_cuda((2,), (1,), torch.float32)
        triton_poi_fused_mean_4[grid(2)](buf14, buf6, buf15, 2, XBLOCK=2,
            num_warps=1, num_stages=1)
        del buf6
    return (reinterpret_tensor(buf15, (2, 1, 1), (1, 1, 1), 0),
        reinterpret_tensor(buf5, (2, 4), (4, 1), 0), primals_1, primals_4,
        primals_6, primals_8, primals_10, primals_12, primals_14,
        reinterpret_tensor(primals_3, (1, 4, 4), (16, 4, 1), 0),
        reinterpret_tensor(buf1, (1, 512, 4), (2048, 4, 1), 0),
        reinterpret_tensor(buf3, (1, 256, 4), (1024, 4, 1), 0),
        reinterpret_tensor(buf5, (2, 4), (4, 1), 0), reinterpret_tensor(
        buf8, (1, 512, 4), (2048, 4, 1), 0), reinterpret_tensor(buf10, (1, 
        256, 4), (1024, 4, 1), 0), reinterpret_tensor(buf12, (1, 256, 4), (
        1024, 4, 1), 0), buf14, buf16, buf17, buf18, buf19, buf20)


class MLP_PARTNew(nn.Module):

    def __init__(self, filter_channels, merge_layer=0, res_layers=[], norm=
        'group', num_parts=2, last_op=None):
        super(MLP_PARTNew, self).__init__()
        self.num_parts = num_parts
        self.fc_parts_0 = nn.Conv1d(filter_channels[0], 512, 1)
        self.fc_parts_1 = nn.Conv1d(512, 256, 1)
        self.fc_parts_out = nn.Conv1d(256, num_parts, 1)
        self.fc_parts_softmax = nn.Softmax(1)
        self.part_0 = nn.Conv1d(filter_channels[0], 256 * num_parts, 1)
        self.part_1 = nn.Conv1d(256 * num_parts, 128 * num_parts, 1, groups
            =num_parts)
        self.part_2 = nn.Conv1d(128 * num_parts, 128 * num_parts, 1, groups
            =num_parts)
        self.part_out = nn.Conv1d(128 * num_parts, num_parts, 1, groups=
            num_parts)
        self.actvn = nn.ReLU()
        self.last = last_op

    def forward(self, input_0):
        primals_1 = self.fc_parts_0.weight
        primals_2 = self.fc_parts_0.bias
        primals_4 = self.fc_parts_1.weight
        primals_5 = self.fc_parts_1.bias
        primals_6 = self.fc_parts_out.weight
        primals_7 = self.fc_parts_out.bias
        primals_8 = self.part_0.weight
        primals_9 = self.part_0.bias
        primals_10 = self.part_1.weight
        primals_11 = self.part_1.bias
        primals_12 = self.part_2.weight
        primals_13 = self.part_2.bias
        primals_14 = self.part_out.weight
        primals_15 = self.part_out.bias
        primals_3 = input_0
        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])
        return output[0], output[1]


Measured latency_ms: 0.025804