Skip to content

Runtime Operator and Variable should take OpDesc and VarDesc as private data members #9069

@QiJune

Description

@QiJune

Actually, we construct OpDesc and VarDesc at CompileTime, and then create Operator and Variable at CompileTime.

Operator has four data members:

std::string type_;
// NOTE: in case of OpGrad, inputs_ contains:
// I (Inputs)
// O (Outputs)
// OG (Output Gradients)
VariableNameMap inputs_;
// NOTE: in case of OpGrad, outputs_ contains
// IG (Inputs Gradients)
VariableNameMap outputs_;
AttributeMap attrs_;

These four data members are equivalent with OpDesc.

But in Variable, we do not have a VarDesc data member.

I am trying to implement re-computation policy to make further memory optimization. The re-computation policy will delete the variable in forward pass, and re-compute them in backward pass.

But If I erase the variable in current scope in forward pass, I can not compute them in backward pass. Because the variable is not exits. And the var type information in VarDesc is also lost.

A solution can be delete the variable first, and make memory released. And then create the variable again, and we need to call GetMutable method to set var type for this variable. It acquires VarDesc in a Runtime variable.

We should take OpDesc and VarDesc as a data member of Operator and Variable.

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