def test_cannot_set_shape_preallocated_memory(): tensor_desc = TensorDesc("FP32", [1, 3, 127, 127], "NHWC") array = np.ones([1, 3, 127, 127], dtype=np.float32) blob = Blob(tensor_desc, array) with pytest.raises(RuntimeError) as e: blob.set_shape([1, 4, 128, 128]) assert "Cannot call setShape for Blobs created on top of preallocated memory" in str(e.value)
def test_set_shape(): tensor_desc = TensorDesc("FP32", [1, 3, 127, 127], "NHWC") blob = Blob(tensor_desc) blob.set_shape([1, 4, 128, 128]) assert blob.tensor_desc.dims == [1, 4, 128, 128] assert blob.buffer.shape == (1, 4, 128, 128) array = np.ones([1, 3, 127, 127], dtype=np.float32) blob = Blob(tensor_desc, array) blob.set_shape([1, 4, 128, 128]) assert blob.tensor_desc.dims == [1, 4, 128, 128] assert blob.buffer.shape == (1, 4, 128, 128)
def test_set_shape(): tensor_desc = TensorDesc("FP32", [1, 3, 127, 127], "NHWC") blob = Blob(tensor_desc) blob.set_shape([1, 4, 128, 128]) assert blob.tensor_desc.dims == [1, 4, 128, 128] assert blob.buffer.shape == (1, 4, 128, 128)