Beispiel #1
0
def test_relu_inplace(seed, ctx, func_name):
    from nbla_test_utils import inplace_function_test_helper
    x = nn.Variable([2, 3, 4], need_grad=True)
    inplace_function_test_helper([x],
                                 F.relu,
                                 ctx=ctx,
                                 rng=np.random.RandomState(seed))
Beispiel #2
0
def test_add2_inplace(seed, ctx, func_name):
    from nbla_test_utils import inplace_function_test_helper
    x0 = nn.Variable([2, 3, 4], need_grad=True)
    x1 = nn.Variable([2, 3, 4], need_grad=True)
    inplace_function_test_helper([x0, x1],
                                 F.add2,
                                 ctx=ctx,
                                 rng=np.random.RandomState(seed))
Beispiel #3
0
def test_reshpae_inplace(seed, ctx, func_name, inshape, outshape):
    from nbla_test_utils import inplace_function_test_helper
    rng = np.random.RandomState(seed)
    inputs = [nn.Variable.from_numpy_array(
        rng.randn(*inshape).astype(np.float32))]
    inplace_function_test_helper(
        inputs, F.reshape, func_args=[
            outshape], ctx=ctx, rng=np.random.RandomState(seed))
Beispiel #4
0
def test_add_scalar_inplace(seed, val, ctx, func_name):
    from nbla_test_utils import inplace_function_test_helper
    rng = np.random.RandomState(seed)
    x = nn.Variable([2, 3, 4], need_grad=True)
    inplace_function_test_helper([x],
                                 F.add_scalar,
                                 func_args=[val],
                                 ctx=ctx,
                                 rng=rng)
Beispiel #5
0
def test_transform_binary_inplace(seed, fname, ctx, func_name):
    from nbla_test_utils import inplace_function_test_helper
    x0 = nn.Variable([2, 3, 4], need_grad=True)
    x1 = nn.Variable([2, 3, 4], need_grad=True)
    func = getattr(F, fname)
    inplace_function_test_helper([x0, x1],
                                 func,
                                 ctx=ctx,
                                 rng=np.random.RandomState(seed))
Beispiel #6
0
def test_relu_inplace(seed, ctx, func_name):
    from nbla_test_utils import inplace_function_test_helper
    x = nn.Variable([2, 3, 4], need_grad=True)
    inplace_function_test_helper(
        [x], F.relu, ctx=ctx, rng=np.random.RandomState(seed))