d3819b2941d22569389de4f2ce61da53c2e95c47,test/graph_builder_test/graph_test/operators_test/axiswise_bias_test.py,,test_every_order,#,12

Before Change



// FIXME 各orderをテストにわけられないか
def test_every_order():
    for order in [OrderC,
                  OrderNC,
                  OrderCN,
                  OrderNHWC,
                  OrderHWNC,
                  OrderHWCN,
                  OrderNCHW,
                  OrderCNHW,
                  OrderCHWN]:
        for axis in [Axis.C]:
            default_order = {
                1: OrderC,
                2: OrderNC,
                4: OrderNHWC,
                Axis.C: OrderC
            }

            op = AxiswiseBias("op", {"axis": axis})
            x = Variable(np.arange(order.ndim) + 1, default_order[order.ndim])
            w = Variable((x.shape_dict[axis],), default_order[axis])

            y, = op(x, w)

            for axis in y.axis_order.axes:
                assert y.shape_dict[axis] == x.shape_dict[axis]


@raises(AssertionError)
def test_invalid_size():
    op = AxiswiseBias("op", {"axis": Axis.C})

After Change


// FIXME 各orderをテストにわけられないか
def test_every_order():
    orders_x = [OrderNHWC, OrderHWNC, OrderHWCN, OrderNCHW, OrderCNHW, OrderCHWN]
    axes = [Axis.C]

    default_order = {
        1: OrderC,
        2: OrderNC,
        4: OrderNHWC,
        Axis.C: OrderC
    }

    for order_x, axis in itertools.product(orders_x, axes):
        if axis not in order_x.axes:
            continue

        op = AxiswiseBias("op", {"axis": axis})
        x = Variable(np.arange(order_x.ndim) + 1, default_order[order_x.ndim])
        x.change_axis_order(order_x)
        w = Variable((x.shape_dict[axis],), default_order[axis])

        y, = op(x, w)

        for axis in y.axis_order.axes:
            assert y.shape_dict[axis] == x.shape_dict[axis]


@raises(AssertionError)
def test_invalid_size():
    op = AxiswiseBias("op", {"axis": Axis.C})
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 11

Instances


Project Name: mil-tokyo/webdnn
Commit Name: d3819b2941d22569389de4f2ce61da53c2e95c47
Time: 2017-05-05
Author: y.kikura@gmail.com
File Name: test/graph_builder_test/graph_test/operators_test/axiswise_bias_test.py
Class Name:
Method Name: test_every_order


Project Name: mil-tokyo/webdnn
Commit Name: d3819b2941d22569389de4f2ce61da53c2e95c47
Time: 2017-05-05
Author: y.kikura@gmail.com
File Name: test/graph_builder_test/graph_test/operators_test/elementwise_sum_test.py
Class Name:
Method Name: test_every_order


Project Name: mil-tokyo/webdnn
Commit Name: d3819b2941d22569389de4f2ce61da53c2e95c47
Time: 2017-05-05
Author: y.kikura@gmail.com
File Name: test/graph_builder_test/graph_test/operators_test/linear_test.py
Class Name:
Method Name: test_every_order


Project Name: mil-tokyo/webdnn
Commit Name: d3819b2941d22569389de4f2ce61da53c2e95c47
Time: 2017-05-05
Author: y.kikura@gmail.com
File Name: test/graph_builder_test/graph_test/operators_test/axiswise_scale_test.py
Class Name:
Method Name: test_every_order