Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

[quantization speedup]fix data device type bug #3856

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

linbinskn
Copy link
Contributor

This PR is for fixing data's device type which has to be "cpu". Otherwise, it can not convert to numpy directly and will raise errors.

@QuanluZhang QuanluZhang requested a review from J-shang June 21, 2021 10:37
@@ -326,6 +329,8 @@ def inference(self, test_data):
Model input tensor
"""
# convert pytorch tensor to numpy darray
if test_data.device != torch.device("cpu"):
test_data = test_data.to("cpu")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is a little strange that inference can only be executed on cpu... why?

Copy link
Contributor Author

@linbinskn linbinskn Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Actually the inference executed on GPU after the memory copy from host memory to device memory which is done in our tool and the process of host2device memory copy is unavoidable. We use pycuda' s memcpy_htod_async api to do such copy. It is just a way of unifying that we choose to handle all host data and we will do memory copy in our engine before calibration and inference. We can also take another to handle it such as finding other way or API which can use torch' s cuda type data directly. However, it will be more complicated and no extra advantage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, got it

@QuanluZhang QuanluZhang merged commit 27e123d into microsoft:master Jun 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants