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
import torch.nn
import torch.nn.init
import torch.optim
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_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    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 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    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, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (8, 4), (4, 1))
    assert_size_stride(primals_3, (8,), (1,))
    assert_size_stride(primals_4, (4, 8), (8, 1))
    assert_size_stride(primals_5, (4,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_relu_0[grid(256)](primals_1, buf0, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        del primals_1
        buf1 = empty_strided_cuda((64, 8), (8, 1), torch.float32)
        extern_kernels.addmm(primals_3, reinterpret_tensor(buf0, (64, 4), (
            4, 1), 0), reinterpret_tensor(primals_2, (4, 8), (1, 4), 0),
            alpha=1, beta=1, out=buf1)
        del primals_2
        del primals_3
        buf2 = torch.ops.aten.native_dropout.default(reinterpret_tensor(
            buf1, (4, 4, 4, 8), (128, 32, 8, 1), 0), 0.5, True)
        del buf1
        buf3 = buf2[0]
        buf4 = buf2[1]
        del buf2
        buf5 = empty_strided_cuda((64, 4), (4, 1), torch.float32)
        extern_kernels.addmm(primals_5, reinterpret_tensor(buf3, (64, 8), (
            8, 1), 0), reinterpret_tensor(primals_4, (8, 4), (1, 8), 0),
            alpha=1, beta=1, out=buf5)
        del primals_5
        buf6 = torch.ops.aten.native_dropout.default(reinterpret_tensor(
            buf5, (4, 4, 4, 4), (64, 16, 4, 1), 0), 0.5, True)
        del buf5
        buf7 = buf6[0]
        buf8 = buf6[1]
        del buf6
    return buf7, reinterpret_tensor(buf0, (64, 4), (4, 1), 0
        ), buf4, reinterpret_tensor(buf3, (64, 8), (8, 1), 0), buf8, primals_4


class Model(nn.Module):
    """ Class representing sampleable neural network model """

    def num_params(self):
        """ Get the number of model parameters. """
        return sum(p.numel() for p in self.parameters())

    def summary(self, hashsummary=False):
        None
        None
        self.num_params()
        None
        None
        if hashsummary:
            None
            for idx, hashvalue in enumerate(self.hashsummary()):
                None

    def hashsummary(self):
        """ Print a model summary - checksums of each layer parameters """
        children = list(self.children())
        result = []
        for child in children:
            result.extend(hashlib.sha256(x.detach().cpu().numpy().tobytes()
                ).hexdigest() for x in child.parameters())
        return result

    def loss(self, x_data, y_true, reduce='mean'):
        """ Forward propagate network and return a value of loss function """
        if reduce not in (None, 'sum', 'mean'):
            raise ValueError('`reduce` must be either None, `sum`, or `mean`!')
        y_pred = self(x_data)
        return y_pred, self.loss_value(x_data, y_true, y_pred, reduce=reduce)

    def loss_value(self, x_data, y_true, y_pred, reduce=None):
        """ Calculate a value of loss function """
        raise NotImplementedError


class LinearDropNew(Model):
    """ Linear block with dropout """

    def __init__(self, c_in, c_out, affine=True):
        super(LinearDropNew, self).__init__()
        assert c_out % 2 == 0
        self.fc1 = nn.Linear(c_in, c_in * 2)
        self.fc2 = nn.Linear(c_in * 2, c_out)

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


Measured latency_ms: 0.03222