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_relu_threshold_backward_0(in_ptr0, out_ptr0, out_ptr1,
    xnumel, XBLOCK: tl.constexpr):
    xnumel = 12000
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x0 = xindex % 3000
    x1 = xindex // 3000
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = 0.0
    tmp4 = tmp2 <= tmp3
    tl.store(out_ptr0 + (x0 + 3008 * x1), tmp2, xmask)
    tl.store(out_ptr1 + (x0 + 3072 * x1), tmp4, xmask)


@triton.jit
def triton_poi_fused_relu_view_1(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 12000
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 100
    x1 = xindex // 100
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (25 * ((x0 + 100 * x1) // 25 % 120) + 3008 * (
        (x0 + 100 * x1) // 3000) + x0 % 25), xmask)
    tl.store(out_ptr0 + x2, tmp0, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4 = args
    args.clear()
    assert_size_stride(primals_1, (4, 1, 3, 8), (24, 24, 8, 1))
    assert_size_stride(primals_2, (4, 1, 32, 32), (1024, 1024, 32, 1))
    assert_size_stride(primals_3, (1, 100), (100, 1))
    assert_size_stride(primals_4, (1,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = extern_kernels.convolution(primals_2, 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, 4, 30, 25), (3000, 750, 25, 1))
        buf1 = empty_strided_cuda((4, 4, 30, 25), (3008, 750, 25, 1), torch
            .float32)
        buf5 = empty_strided_cuda((4, 4, 30, 25), (3072, 750, 25, 1), torch
            .bool)
        get_raw_stream(0)
        triton_poi_fused_relu_threshold_backward_0[grid(12000)](buf0, buf1,
            buf5, 12000, XBLOCK=256, num_warps=4, num_stages=1)
        buf2 = reinterpret_tensor(buf0, (120, 100), (100, 1), 0)
        del buf0
        triton_poi_fused_relu_view_1[grid(12000)](buf1, buf2, 12000, XBLOCK
            =128, num_warps=4, num_stages=1)
        del buf1
        buf4 = empty_strided_cuda((120, 1), (1, 1), torch.float32)
        extern_kernels.addmm(primals_4, buf2, reinterpret_tensor(primals_3,
            (100, 1), (1, 100), 0), alpha=1, beta=1, out=buf4)
        del primals_4
    return buf4, primals_1, primals_2, buf2, primals_3, buf5


class NetNew(nn.Module):

    def __init__(self):
        super(NetNew, self).__init__()
        self.conv1 = nn.Conv2d(1, 4, (3, 8), bias=False, stride=1)
        self.fc1 = nn.Linear(25 * 4, 1)

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


Measured latency_ms: 0.049122