Skip to content

Commit

Permalink
[Python API] Support of FP16 blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
akuporos authored and anastasia.kuporosova committed Jan 25, 2021
1 parent a555908 commit a7e727e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ cdef class Blob:
fp64_array_memview = self._array_data
self._ptr = C.make_shared_blob[double](c_tensor_desc, &fp64_array_memview[0], fp64_array_memview.shape[0])
elif precision == "FP16":
raise RuntimeError("Currently, it's impossible to set_blob with FP16 precision")
I16_array_memview = self._array_data.view(dtype=np.int16)
self._ptr = C.make_shared_blob[int16_t](c_tensor_desc, &I16_array_memview[0], I16_array_memview.shape[0])
elif precision == "I16":
I16_array_memview = self._array_data
self._ptr = C.make_shared_blob[int16_t](c_tensor_desc, &I16_array_memview[0], I16_array_memview.shape[0])
Expand Down Expand Up @@ -206,7 +207,7 @@ cdef class Blob:
representation_shape = self._initial_shape if self._initial_shape is not None else []
cdef BlobBuffer buffer = BlobBuffer()
buffer.reset(self._ptr, representation_shape)
return buffer.to_numpy()
return buffer.to_numpy()

## TensorDesc of created Blob
@property
Expand Down
1 change: 0 additions & 1 deletion inference-engine/ie_bridges/python/tests/test_Blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def test_write_to_buffer_fp64():
assert np.array_equal(blob.buffer, ones_arr)


@pytest.mark.skip(reason="Need to figure out how to implement right conversion")
def test_write_to_buffer_fp16():
tensor_desc = TensorDesc("FP16", [1, 3, 127, 127], "NCHW")
array = np.zeros(shape=(1, 3, 127, 127), dtype=np.float16)
Expand Down

0 comments on commit a7e727e

Please sign in to comment.