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
import torch.utils.data
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_clone_0(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 4
    x3 = xindex
    tmp0 = tl.load(in_ptr0 + x1, xmask, eviction_policy='evict_last')
    tl.store(out_ptr0 + x3, tmp0, xmask)


@triton.jit
def triton_poi_fused_cat_1(in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex % 8
    x1 = xindex // 8
    x2 = xindex
    tmp6 = tl.load(in_ptr1 + 0)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp0 = x0
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (4 * x1 + x0), tmp4 & xmask, eviction_policy=
        'evict_last', other=0.0)
    tmp8 = tmp5 + tmp7
    tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
    tmp10 = tl.where(tmp4, tmp8, tmp9)
    tmp11 = tmp0 >= tmp3
    tl.full([1], 8, tl.int64)
    tmp14 = tl.load(in_ptr2 + (4 * x1 + (-4 + x0)), tmp11 & xmask,
        eviction_policy='evict_last', other=0.0)
    tmp15 = tmp14 + tmp7
    tmp16 = tl.full(tmp15.shape, 0.0, tmp15.dtype)
    tmp17 = tl.where(tmp11, tmp15, tmp16)
    tmp18 = tl.where(tmp4, tmp10, tmp17)
    tl.store(out_ptr0 + x2, tmp18, xmask)


def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5 = args
    args.clear()
    assert_size_stride(primals_1, (4,), (1,))
    assert_size_stride(primals_2, (4, 4, 4), (16, 4, 1))
    assert_size_stride(primals_3, (1, 4, 4), (16, 4, 1))
    assert_size_stride(primals_4, (1,), (1,))
    assert_size_stride(primals_5, (4, 4, 4), (16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 4, 4), (16, 4, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused_clone_0[grid(64)](primals_1, buf0, 64, XBLOCK=64,
            num_warps=1, num_stages=1)
        del primals_1
        buf1 = torch.ops.aten._trilinear.default(reinterpret_tensor(
            primals_2, (16, 4), (4, 1), 0), primals_3, reinterpret_tensor(
            buf0, (16, 4), (4, 1), 0), [1, 3], [0], [1, 2], [2, 3])
        buf2 = buf1
        del buf1
        buf3 = torch.ops.aten._trilinear.default(reinterpret_tensor(
            primals_5, (16, 4), (4, 1), 0), primals_3, reinterpret_tensor(
            buf0, (16, 4), (4, 1), 0), [1, 3], [0], [1, 2], [2, 3])
        del primals_3
        buf4 = buf3
        del buf3
        buf5 = empty_strided_cuda((4, 8), (8, 1), torch.float32)
        triton_poi_fused_cat_1[grid(32)](buf2, primals_4, buf4, buf5, 32,
            XBLOCK=32, num_warps=1, num_stages=1)
        del buf2
        del buf4
        del primals_4
    return buf5, reinterpret_tensor(primals_2, (16, 4), (4, 1), 0
        ), reinterpret_tensor(buf0, (16, 4), (4, 1), 0), reinterpret_tensor(
        primals_5, (16, 4), (4, 1), 0)


class DiscriminatorNew(nn.Module):

    def __init__(self, n_h):
        super(DiscriminatorNew, self).__init__()
        self.f_k = nn.Bilinear(n_h, n_h, 1)
        for m in self.modules():
            self.weights_init(m)

    def weights_init(self, m):
        if isinstance(m, nn.Bilinear):
            torch.nn.init.xavier_uniform_(m.weight.data)
            if m.bias is not None:
                m.bias.data.fill_(0.0)

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


Measured latency_ms: 0.014676