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.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_max_0(in_ptr0, out_ptr0, out_ptr1, 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 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp3 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp2 = triton_helpers.maximum(tmp0, tmp1)
    tmp4 = triton_helpers.maximum(tmp2, tmp3)
    tmp6 = triton_helpers.maximum(tmp4, tmp5)
    tmp7 = tmp0 > tmp1
    tmp8 = tmp0 == tmp1
    tmp9 = tmp0 != tmp0
    tmp10 = tmp1 != tmp1
    tmp11 = tmp9 > tmp10
    tmp12 = tmp7 | tmp11
    tmp13 = tmp9 & tmp10
    tmp14 = tmp8 | tmp13
    tmp15 = tl.full([1], 0, tl.int64)
    tmp16 = tl.full([1], 1, tl.int64)
    tmp17 = tmp15 < tmp16
    tmp18 = tmp14 & tmp17
    tmp19 = tmp12 | tmp18
    tmp20 = tl.where(tmp19, tmp0, tmp1)
    tmp21 = tl.where(tmp19, tmp15, tmp16)
    tmp22 = tmp20 > tmp3
    tmp23 = tmp20 == tmp3
    tmp24 = tmp20 != tmp20
    tmp25 = tmp3 != tmp3
    tmp26 = tmp24 > tmp25
    tmp27 = tmp22 | tmp26
    tmp28 = tmp24 & tmp25
    tmp29 = tmp23 | tmp28
    tmp30 = tl.full([1], 2, tl.int64)
    tmp31 = tmp21 < tmp30
    tmp32 = tmp29 & tmp31
    tmp33 = tmp27 | tmp32
    tmp34 = tl.where(tmp33, tmp20, tmp3)
    tmp35 = tl.where(tmp33, tmp21, tmp30)
    tmp36 = tmp34 > tmp5
    tmp37 = tmp34 == tmp5
    tmp38 = tmp34 != tmp34
    tmp39 = tmp5 != tmp5
    tmp40 = tmp38 > tmp39
    tmp41 = tmp36 | tmp40
    tmp42 = tmp38 & tmp39
    tmp43 = tmp37 | tmp42
    tmp44 = tl.full([1], 3, tl.int64)
    tmp45 = tmp35 < tmp44
    tmp46 = tmp43 & tmp45
    tmp47 = tmp41 | tmp46
    tl.where(tmp47, tmp34, tmp5)
    tmp49 = tl.where(tmp47, tmp35, tmp44)
    tl.store(out_ptr0 + x0, tmp6, xmask)
    tl.store(out_ptr1 + x0, tmp49, xmask)


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


class maxoutNew(nn.Module):

    def __init__(self, in_feature, out_feature, pool_size):
        super(maxoutNew, self).__init__()
        self.in_feature = in_feature
        self.out_feature = out_feature
        self.pool_size = pool_size
        self.linear = nn.Linear(in_feature, out_feature * pool_size)

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


Measured latency_ms: 0.026463