import torch
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
from torch._inductor.runtime.triton_helpers import libdevice
import torch.utils.data
import torch
from torch import nn
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda


@triton.jit
def triton_poi_fused_pow_0(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl.
    constexpr):
    xnumel = 1024
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 16
    x4 = xindex // 64
    x5 = xindex // 16 % 16
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x4), xmask, eviction_policy=
        'evict_last')
    tmp5 = tl.load(in_ptr1 + x5, xmask, eviction_policy='evict_last')
    tmp1 = tl.full([1], 0, tl.int32)
    tmp2 = triton_helpers.maximum(tmp1, tmp0)
    tmp3 = 0.1
    tmp4 = tmp2 + tmp3
    tmp6 = libdevice.pow(tmp4, tmp5)
    tl.store(out_ptr0 + x6, tmp6, xmask)


@triton.jit
def triton_poi_fused_add_prod_1(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex // 64
    x3 = xindex % 64
    x1 = xindex // 16 % 4
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x3 + 256 * x2), xmask)
    tmp1 = tl.load(in_ptr0 + (64 + x3 + 256 * x2), xmask)
    tmp3 = tl.load(in_ptr0 + (128 + x3 + 256 * x2), xmask)
    tmp5 = tl.load(in_ptr0 + (192 + x3 + 256 * x2), xmask)
    tmp7 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp2 = tmp0 * tmp1
    tmp4 = tmp2 * tmp3
    tmp6 = tmp4 * tmp5
    tmp8 = tmp6 + tmp7
    tl.store(out_ptr0 + x4, tmp8, xmask)


@triton.jit
def triton_poi_fused_ge_2(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 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 1, 1), (4, 1, 1, 1))
    assert_size_stride(primals_3, (4, 1, 1), (1, 1, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4, 4, 4), (256, 64, 16, 4, 1),
            torch.float32)
        get_raw_stream(0)
        triton_poi_fused_pow_0[grid(1024)](primals_1, primals_2, buf0, 1024,
            XBLOCK=256, num_warps=4, num_stages=1)
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused_add_prod_1[grid(256)](buf0, primals_3, buf1, 256,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_3
        buf2 = empty_strided_cuda((4, 4, 1, 1), (4, 1, 1, 1), torch.bool)
        triton_poi_fused_ge_2[grid(16)](primals_2, buf2, 16, XBLOCK=16,
            num_warps=1, num_stages=1)
        del primals_2
    return buf1, primals_1, buf0, buf2


class MultNew(nn.Module):

    def __init__(self, nc):
        super(MultNew, self).__init__()
        self.register_parameter(name='exp', param=torch.nn.Parameter(torch.
            diag(torch.ones(nc)).unsqueeze(-1).unsqueeze(-1)))
        """self.register_parameter(name='weight',
                                param=torch.nn.Parameter(torch.ones(nc).unsqueeze(-1).unsqueeze(-1)))
                                """
        self.register_parameter(name='bias', param=torch.nn.Parameter(torch
            .zeros(nc).unsqueeze(-1).unsqueeze(-1)))
        self.relu = nn.ReLU()

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


Measured latency_ms: 0.040315