def test_build_rule_syft_tensors_and_pointers():
    pointer = PointerTensor(id=1000,
                            location="location",
                            owner="owner",
                            garbage_collect_data=False)
    result = hook_args.build_rule(([torch.tensor([1, 2]), pointer], 42))
    assert result == ([1, 1], 0)
Exemple #2
0
def test_build_get_child_type():
    from syft.generic.frameworks.hook.hook_args import build_rule
    from syft.generic.frameworks.hook.hook_args import build_get_tensor_type

    x = torch.Tensor([1, 2, 3])
    args = (x, [[1, x]])
    rule = build_rule(args)

    get_child_type_function = build_get_tensor_type(rule)
    tensor_type = get_child_type_function(args)

    assert tensor_type == torch.Tensor
Exemple #3
0
def test_build_rule_numpy():
    arr = np.array([2.0, 3.0, 4.0])
    result = hook_args.build_rule([arr, arr + 2, [2, 4, "string"]])
    assert result == [1, 1, [0, 0, 0]]