In the following excerpt from GraphImporter::_import_placeholder, for each PlaceholderOp, we determine whether it is a param or not based where it appears in the order in the body list of the graph.
This is undesirable, as it introduces implicit dependencies. It can also cause errors, if any optimisation routine changes the ordering of nodes, etc.
Ideally the GraphImporter should have static, order independent knowledge of which PlacehodlerOps are params, inputs etc.
|
if self._num_input_visited < len(self._params) and self._do_param_pack: |
|
dtype = node.tensor_meta["dtype"] |
|
pack_of_dtype = None |
|
for pack in args_list: |
|
if ir.MemRefType( |
|
pack.type |
|
).element_type == self._str_to_mlir_dtype(dtype): |
|
pack_of_dtype = pack |
|
break |
|
placeholder_name = self._ops_registry["param.extract"]( |
|
node, self._current_param_pack_offset[dtype], pack_of_dtype |
|
).result |
|
self._current_param_pack_offset[dtype] += functools.reduce( |
|
lambda x, y: x * y, list(node.tensor_meta["shape"]), 1 |
|
) |