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.triton_helpers import math as tl_math
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_abs_exp_neg_sub_sum_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
    x2 = xindex
    x0 = xindex % 4
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + 4 * x2, xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (1 + 4 * x2), xmask, eviction_policy='evict_last')
    tmp5 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp9 = tl.load(in_ptr0 + (2 + 4 * x2), xmask, eviction_policy='evict_last')
    tmp10 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp14 = tl.load(in_ptr0 + (3 + 4 * x2), xmask, eviction_policy='evict_last'
        )
    tmp15 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp21 = tl.load(in_ptr0 + (16 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp24 = tl.load(in_ptr0 + (17 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp28 = tl.load(in_ptr0 + (18 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp32 = tl.load(in_ptr0 + (19 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp39 = tl.load(in_ptr0 + (32 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp42 = tl.load(in_ptr0 + (33 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp46 = tl.load(in_ptr0 + (34 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp50 = tl.load(in_ptr0 + (35 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp57 = tl.load(in_ptr0 + (48 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp60 = tl.load(in_ptr0 + (49 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp64 = tl.load(in_ptr0 + (50 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp68 = tl.load(in_ptr0 + (51 + 4 * x0), xmask, eviction_policy=
        'evict_last')
    tmp2 = tmp0 - tmp1
    tmp3 = tl_math.abs(tmp2)
    tmp6 = tmp4 - tmp5
    tmp7 = tl_math.abs(tmp6)
    tmp8 = tmp3 + tmp7
    tmp11 = tmp9 - tmp10
    tmp12 = tl_math.abs(tmp11)
    tmp13 = tmp8 + tmp12
    tmp16 = tmp14 - tmp15
    tmp17 = tl_math.abs(tmp16)
    tmp18 = tmp13 + tmp17
    tmp19 = -tmp18
    tmp20 = tl_math.exp(tmp19)
    tmp22 = tmp0 - tmp21
    tmp23 = tl_math.abs(tmp22)
    tmp25 = tmp4 - tmp24
    tmp26 = tl_math.abs(tmp25)
    tmp27 = tmp23 + tmp26
    tmp29 = tmp9 - tmp28
    tmp30 = tl_math.abs(tmp29)
    tmp31 = tmp27 + tmp30
    tmp33 = tmp14 - tmp32
    tmp34 = tl_math.abs(tmp33)
    tmp35 = tmp31 + tmp34
    tmp36 = -tmp35
    tmp37 = tl_math.exp(tmp36)
    tmp38 = tmp20 + tmp37
    tmp40 = tmp0 - tmp39
    tmp41 = tl_math.abs(tmp40)
    tmp43 = tmp4 - tmp42
    tmp44 = tl_math.abs(tmp43)
    tmp45 = tmp41 + tmp44
    tmp47 = tmp9 - tmp46
    tmp48 = tl_math.abs(tmp47)
    tmp49 = tmp45 + tmp48
    tmp51 = tmp14 - tmp50
    tmp52 = tl_math.abs(tmp51)
    tmp53 = tmp49 + tmp52
    tmp54 = -tmp53
    tmp55 = tl_math.exp(tmp54)
    tmp56 = tmp38 + tmp55
    tmp58 = tmp0 - tmp57
    tmp59 = tl_math.abs(tmp58)
    tmp61 = tmp4 - tmp60
    tmp62 = tl_math.abs(tmp61)
    tmp63 = tmp59 + tmp62
    tmp65 = tmp9 - tmp64
    tmp66 = tl_math.abs(tmp65)
    tmp67 = tmp63 + tmp66
    tmp69 = tmp14 - tmp68
    tmp70 = tl_math.abs(tmp69)
    tmp71 = tmp67 + tmp70
    tmp72 = -tmp71
    tmp73 = tl_math.exp(tmp72)
    tmp74 = tmp56 + tmp73
    tl.store(out_ptr0 + (x0 + 68 * x1), tmp74, xmask)


@triton.jit
def triton_poi_fused_cat_1(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
    x2 = xindex
    x0 = xindex % 64
    x1 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x2, xmask)
    tl.store(out_ptr0 + (x0 + 68 * x1), tmp0, xmask)


def call(args):
    primals_1, primals_2 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (64, 16), (16, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 16), (16, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(primals_1, (4, 64), (64, 1), 0
            ), primals_2, out=buf0)
        del primals_2
        buf3 = empty_strided_cuda((4, 68), (68, 1), torch.float32)
        buf1 = reinterpret_tensor(buf3, (4, 4), (68, 1), 64)
        get_raw_stream(0)
        triton_poi_fused_abs_exp_neg_sub_sum_0[grid(16)](buf0, buf1, 16,
            XBLOCK=16, num_warps=1, num_stages=1)
        buf2 = reinterpret_tensor(buf3, (4, 64), (68, 1), 0)
        triton_poi_fused_cat_1[grid(256)](primals_1, buf2, 256, XBLOCK=128,
            num_warps=4, num_stages=1)
    return buf3, buf0, reinterpret_tensor(primals_1, (64, 4), (1, 64), 0)


class minibatch_discriminatorNew(nn.Module):

    def __init__(self, num_channels, B_dim, C_dim):
        super(minibatch_discriminatorNew, self).__init__()
        self.B_dim = B_dim
        self.C_dim = C_dim
        self.num_channels = num_channels
        T_init = torch.randn(num_channels * 4 * 4, B_dim * C_dim) * 0.1
        self.T_tensor = nn.Parameter(T_init, requires_grad=True)

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


Measured latency_ms: 0.033898