10d7ece1c34c5533262a54d20d974a3d04f0b7ce,src/sdk/pynni/nni/compression/tensorflow/compressor.py,,_instrument_model,#Any#Any#,289

Before Change



def _instrument_model(model, wrappers):
    // Replace layers to wrappers
    for wrapper in reversed(wrappers):
        cur = model
        for key in wrapper.layer_info.path[:-1]:
            if isinstance(key, str):
                cur = getattr(cur, key)
            else:
                name, index = key
                cur = getattr(cur, name)[index]
        key = wrapper.layer_info.path[-1]
        if isinstance(key, str):
            setattr(cur, key, wrapper)
        else:
            name, index = key
            getattr(cur, name)[index] = wrapper
            //if isinstance(cur, tf.keras.Sequential):
            //    cur._graph_initialized = False
            //    cur._layer_call_argspecs[wrapper] = cur._layer_call_argspecs[wrapper.layer]

After Change


            elif isinstance(value, list):
                for i, item in enumerate(value):
                    if isinstance(item, tf.keras.layers.Layer):
                        value[i] = self._instrument(item)
        return model

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: microsoft/nni
Commit Name: 10d7ece1c34c5533262a54d20d974a3d04f0b7ce
Time: 2020-09-15
Author: 40699903+liuzhe-lz@users.noreply.github.com
File Name: src/sdk/pynni/nni/compression/tensorflow/compressor.py
Class Name:
Method Name: _instrument_model


Project Name: deepmipt/DeepPavlov
Commit Name: f4e50dc7b68d5fde864430dd11f7fa59e85ce887
Time: 2018-01-18
Author: ol.gure@gmail.com
File Name: deeppavlov/core/common/params.py
Class Name:
Method Name: from_params


Project Name: hanxiao/bert-as-service
Commit Name: d0eddfd7882f053bd6d6b6a7b0305f5c42d5d39f
Time: 2019-01-21
Author: hanhxiao@tencent.com
File Name: benchmark.py
Class Name:
Method Name:


Project Name: microsoft/nni
Commit Name: 10d7ece1c34c5533262a54d20d974a3d04f0b7ce
Time: 2020-09-15
Author: 40699903+liuzhe-lz@users.noreply.github.com
File Name: src/sdk/pynni/nni/compression/tensorflow/compressor.py
Class Name:
Method Name: _instrument_model