Skip to content
Snippets Groups Projects
  • Xiaoyu Xu's avatar
    Fea/nn graph/forward graph (#5516) · ab8aab8b
    Xiaoyu Xu authored
    
    * add test on add input to graph
    
    * add var into graph
    
    * LazyInterpreter for FetchOutputOpExpr and set op parallel_distribution
    
    * refine input var build
    
    * split file
    
    * rename
    
    * mini refine
    
    * Add note
    
    * LazyInterpret::ApplyImpl for UserOpExpr
    
    * refine test scripts
    
    * add output to graph
    
    * format
    
    * Fix bug of LazyInterpret UserOpExpr for change output lbns
    
    * Add test user op expr test
    
    * fix note mistake
    
    * add userop and test
    
    * address review
    
    * address review
    
    * save i/o/s op_name and tensor for c_nn_graph
    
    * address review
    
    * adjust test
    
    * refine build_graph_state
    
    Co-authored-by: default avatarchengtbf <472491134@qq.com>
    Co-authored-by: default avataroneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
    Unverified
    ab8aab8b
utils.py 861 B
"""
Copyright 2020 The OneFlow Authors. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from __future__ import absolute_import


def add_indent(in_s, num_spaces):
    s = in_s.split("\n")
    if len(s) == 1:
        return in_s
    first = s.pop(0)
    s = [(num_spaces * " ") + line for line in s]
    s = "\n".join(s)
    s = first + "\n" + s
    return s