Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update adaround_optimizer.py #3709

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def _optimize_rounding(cls, module: ModuleInfo, quantized_input_name,
else:
model_inputs = cached_dataset[np.random.randint(len(cached_dataset))]
inp_data, orig_out_data = act_sampler.sample_acts(create_input_dict(orig_model.model, model_inputs))
inp_data, orig_out_data = torch.from_numpy(inp_data[0]).to(torch_device), torch.from_numpy(out_data[0]).to(torch_device)
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not understand one aspect of the change. There are two parts to the change - 1. we are converting numpy tensors to torch, 2. we are placing the torch tensors on a device.

How does the rest of the code work if we are now passing torch tensors instead of numpy?

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the code expects a torch tensor on the correct device, since it is using torch to backprop through the layer

# This assumes there's only 1 input and 1 output in the list output by sample_acts


# Clear alpha's gradients before optimization step
Expand Down
Loading