r"""Embeds ``data`` to the graph's inputs of ``dst``. Args: dst: target vars representing the graph. data: data to be embeded. inputs: indicates which inputs to be replaced. All inputs(``Host2DeiceCopy``) will be replaced if not specified. Returns:
(
dst: List[_VarNode], data: List[np.ndarray], inputs: List[_VarNode] = None
)
| 402 | |
| 403 | |
| 404 | def embed_inputs( |
| 405 | dst: List[_VarNode], data: List[np.ndarray], inputs: List[_VarNode] = None |
| 406 | ) -> Tuple[List[_VarNode], Dict[str, _VarNode]]: |
| 407 | r"""Embeds ``data`` to the graph's inputs of ``dst``. |
| 408 | |
| 409 | Args: |
| 410 | dst: target vars representing the graph. |
| 411 | data: data to be embeded. |
| 412 | inputs: indicates which inputs to be replaced. All |
| 413 | inputs(``Host2DeiceCopy``) will be replaced if not specified. |
| 414 | |
| 415 | Returns: |
| 416 | new vars that correspond to ``dst`` with all inputs replaced, and new inputs dict. |
| 417 | """ |
| 418 | if inputs is None: |
| 419 | inputs = get_dep_vars(dst, "Host2DeviceCopy") |
| 420 | assert len(data) == len(inputs) |
| 421 | input_dict = OrderedDict() |
| 422 | replace_dict = {} |
| 423 | for inp, d in zip(inputs, data): |
| 424 | new_inp = _imperative_rt.make_shared(inp.graph, Tensor(d)._dev_tensor()) |
| 425 | new_inp.name = inp.name |
| 426 | input_dict[inp.name] = new_inp |
| 427 | replace_dict[inp] = new_inp |
| 428 | new_output_nodes = replace_vars(dst, replace_dict) |
| 429 | for old, new in zip(dst, new_output_nodes): |
| 430 | new.name = old.name |
| 431 | return new_output_nodes, input_dict |
| 432 | |
| 433 | |
| 434 | class GraphInference: |
nothing calls this directly
no test coverage detected