Пример #1
0
def test_general():
    for condition_custom in [{}, {"x_order": OrderNCHW}]:
        condition = dict(condition_default)
        condition.update(condition_custom)

        vx = np.random.rand(2, 3, 4, 5) - 0.5
        vy = vx * (vx > 0)

        x = Variable(vx.shape, order=OrderNHWC)
        y, = Relu(None)(x)

        x.change_order(condition["x_order"])
        y.change_order(condition["y_order"])

        generate_kernel_test_case(
            description=f"Relu: " +
            (", ".join([f"{k}={v}" for k, v in condition_custom.items()])),
            backend=condition["backend"],
            graph=Graph([x], [y]),
            inputs={
                x: ConstantVariable(vx, OrderNHWC).change_order(x.order).data
            },
            expected={
                y: ConstantVariable(vy, OrderNHWC).change_order(y.order).data
            },
            raise_skip=False)

    raise SkipTest
Пример #2
0
def template(x_order=OrderNHWC,
             x_shape=(2, 3, 4, 5),
             y_order=OrderNHWC,
             description: str = ""):
    vx = np.random.rand(*x_shape) - 0.5
    vy = vx * (vx > 0)

    x = Variable(vx.shape, order=x_order)
    y, = Relu(None)(x)
    y.change_order(y_order)

    generate_kernel_test_case(
        description=f"Relu {description}",
        graph=Graph([x], [y]),
        inputs={x: vx},
        expected={
            y: np.transpose(vy, [x_order.axes_dict[a] for a in y_order.axes])
        },
    )