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_relu_0(in_out_ptr0, in_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 691200
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x3 = xindex
    x1 = xindex // 3456 % 50
    tmp0 = tl.load(in_out_ptr0 + x3, 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)
    tl.store(in_out_ptr0 + x3, tmp4, xmask)


@triton.jit
def triton_red_fused_convolution_mean_relu_threshold_backward_1(in_out_ptr0,
    in_ptr0, in_ptr1, out_ptr0, xnumel, rnumel, XBLOCK: tl.constexpr,
    RBLOCK: tl.constexpr):
    xnumel = 200
    rnumel = 2816
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rbase = tl.arange(0, RBLOCK)[None, :]
    x3 = xindex
    x0 = xindex % 50
    tmp1 = tl.load(in_ptr1 + x0, xmask, eviction_policy='evict_last')
    _tmp6 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
    for roffset in range(0, rnumel, RBLOCK):
        rindex = roffset + rbase
        rmask = rindex < rnumel
        r2 = rindex
        tmp0 = tl.load(in_ptr0 + (r2 + 2816 * x3), rmask & xmask,
            eviction_policy='evict_first', other=0.0)
        tmp2 = tmp0 + tmp1
        tmp3 = tl.full([1, 1], 0, tl.int32)
        tmp4 = triton_helpers.maximum(tmp3, tmp2)
        tmp5 = tl.broadcast_to(tmp4, [XBLOCK, RBLOCK])
        tmp7 = _tmp6 + tmp5
        _tmp6 = tl.where(rmask & xmask, tmp7, _tmp6)
        tmp8 = 0.0
        tmp9 = tmp4 <= tmp8
        tl.store(out_ptr0 + (r2 + 2816 * x3), tmp9, rmask & xmask)
    tmp6 = tl.sum(_tmp6, 1)[:, None]
    tmp10 = 2816.0
    tmp11 = tmp6 / tmp10
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x3, tmp11, xmask)


@triton.jit
def triton_poi_fused_relu_2(in_out_ptr0, in_ptr0, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 200
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 50
    tmp0 = tl.load(in_out_ptr0 + x2, xmask)
    tmp1 = tl.load(in_ptr0 + x0, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tl.store(in_out_ptr0 + x2, tmp4, xmask)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9) = args
    args.clear()
    assert_size_stride(primals_1, (50, 4, 1, 11), (44, 11, 11, 1))
    assert_size_stride(primals_2, (50,), (1,))
    assert_size_stride(primals_3, (4, 4, 64, 64), (16384, 4096, 64, 1))
    assert_size_stride(primals_4, (50, 50, 1, 11), (550, 11, 11, 1))
    assert_size_stride(primals_5, (50,), (1,))
    assert_size_stride(primals_6, (50, 50), (50, 1))
    assert_size_stride(primals_7, (50,), (1,))
    assert_size_stride(primals_8, (5, 50), (50, 1))
    assert_size_stride(primals_9, (5,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_3, primals_1, stride=(1, 
            1), padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf0, (4, 50, 64, 54), (172800, 3456, 54, 1))
        buf1 = buf0
        del buf0
        get_raw_stream(0)
        triton_poi_fused_convolution_relu_0[grid(691200)](buf1, primals_2, 
            691200, XBLOCK=512, num_warps=8, num_stages=1)
        del primals_2
        buf2 = extern_kernels.convolution(buf1, primals_4, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf2, (4, 50, 64, 44), (140800, 2816, 44, 1))
        buf3 = empty_strided_cuda((4, 50), (50, 1), torch.float32)
        buf8 = empty_strided_cuda((4, 50, 64, 44), (140800, 2816, 44, 1),
            torch.bool)
        buf4 = buf3
        del buf3
        triton_red_fused_convolution_mean_relu_threshold_backward_1[grid(200)](
            buf4, buf2, primals_5, buf8, 200, 2816, XBLOCK=1, RBLOCK=2048,
            num_warps=16, num_stages=1)
        del buf2
        del primals_5
        buf5 = empty_strided_cuda((4, 50), (50, 1), torch.float32)
        extern_kernels.mm(buf4, reinterpret_tensor(primals_6, (50, 50), (1,
            50), 0), out=buf5)
        buf6 = buf5
        del buf5
        triton_poi_fused_relu_2[grid(200)](buf6, primals_7, 200, XBLOCK=128,
            num_warps=4, num_stages=1)
        del primals_7
        buf7 = empty_strided_cuda((4, 5), (5, 1), torch.float32)
        extern_kernels.addmm(primals_9, buf6, reinterpret_tensor(primals_8,
            (50, 5), (1, 50), 0), alpha=1, beta=1, out=buf7)
        del primals_9
    return (buf7, primals_1, primals_3, primals_4, buf1, buf4, buf6,
        primals_8, primals_6, buf8)


class DeepLiftRegressorNew(nn.Module):

    def __init__(self):
        super(DeepLiftRegressorNew, self).__init__()
        self.conv1 = nn.Conv2d(in_channels=4, out_channels=50, kernel_size=
            (1, 11))
        self.conv2 = nn.Conv2d(in_channels=50, out_channels=50, kernel_size
            =(1, 11))
        self.fc1 = nn.Linear(50, 50)
        self.dropout1 = nn.Dropout2d(p=0.5)
        self.fc2 = nn.Linear(50, 5)

    def num_flat_features(self, x):
        size = x.size()[1:]
        num_features = 1
        for s in size:
            num_features *= s
        return num_features

    def forward(self, input_0):
        primals_1 = self.conv1.weight
        primals_2 = self.conv1.bias
        primals_4 = self.conv2.weight
        primals_5 = self.conv2.bias
        primals_6 = self.fc1.weight
        primals_7 = self.fc1.bias
        primals_8 = self.fc2.weight
        primals_9 = self.fc2.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])
        return output[0]


Measured latency_ms: 0.020876