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.utils.data
import torch
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_clone_0(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 256
    xnumel = 32
    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 % 64
    y1 = yindex // 64
    y3 = yindex
    tmp0 = tl.load(in_ptr0 + (y0 + 64 * x2 + 2048 * y1), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (x2 + 32 * y3), tmp0, xmask & ymask)


def call(args):
    primals_1, primals_2, primals_3 = args
    args.clear()
    assert_size_stride(primals_1, (32, 2, 31), (62, 31, 1))
    assert_size_stride(primals_2, (4, 2, 64), (128, 64, 1))
    assert_size_stride(primals_3, (4, 32), (32, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_2, primals_1, stride=(1,),
            padding=(15,), dilation=(1,), transposed=False, output_padding=
            (0,), groups=1, bias=None)
        assert_size_stride(buf0, (4, 32, 64), (2048, 64, 1))
        buf1 = empty_strided_cuda((4, 64, 32), (2048, 32, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_clone_0[grid(256, 32)](buf0, buf1, 256, 32, XBLOCK
            =32, YBLOCK=32, num_warps=4, num_stages=1)
        del buf0
        buf2 = empty_strided_cuda((256, 4), (4, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf1, (256, 32), (32, 1), 0),
            reinterpret_tensor(primals_3, (32, 4), (1, 32), 0), out=buf2)
    return reinterpret_tensor(buf2, (4, 64, 4), (256, 4, 1), 0
        ), primals_1, primals_2, reinterpret_tensor(buf1, (256, 32), (32, 1), 0
        ), primals_3


class Linear(nn.Module):

    def __init__(self, in_features, out_features, bias=True, init_gain='linear'
        ):
        super(Linear, self).__init__()
        self.linear_layer = nn.Linear(in_features, out_features, bias=bias)
        self._init_w(init_gain)

    def _init_w(self, init_gain):
        nn.init.xavier_uniform_(self.linear_layer.weight, gain=nn.init.
            calculate_gain(init_gain))

    def forward(self, x):
        return self.linear_layer(x)


class LocationLayerNew(nn.Module):

    def __init__(self, attention_dim, attention_n_filters=32,
        attention_kernel_size=31):
        super(LocationLayerNew, self).__init__()
        self.location_conv = nn.Conv1d(in_channels=2, out_channels=
            attention_n_filters, kernel_size=attention_kernel_size, stride=
            1, padding=(attention_kernel_size - 1) // 2, bias=False)
        self.location_dense = Linear(attention_n_filters, attention_dim,
            bias=False, init_gain='tanh')

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


Measured latency_ms: 0.034304