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 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_cat_0(in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8
    x1 = xindex // 8
    x2 = xindex
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (4 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp6 = tl.load(in_ptr1 + x0, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp7 = tmp5 + tmp6
    tmp8 = tl.load(in_ptr2 + (4 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp9 = tl.load(in_ptr3 + x0, tmp4 & xmask, eviction_policy='evict_last',
        other=0.0)
    tmp10 = tmp8 + tmp9
    tmp11 = tmp7 - tmp10
    tmp12 = tl.full(tmp11.shape, 0.0, tmp11.dtype)
    tmp13 = tl.where(tmp4, tmp11, tmp12)
    tmp14 = tmp0 >= tmp3
    tl.full([1], 8, tl.int64)
    tmp17 = tl.load(in_ptr0 + (4 * x1 + (-4 + x0)), tmp14 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp18 = tl.load(in_ptr1 + (-4 + x0), tmp14 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp19 = tmp17 + tmp18
    tmp20 = tl.load(in_ptr2 + (4 * x1 + (-4 + x0)), tmp14 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp21 = tl.load(in_ptr3 + (-4 + x0), tmp14 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp22 = tmp20 + tmp21
    tmp23 = tmp19 + tmp22
    tmp24 = tl.full(tmp23.shape, 0.0, tmp23.dtype)
    tmp25 = tl.where(tmp14, tmp23, tmp24)
    tmp26 = tl.where(tmp4, tmp13, tmp25)
    tl.store(out_ptr0 + x2, tmp26, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5 = args
    args.clear()
    assert_size_stride(primals_1, (4, 8, 4), (32, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_3, (4,), (1,))
    assert_size_stride(primals_4, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_5, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(reinterpret_tensor(primals_1, (4,
            4, 4), (32, 4, 1), 0), primals_2, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=1,
            bias=None)
        assert_size_stride(buf0, (4, 4, 1), (4, 1, 1))
        buf1 = extern_kernels.convolution(reinterpret_tensor(primals_1, (4,
            4, 4), (32, 4, 1), 16), primals_4, 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 = empty_strided_cuda((4, 8, 1), (8, 1, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_cat_0[grid(32)](buf0, primals_3, buf1, primals_5,
            buf2, 32, XBLOCK=32, num_warps=1, num_stages=1)
        del buf0
        del buf1
        del primals_3
        del primals_5
    return buf2, primals_2, primals_4, reinterpret_tensor(primals_1, (4, 4,
        4), (32, 4, 1), 0), reinterpret_tensor(primals_1, (4, 4, 4), (32, 4,
        1), 16)


class ComplexConvNew(nn.Module):

    def __init__(self, in_channel, out_channel, kernel_size, stride=1,
        padding=0, dilation=1, groups=1, bias=True):
        super(ComplexConvNew, self).__init__()
        self.device = torch.device('cuda' if torch.cuda.is_available() else
            'cpu')
        self.padding = padding
        self.conv_re = nn.Conv1d(in_channel, out_channel, kernel_size,
            stride=stride, padding=padding, dilation=dilation, groups=
            groups, bias=bias)
        self.conv_im = nn.Conv1d(in_channel, out_channel, kernel_size,
            stride=stride, padding=padding, dilation=dilation, groups=
            groups, bias=bias)

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


Measured latency_ms: 0.047489