oneflow.nn.graph.graph_config.GraphConfig.allow_fuse_add_to_output

GraphConfig.allow_fuse_add_to_output(mode: bool = True)

If set to true, try to fuse a binary element-wise add operator to one of the predecessors to improve performance.

For example:

import oneflow as flow

class Graph(flow.nn.Graph):
    def __init__(self):
        super().__init__()
        self.bn1 = flow.nn.BatchNorm1d(100)
        self.config.allow_fuse_add_to_output(True)
    def build(self, x):
        bn = self.bn1(x)
        out = bn + x
        return out

graph = Graph()
Parameters

mode (bool, optional) – The default value is True.