Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

[RFC] Perform deeper function cloning. Some variables needs to be cloned. #1582

@rdzhabarov

Description

@rdzhabarov

Usage of cloning function

Glow currently provides a convenience method to clone an existing high level IR Function.
This functionality is used for procedures like:

Cloning semantics

The semantics of cloning is to create a new Function with all nodes cloned (basically, creating a new nodes) and restore edges in the new Function based on the original one. Cloning does not involve cloning variables in any way, so that newly cloned Function reuses the same variables as the original one.

Multiple writers issue

At the moment of inference some of the variables are read only variables like weights while others (e.g., connected to the Save node) are not. Having Save nodes clonned while sharing variables creates a situation when results of inference on one function overwrites results of inference on another function. This feels like an unexpected behavior when normally cloning is done with copy on write or just cloning shared resource. Currently, quantization end to end test does not perform any sensible validation as second inference run overwrites original values.

Options to fix this

  • The most natural way is to let Node cloning method to decide what needs to be cloned. Currently, it's just node itself, but for the case of Save node it could clone the output variable first and use that to create a new Save node.
  • Let the cloning procedure to handle variables and clone some of them. This way cloning procedure needs somehow to know whether var is output var and clone only those.
  • Other options?

@qcolombet, you looked at Save nodes a lot in the past. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions