def __update_input_data_from_data_shape()

in src/neo_loader/abstract_model_loader.py [0:0]


    def __update_input_data_from_data_shape(self) -> None:
        from tvm import relay
        if 'Inputs' not in self.metadata:
            inputs = []
            for key, value in self.__data_shape.items():
                inputs.append({
                    'name': key,
                    'shape': value
                })
            self._metadata['Inputs'] = inputs
        else:
            for inp in self._metadata['Inputs']:
                if None in inp['shape'] and inp['name'] in self.__data_shape:
                    inp['shape'] = self.__data_shape[inp['name']]

        # Get input dtypes from Relay
        if self.ir_format == GraphIR.relay:
            relay_var_dtypes = {}
            for p in self._relay_module_object["main"].params:
                if isinstance(p.type_annotation, relay.ty.TupleType):
                    if len(p.type_annotation.fields) != 1:
                        raise RuntimeError("Tuple input with multiple elements is currently not supported.")
                    relay_var_dtypes[p.name_hint] = p.type_annotation.fields[0].dtype
                else:
                    relay_var_dtypes[p.name_hint] = p.type_annotation.dtype
            for inp in self._metadata['Inputs']:
                if 'dtype' not in inp and inp['name'] in relay_var_dtypes:
                    inp['dtype'] = relay_var_dtypes[inp['name']]