Example #1
0
def test_exact_dict3():
    z = {"TotalIndices": 3, "ZeroPadA": [[1, 2, 6, 4]], "ZeroPadB": []}

    e = ExactDict({'sizes': [100, 200, 300], 'padStartA': [6]}, z)
    assert (e.sizes == [100, 200, 300])
    assert (e.zeroPadA == [[1, 2, 6, 4]])
    assert (e.stridesA == None)
Example #2
0
def test_exact_padend_mismatch():
    z = {"TotalIndices": 3, "ZeroPadA": [[1, 2, 3, 4]], "ZeroPadB": []}

    with pytest.raises(
            RuntimeError,
            match="problem-specified padEndA==7 does not match problem-type==4"
    ):
        ExactDict({'sizes': [100, 200, 300], 'padEndA': [7]}, z)
Example #3
0
def test_exact_dict2():
    e = ExactDict({
        'sizes': [100, 200, 300],
        'stridesA': [-1, 100, 1000]
    }, None)
    assert (e.sizes == [100, 200, 300])
    assert (e.stridesA == [-1, 100, 1000])
    assert (e.zeroPadA == [])
Example #4
0
def test_exact_padstart_left_tbd():
    z = {
        "TotalIndices": 3,
        "ZeroPadA": [[1, 2, -1, -1]],  # TBD pads should be specified at end:
        "ZeroPadB": []
    }
    #with pytest.raises(RuntimeError, match="RuntimeError:.*"):
    with pytest.raises(RuntimeError):
        ExactDict({'sizes': [100, 200, 300], 'stridesA': [-1, 100, 1000]}, z)
Example #5
0
def test_exact_override_pad_tbd():
    z = {"TotalIndices": 3, "ZeroPadA": [[1, 2, -1, -1]], "ZeroPadB": []}

    e = ExactDict({
        'sizes': [100, 200, 300],
        'padStartA': [6],
        'padEndA': [7]
    }, z)
    assert (e.sizes == [100, 200, 300])
    assert (e.zeroPadA == [[1, 2, 6, 7]])
    assert (e.stridesA == None)
Example #6
0
def test_exact_override_pad_tbd_multi_pad_b():
    z = {
        "TotalIndices": 3,
        "ZeroPadA": [],
        "ZeroPadB": [[1, 2, -1, -1], [4, 5, -1, -1]],
    }

    e = ExactDict(
        {
            'sizes': [100, 200, 300],
            'padStartB': [6, 66],
            'padEndB': [7, 77]
        }, z)
    assert (e.sizes == [100, 200, 300])
    assert (e.zeroPadB == [[1, 2, 6, 7], [4, 5, 66, 77]])
    assert (e.stridesA == None)