(self,
                 path,                      # type: str
                 decomposed=None,           # type: typing.Optional[typing.List[str]]
                 custom_operators=None,     # type: typing.Optional[typing.Dict[str, typing.Callable]]
                 activation_callback=None,  # type: typing.Optional[typing.Callable[[str, torch.Tensor], None]]
                 training_attributes=None,  # type: typing.Optional[typing.Dict[str, typing.Dict[str, typing.Any]]]
                 )
nnef_graph might be modified by this class if training and write_nnef is used
nnef_graph might be modified by this class if training and write_nnef is used
nnef_graph might be modified by this class if training and write_nnef is used
def __init__(self,
                 path,                      # type: str
                 decomposed=None,           # type: typing.Optional[typing.List[str]]
                 custom_operators=None,     # type: typing.Optional[typing.Dict[str, typing.Callable]]
                 activation_callback=None,  # type: typing.Optional[typing.Callable[[str, torch.Tensor], None]]
                 training_attributes=None,  # type: typing.Optional[typing.Dict[str, typing.Dict[str, typing.Any]]]
                 ):
        # type: (...)->None
        """
            nnef_graph might be modified by this class if training and write_nnef is used
        """
        super(NNEFModule, self).__init__()
        reader = nnef_io.Reader(decomposed=decomposed, infer_shapes=False)
        self._nnef_graph = reader(path)
        self._name_inline_constants(self._nnef_graph)

        for nnef_tensor in self._nnef_graph.tensors:
            if self._is_variable(nnef_tensor):
                name = self._registered_name(nnef_tensor.name)
                data = self._dequantize(nnef_tensor.data, nnef_tensor.quant) \
                    if nnef_tensor.quant else nnef_tensor.data
                self.register_parameter(name, torch.nn.Parameter(torch.tensor(self.normalize_dtype(data))))
            elif self._is_constant(nnef_tensor):
                name = self._registered_name(nnef_tensor.name)
                data = nnef_tensor.data if not nnef_tensor.producer else \
                    self._as_numpy(nnef_tensor.producer.attribs['value'],
                                   nnef_tensor.producer.attribs['shape'],
                                   nnef_tensor.producer.attribs['dtype']) \

                self.register_buffer(name, torch.tensor(self.normalize_dtype(data)))

        self._operators = {}
        self._operators.update(nnef_operators.Operators)
        if custom_operators:
            self._operators.update(custom_operators)
        self._activation_callback = activation_callback
        self._training_attributes = training_attributes or {}
def __init__ ( self , path , # type: str decomposed = None , # type: typing.Optional[typing.List[str]] custom_operators = None , # type: typing.Optional[typing.Dict[str, typing.Callable]] activation_callback = None , # type: typing.Optional[typing.Callable[[str, torch.Tensor], None]] training_attributes = None , # type: typing.Optional[typing.Dict[str, typing.Dict[str, typing.Any]]] ) : # type: (...)->None super ( NNEFModule , self ) . __init__ ( ) reader = nnef_io . Reader ( decomposed = decomposed , infer_shapes = False ) self . _nnef_graph = reader ( path ) self . _name_inline_constants ( self . _nnef_graph ) for nnef_tensor in self . _nnef_graph . tensors : if self . _is_variable ( nnef_tensor ) : name = self . _registered_name ( nnef_tensor . name ) data = self . _dequantize ( nnef_tensor . data , nnef_tensor . quant ) if nnef_tensor . quant else nnef_tensor . data self . register_parameter ( name , torch . nn . Parameter ( torch . tensor ( self . normalize_dtype ( data ) ) ) ) elif self . _is_constant ( nnef_tensor ) : name = self . _registered_name ( nnef_tensor . name ) data = nnef_tensor . data if not nnef_tensor . producer else self . _as_numpy ( nnef_tensor . producer . attribs [ 'value' ] , nnef_tensor . producer . attribs [ 'shape' ] , nnef_tensor . producer . attribs [ 'dtype' ] ) self . register_buffer ( name , torch . tensor ( self . normalize_dtype ( data ) ) ) self . _operators = { } self . _operators . update ( nnef_operators . Operators ) if custom_operators : self . _operators . update ( custom_operators ) self . _activation_callback = activation_callback self . _training_attributes = training_attributes or { }