-
Notifications
You must be signed in to change notification settings - Fork 240
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
[Good First Issue][NNCF][TorchFX]: Test model transformer #2775
Comments
.take |
Thank you for looking into this issue! Please let us know if you have any questions or require any help. |
.take |
Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. Please communicate with the assigned contributor to confirm the status of the issue. |
@daniil-lyakhov Hi, Could you please push your branch before merging it into the develop branch? This will allow me to develop based on your branch. Additionally, I noticed the file tests/torch/fx/test_sanity.py. Should I implement the unit tests in tests/torch/fx/test_model_transformer.py instead of tests/torch_fx/test_model_transformer.py? Thank you! |
Hi @awayzjj, Thank you for your contribution! PR is on review right now and should be merged soon, I'll keep you updated. Yes, please use tests/torch/fx directory, I forgot to update the issue. Thanks! |
@daniil-lyakhov Hi, I attempted to implement the import torch
import torch.nn.functional as F
from torch import nn
from torch._export import capture_pre_autograd_graph
from nncf.common.graph.transformations.commands import TargetType
from nncf.common.graph.transformations.layout import TransformationLayout
def test_leaf_module_insertion_transformation():
class InsertionPointTestModel(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(1, 1, 1, 1)
self.linear_wts = nn.Parameter(torch.FloatTensor(size=(100, 100)))
self.conv2 = nn.Conv2d(1, 1, 1, 1)
self.relu = nn.ReLU()
def forward(self, input_):
x = self.conv1(input_)
x = x.flatten()
x = nn.functional.linear(x, self.linear_wts)
x = x.reshape((1, 1, 10, 10))
x = self.conv2(x)
x = self.relu(x)
return x
model = InsertionPointTestModel()
with torch.no_grad():
ex_input = torch.ones([1, 1, 10, 10])
model.eval()
exported_model = capture_pre_autograd_graph(model, args=(ex_input,))
print(exported_model.print_readable())
from nncf.experimental.torch.fx.model_transformer import FXModelTransformer
from nncf.torch.graph.transformations.commands import PTTargetPoint
from nncf.experimental.torch.fx.transformations import leaf_module_insertion_transformation_builder
from nncf.experimental.torch.fx.commands import FXApplyTransformationCommand
model_transformer = FXModelTransformer(exported_model)
conv1_node_name = "InsertionPointTestModel/NNCFConv2d[conv1]/conv2d_0"
target_point = PTTargetPoint(
target_type=TargetType.OPERATION_WITH_WEIGHTS, target_node_name=conv1_node_name, input_port_id=1
)
transformation = leaf_module_insertion_transformation_builder(
exported_model, [target_point]
)
command = FXApplyTransformationCommand(
transformation
)
transformation_layout = TransformationLayout()
transformation_layout.register(command)
model_transformer.transform(transformation_layout)
Could you give me some suggestions? Thank you very much! |
@awayzjj you defined the variable |
@rk119 Thank you so much! Your suggestions does work! |
@daniil-lyakhov Hi, I've been really busy lately, so I've decided to unassign myself for now. I apologize for any inconvenience this may cause. |
@awayzjj, that's ok, thank you for letting us know! |
PR #2920 |
.take |
Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. Please communicate with the assigned contributor to confirm the status of the issue. |
@zina-cs, sorry for inconvenience, but this good first issue should have been closed already. Big sorry 🙁 |
### Changes Model transformation tests are presented ### Reason for changes To cover TorchFX model transformations by tests ### Related tickets #2775 ### Tests * test_model_insertion_transformation * test_constant_update_transformation * test_constant_update_transformation_no_constant * TestQDQInsertion * test_node_removal_transformation
Greetings🐱! As a part of #2766 TorchFX PTQ backend support, we are gladly presenting to you following issue
Context
The task is to cover FXModelTransformer by simple unit tests as it done for other backends:
https://github.com/openvinotoolkit/nncf/blob/develop/tests/onnx/test_model_transformer.py
What needs to be done?
Unit tests in file
tests/torch/fx/test_model_transformer.py
:Example Pull Requests
No response
Resources
Contact points
@daniil-lyakhov
Ticket
141640
The text was updated successfully, but these errors were encountered: