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 import nn
import torch.utils.data
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_add_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 16
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + x0, xmask)
    tmp1 = 0.0
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + x0, tmp2, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4), (4, 1))
    assert_size_stride(primals_2, (4, 4), (4, 1))
    assert_size_stride(primals_3, (4,), (1,))
    assert_size_stride(primals_4, (16, 4), (4, 1))
    assert_size_stride(primals_5, (16,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_add_0[grid(16)](primals_1, buf0, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        buf1 = empty_strided_cuda((4, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_3, buf0, reinterpret_tensor(primals_2,
            (4, 4), (1, 4), 0), alpha=1, beta=1, out=buf1)
        del primals_2
        del primals_3
        buf2 = empty_strided_cuda((4, 16), (16, 1), torch.float32)
        extern_kernels.addmm(primals_5, primals_1, reinterpret_tensor(
            primals_4, (4, 16), (1, 4), 0), alpha=1, beta=1, out=buf2)
        del primals_4
        del primals_5
    return buf1, buf2, primals_1, buf0


class FastRCNNPredictorNew(nn.Module):
    """
    Standard classification + bounding box regression layers
    for Fast R-CNN.

    Arguments:
        in_channels (int): number of input channels
        num_classes (int): number of output classes (including background)
    """

    def __init__(self, in_channels, num_classes, n_fc_classif_layers=1,
        dropout=0.1, batched_nms=True):
        super(FastRCNNPredictorNew, self).__init__()
        self.n_fc_classif_layers = n_fc_classif_layers
        self.batched_nms = batched_nms
        self.fc_classif_layers = {i: nn.Linear(in_channels, in_channels) for
            i in range(n_fc_classif_layers - 1)}
        self.dropout = nn.Dropout(dropout)
        self.cls_score = nn.Linear(in_channels, num_classes)
        if self.batched_nms:
            self.bbox_pred = nn.Linear(in_channels, num_classes * 4)
        else:
            self.bbox_pred = nn.Linear(in_channels, 2 * 4)

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


Measured latency_ms: 0.029665