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

RuntimeError: unsupported operation type: LayerChoice ? None #3686

Closed
duchengyao opened this issue May 27, 2021 · 2 comments
Closed

RuntimeError: unsupported operation type: LayerChoice ? None #3686

duchengyao opened this issue May 27, 2021 · 2 comments

Comments

@duchengyao
Copy link

duchengyao commented May 27, 2021

Describe the issue:

When trying to run Pure-python execution engine by the following code:

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        hidden_size = 128
        self.fc = nn.LayerChoice([
            nn.Linear(4 * 4 * 50, hidden_size),
            nn.Linear(4 * 4 * 50, hidden_size, bias=False)
        ])

    def forward(self, x):
        return self.fc(x)


def submit_model(model):
    _ = codegen.model_to_pytorch_script(model)
    data = BaseGraphData(_, model.evaluator)
    print(data)
    print(data.dump())


if __name__ == '__main__':
    base_model = Net()
    base_model_ir, mutators = extract_mutation_from_pt_module(base_model)
    # handle inline mutations
    search_space = dry_run_for_search_space(base_model_ir, mutators)
    for sample in random_generator(search_space):
        submit_model(get_targeted_model(base_model_ir, mutators, sample))

an error raised:

    _ = codegen.model_to_pytorch_script(model)
  File "/xxx/retiarii/codegen/pytorch.py", line 16, in model_to_pytorch_script
    import_pkgs, graph_code = graph_to_pytorch_model(name, cell, placement=placement)
  File "/xxxretiarii/codegen/pytorch.py", line 139, in graph_to_pytorch_model
    edge_codes.append(node.operation.to_forward_code(submodule_name, node_name, inputs, inputs_value))
  File "xxx/operation.py", line 159, in to_forward_code
    raise RuntimeError(f'unsupported operation type: {self.type} ? {self._to_class_name()}')
RuntimeError: unsupported operation type: LayerChoice ? None

I found the to_forward_code function seems to be always RuntimeError.

        if self.type == 'aten::slice':
            raise RuntimeError('not supposed to have aten::slice operation')
        else:
            raise RuntimeError(f'unsupported operation type: {self.type} ? {self._to_class_name()}')

Is this function to be not finished yet? @ultmaster

Regards,

Environment:

  • NNI version: master
@ultmaster
Copy link
Contributor

You don't need codegen for python execution engine.

And this is not what we expect most users would do. See the source code of py engine and tests if you insist on doing all the hacking staff.

@duchengyao
Copy link
Author

Thanks so much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants