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
from torch._inductor.runtime.triton_helpers import math as tl_math
import torch.nn as nn
import torch.utils
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__log_softmax_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
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp4 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = triton_helpers.maximum(tmp1, tmp2)
    tmp5 = triton_helpers.maximum(tmp3, tmp4)
    tmp7 = triton_helpers.maximum(tmp5, tmp6)
    tmp8 = tmp0 - tmp7
    tl.store(out_ptr0 + x3, tmp8, xmask)


@triton.jit
def triton_poi_fused__log_softmax_neg_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
    x3 = xindex
    x0 = xindex % 16
    x2 = xindex // 64
    tmp0 = tl.load(in_ptr0 + x3, xmask)
    tmp1 = tl.load(in_ptr0 + (x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp3 = tl.load(in_ptr0 + (16 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp6 = tl.load(in_ptr0 + (32 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp9 = tl.load(in_ptr0 + (48 + x0 + 64 * x2), xmask, eviction_policy=
        'evict_last')
    tmp2 = tl_math.exp(tmp1)
    tmp4 = tl_math.exp(tmp3)
    tmp5 = tmp2 + tmp4
    tmp7 = tl_math.exp(tmp6)
    tmp8 = tmp5 + tmp7
    tmp10 = tl_math.exp(tmp9)
    tmp11 = tmp8 + tmp10
    tmp12 = tl_math.log(tmp11)
    tmp13 = tmp0 - tmp12
    tmp14 = -tmp13
    tl.store(out_ptr0 + x3, tmp14, xmask)


@triton.jit
def triton_poi_fused_index_2(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (x1 + 16 * y0), xmask & ymask, eviction_policy
        ='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_index_3(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (64 + x1 + 16 * y0), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_index_4(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (128 + x1 + 16 * y0), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_index_5(in_ptr0, out_ptr0, ynumel, xnumel, YBLOCK: tl.
    constexpr, XBLOCK: tl.constexpr):
    ynumel = 4
    xnumel = 16
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = yindex < ynumel
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x1 = xindex
    y0 = yindex
    tmp0 = tl.load(in_ptr0 + (192 + x1 + 16 * y0), xmask & ymask,
        eviction_policy='evict_last')
    tl.store(out_ptr0 + (y0 + 4 * x1), tmp0, xmask & ymask)


@triton.jit
def triton_poi_fused_add_div_6(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2,
    xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    tmp0 = tl.load(in_ptr0 + 0)
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK])
    tmp6 = tl.load(in_ptr1 + 0)
    tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
    tmp10 = tl.load(in_out_ptr0 + 0)
    tmp11 = tl.broadcast_to(tmp10, [XBLOCK])
    tmp14 = tl.load(in_ptr2 + 0)
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK])
    tmp2 = 0.0625
    tmp3 = tmp1 * tmp2
    tmp4 = 0.0
    tmp5 = tmp3 + tmp4
    tmp8 = tmp7 * tmp2
    tmp9 = tmp5 + tmp8
    tmp12 = tmp11 * tmp2
    tmp13 = tmp9 + tmp12
    tmp16 = tmp15 * tmp2
    tmp17 = tmp13 + tmp16
    tl.store(in_out_ptr0 + tl.full([XBLOCK], 0, tl.int32), tmp17, None)


def call(args):
    arg0_1, arg1_1 = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(arg1_1, (4, 4, 4, 4), (64, 16, 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__log_softmax_0[grid(256)](arg0_1, buf0, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del arg0_1
        buf1 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.float32)
        triton_poi_fused__log_softmax_neg_1[grid(256)](buf0, buf1, 256,
            XBLOCK=128, num_warps=4, num_stages=1)
        del buf0
        buf2 = empty_strided_cuda((1, 4, 4, 4), (64, 1, 16, 4), torch.float32)
        triton_poi_fused_index_2[grid(4, 16)](buf1, buf2, 4, 16, XBLOCK=16,
            YBLOCK=4, num_warps=1, num_stages=1)
        buf3 = empty_strided_cuda((1, 4, 4, 4), (64, 1, 16, 4), torch.float32)
        triton_poi_fused_index_2[grid(4, 16)](arg1_1, buf3, 4, 16, XBLOCK=
            16, YBLOCK=4, num_warps=1, num_stages=1)
        buf4 = extern_kernels.convolution(buf2, buf3, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf4, (1, 1, 1, 1), (1, 1, 1, 1))
        buf5 = buf3
        del buf3
        triton_poi_fused_index_3[grid(4, 16)](buf1, buf5, 4, 16, XBLOCK=16,
            YBLOCK=4, num_warps=1, num_stages=1)
        buf6 = buf2
        del buf2
        triton_poi_fused_index_3[grid(4, 16)](arg1_1, buf6, 4, 16, XBLOCK=
            16, YBLOCK=4, num_warps=1, num_stages=1)
        buf7 = extern_kernels.convolution(buf5, buf6, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf7, (1, 1, 1, 1), (1, 1, 1, 1))
        buf8 = buf6
        del buf6
        triton_poi_fused_index_4[grid(4, 16)](buf1, buf8, 4, 16, XBLOCK=16,
            YBLOCK=4, num_warps=1, num_stages=1)
        buf9 = buf5
        del buf5
        triton_poi_fused_index_4[grid(4, 16)](arg1_1, buf9, 4, 16, XBLOCK=
            16, YBLOCK=4, num_warps=1, num_stages=1)
        buf10 = extern_kernels.convolution(buf8, buf9, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf10, (1, 1, 1, 1), (1, 1, 1, 1))
        buf11 = buf9
        del buf9
        triton_poi_fused_index_5[grid(4, 16)](buf1, buf11, 4, 16, XBLOCK=16,
            YBLOCK=4, num_warps=1, num_stages=1)
        del buf1
        buf12 = buf8
        del buf8
        triton_poi_fused_index_5[grid(4, 16)](arg1_1, buf12, 4, 16, XBLOCK=
            16, YBLOCK=4, num_warps=1, num_stages=1)
        del arg1_1
        buf13 = extern_kernels.convolution(buf11, buf12, stride=(1, 1),
            padding=(0, 0), dilation=(1, 1), transposed=False,
            output_padding=(0, 0), groups=1, bias=None)
        assert_size_stride(buf13, (1, 1, 1, 1), (1, 1, 1, 1))
        del buf11
        del buf12
        buf14 = buf10
        del buf10
        triton_poi_fused_add_div_6[grid(1)](buf14, buf4, buf7, buf13, 1,
            XBLOCK=1, num_warps=1, num_stages=1)
        del buf13
        del buf4
        del buf7
    return buf14,


class SoftCrossEntropyLoss2dNew(nn.Module):

    def __init__(self):
        super(SoftCrossEntropyLoss2dNew, self).__init__()

    def forward(self, input_0, input_1):
        arg0_1 = input_0
        arg1_1 = input_1
        output = call([arg0_1, arg1_1])
        return output[0]


Measured latency_ms: 0.210464