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_replication_pad1d_0(in_ptr0, 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 = tl.load(in_ptr0 + (4 * x1 + (3 * (3 <= 0 * (0 >= -2 + x0) + (-2 +
        x0) * (-2 + x0 > 0)) + (0 * (0 >= -2 + x0) + (-2 + x0) * (-2 + x0 >
        0)) * (0 * (0 >= -2 + x0) + (-2 + x0) * (-2 + x0 > 0) < 3))), xmask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + x2, tmp0, xmask)


@triton.jit
def triton_poi_fused_replication_pad1d_1(in_ptr0, 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 % 5
    x1 = xindex // 5
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (5 * x1 + (4 * (4 <= x0) + x0 * (x0 < 4))), xmask)
    tl.store(out_ptr0 + x2, tmp0, xmask)


def call(args):
    primals_1, primals_2, primals_3 = args
    args.clear()
    assert_size_stride(primals_1, (4, 1, 4), (4, 4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4, 4, 1), (4, 1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_replication_pad1d_0[grid(32)](primals_2, buf0, 32,
            XBLOCK=32, num_warps=1, num_stages=1)
        del primals_2
        buf1 = extern_kernels.convolution(reinterpret_tensor(buf0, (1, 4, 8
            ), (0, 8, 1), 0), primals_1, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=4,
            bias=None)
        assert_size_stride(buf1, (1, 4, 5), (20, 5, 1))
        buf2 = empty_strided_cuda((4, 5), (5, 1), torch.float32)
        triton_poi_fused_replication_pad1d_1[grid(20)](buf1, buf2, 20,
            XBLOCK=32, num_warps=1, num_stages=1)
        buf3 = extern_kernels.convolution(reinterpret_tensor(buf2, (1, 4, 5
            ), (0, 5, 1), 0), primals_3, stride=(1,), padding=(0,),
            dilation=(1,), transposed=False, output_padding=(0,), groups=1,
            bias=None)
        assert_size_stride(buf3, (1, 4, 5), (20, 5, 1))
    return reinterpret_tensor(buf3, (4, 5), (5, 1), 0
        ), primals_1, primals_3, reinterpret_tensor(buf0, (1, 4, 8), (32, 8,
        1), 0), reinterpret_tensor(buf1, (4, 5), (5, 1), 0
        ), reinterpret_tensor(buf2, (1, 4, 5), (20, 5, 1), 0)


class DW_PW_projectionNew(nn.Module):

    def __init__(self, c_in, c_out, kernel_size, bias=False, padding_mode=
        'replicate'):
        super(DW_PW_projectionNew, self).__init__()
        self.dw_conv1d = nn.Conv1d(in_channels=c_in, out_channels=c_in,
            kernel_size=kernel_size, padding=int(kernel_size / 2), groups=
            c_in, bias=bias, padding_mode=padding_mode)
        self.pw_conv1d = nn.Conv1d(in_channels=c_in, out_channels=c_out,
            kernel_size=1, padding=0, groups=1, bias=bias, padding_mode=
            padding_mode)

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


Measured latency_ms: 0.049866