import torch
import torch.nn as nn


class DataProcessor(nn.Module):

    def __init__(self):
        super(DataProcessor, self).__init__()
        self.pool = nn.AdaptiveAvgPool2d((7, 7))

    def forward(self, x):
        x = self.pool(x)
        x = torch.squeeze(x)
        x = x.permute(1, 2, 0)
        return x.view(-1, x.size(-1))


def get_inputs():
    return [torch.rand([4, 4, 4])]


def get_init_inputs():
    return [[], {}]

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.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__adaptive_avg_pool2d_0(in_ptr0, out_ptr0, xnumel,
    XBLOCK: tl.constexpr):
    xnumel = 196
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 7 % 7
    x0 = xindex % 7
    x2 = xindex // 49
    x4 = xindex
    tmp0 = 4 * x1 // 7
    tmp1 = (10 + 4 * x1) // 7
    tmp2 = tmp0 < tmp1
    tmp3 = 4 * x0 // 7
    tmp4 = (10 + 4 * x0) // 7
    tmp5 = tmp3 < tmp4
    tmp6 = tmp2 & tmp5
    tmp7 = tl.load(in_ptr0 + (4 * (4 * x1 // 7) + 16 * x2 + 4 * x0 // 7), 
        tmp6 & xmask, eviction_policy='evict_last', other=0.0)
    tmp8 = 1 + 4 * x0 // 7
    tmp9 = tmp8 < tmp4
    tmp10 = tmp2 & tmp9
    tmp11 = tl.load(in_ptr0 + (1 + 4 * (4 * x1 // 7) + 16 * x2 + 4 * x0 // 
        7), tmp10 & xmask, eviction_policy='evict_last', other=0.0)
    tmp12 = tmp11 + tmp7
    tmp13 = 1 + 4 * x1 // 7
    tmp14 = tmp13 < tmp1
    tmp15 = tmp14 & tmp5
    tmp16 = tl.load(in_ptr0 + (4 + 4 * (4 * x1 // 7) + 16 * x2 + 4 * x0 // 
        7), tmp15 & xmask, eviction_policy='evict_last', other=0.0)
    tmp17 = tmp16 + tmp12
    tmp18 = tmp14 & tmp9
    tmp19 = tl.load(in_ptr0 + (5 + 4 * (4 * x1 // 7) + 16 * x2 + 4 * x0 // 
        7), tmp18 & xmask, eviction_policy='evict_last', other=0.0)
    tmp20 = tmp19 + tmp17
    tmp21 = 1.0
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp6, tmp21, tmp22)
    tmp24 = tl.where(tmp10, tmp21, tmp22)
    tmp25 = tmp24 + tmp23
    tmp26 = tl.where(tmp15, tmp21, tmp22)
    tmp27 = tmp26 + tmp25
    tmp28 = tl.where(tmp18, tmp21, tmp22)
    tmp29 = tmp28 + tmp27
    tmp30 = tmp20 / tmp29
    tl.store(out_ptr0 + x4, tmp30, xmask)


def call(args):
    arg0_1, = args
    args.clear()
    assert_size_stride(arg0_1, (4, 4, 4), (16, 4, 1))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = empty_strided_cuda((4, 7, 7), (49, 7, 1), torch.float32)
        get_raw_stream(0)
        triton_poi_fused__adaptive_avg_pool2d_0[grid(196)](arg0_1, buf0, 
            196, XBLOCK=256, num_warps=4, num_stages=1)
        del arg0_1
    return reinterpret_tensor(buf0, (49, 4), (1, 49), 0),


class DataProcessorNew(nn.Module):

    def __init__(self):
        super(DataProcessorNew, self).__init__()
        self.pool = nn.AdaptiveAvgPool2d((7, 7))

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