Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into develop
commit
1413d83a0f
@ -1,147 +0,0 @@
|
||||
# - This module looks for Sphinx
|
||||
# Find the Sphinx documentation generator
|
||||
#
|
||||
# This modules defines
|
||||
# SPHINX_EXECUTABLE
|
||||
# SPHINX_FOUND
|
||||
|
||||
find_program(SPHINX_EXECUTABLE
|
||||
NAMES sphinx-build
|
||||
PATHS
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
/opt/local/bin
|
||||
DOC "Sphinx documentation generator"
|
||||
)
|
||||
|
||||
if( NOT SPHINX_EXECUTABLE )
|
||||
set(_Python_VERSIONS
|
||||
2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5
|
||||
)
|
||||
|
||||
foreach( _version ${_Python_VERSIONS} )
|
||||
set( _sphinx_NAMES sphinx-build-${_version} )
|
||||
|
||||
find_program( SPHINX_EXECUTABLE
|
||||
NAMES ${_sphinx_NAMES}
|
||||
PATHS
|
||||
/usr/bin
|
||||
/usr/local/bin
|
||||
/opt/loca/bin
|
||||
DOC "Sphinx documentation generator"
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(Sphinx DEFAULT_MSG
|
||||
SPHINX_EXECUTABLE
|
||||
)
|
||||
|
||||
|
||||
option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON )
|
||||
option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF )
|
||||
option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF )
|
||||
option( SPHINX_QTHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in qthelp." OFF )
|
||||
option( SPHINX_DEVHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in devhelp." OFF )
|
||||
option( SPHINX_EPUB_OUTPUT "Build HTML pages with additional information for building a documentation collection in epub." OFF )
|
||||
option( SPHINX_LATEX_OUTPUT "Build LaTeX sources that can be compiled to a PDF document using pdflatex." OFF )
|
||||
option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF )
|
||||
option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF )
|
||||
|
||||
|
||||
mark_as_advanced(
|
||||
SPHINX_EXECUTABLE
|
||||
SPHINX_HTML_OUTPUT
|
||||
SPHINX_DIRHTML_OUTPUT
|
||||
SPHINX_HTMLHELP_OUTPUT
|
||||
SPHINX_QTHELP_OUTPUT
|
||||
SPHINX_DEVHELP_OUTPUT
|
||||
SPHINX_EPUB_OUTPUT
|
||||
SPHINX_LATEX_OUTPUT
|
||||
SPHINX_MAN_OUTPUT
|
||||
SPHINX_TEXT_OUTPUT
|
||||
)
|
||||
|
||||
function( Sphinx_add_target target_name builder conf cache source destination )
|
||||
add_custom_target( ${target_name} ALL
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b ${builder}
|
||||
-d ${cache}
|
||||
-c ${conf}
|
||||
${source}
|
||||
${destination}
|
||||
COMMENT "Generating sphinx documentation: ${builder}"
|
||||
COMMAND cd ${destination} && ln -sf ./index_*.html index.html
|
||||
)
|
||||
|
||||
set_property(
|
||||
DIRECTORY APPEND PROPERTY
|
||||
ADDITIONAL_MAKE_CLEAN_FILES
|
||||
${destination}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Target dependencies can be optionally listed at the end.
|
||||
function( Sphinx_add_targets target_base_name conf source base_destination )
|
||||
|
||||
set( _dependencies )
|
||||
|
||||
foreach( arg IN LISTS ARGN )
|
||||
set( _dependencies ${_dependencies} ${arg} )
|
||||
endforeach()
|
||||
|
||||
if( ${SPHINX_HTML_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_html html ${conf} ${source} ${base_destination}/html )
|
||||
|
||||
add_dependencies( ${target_base_name}_html ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_DIRHTML_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_dirhtml dirhtml ${conf} ${source} ${base_destination}/dirhtml )
|
||||
|
||||
add_dependencies( ${target_base_name}_dirhtml ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_QTHELP_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_qthelp qthelp ${conf} ${source} ${base_destination}/qthelp )
|
||||
|
||||
add_dependencies( ${target_base_name}_qthelp ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_DEVHELP_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_devhelp devhelp ${conf} ${source} ${base_destination}/devhelp )
|
||||
|
||||
add_dependencies( ${target_base_name}_devhelp ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_EPUB_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_epub epub ${conf} ${source} ${base_destination}/epub )
|
||||
|
||||
add_dependencies( ${target_base_name}_epub ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_LATEX_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_latex latex ${conf} ${source} ${base_destination}/latex )
|
||||
|
||||
add_dependencies( ${target_base_name}_latex ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_MAN_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_man man ${conf} ${source} ${base_destination}/man )
|
||||
|
||||
add_dependencies( ${target_base_name}_man ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${SPHINX_TEXT_OUTPUT} )
|
||||
Sphinx_add_target( ${target_base_name}_text text ${conf} ${source} ${base_destination}/text )
|
||||
|
||||
add_dependencies( ${target_base_name}_text ${_dependencies} )
|
||||
endif()
|
||||
|
||||
if( ${BUILD_TESTING} )
|
||||
sphinx_add_target( ${target_base_name}_linkcheck linkcheck ${conf} ${source} ${base_destination}/linkcheck )
|
||||
|
||||
add_dependencies( ${target_base_name}_linkcheck ${_dependencies} )
|
||||
endif()
|
||||
endfunction()
|
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
|
||||
static std::string paddle_commit() {
|
||||
return "@PADDLE_COMMIT@";
|
||||
}
|
||||
|
||||
static std::string paddle_compile_branch() {
|
||||
return "@PADDLE_BRANCH@";
|
||||
}
|
||||
|
||||
static std::string paddle_version() {
|
||||
return "@PADDLE_VERSION@";
|
||||
}
|
||||
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
File diff suppressed because it is too large
Load Diff
@ -1,120 +0,0 @@
|
||||
// Copyright (c) 2018 PaddlePaddle 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "paddle/fluid/framework/data_type.h"
|
||||
#include "paddle/fluid/framework/details/memory_reuse_types.h"
|
||||
#include "paddle/fluid/framework/ir/graph.h"
|
||||
#include "paddle/fluid/framework/ir/pass.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {
|
||||
constexpr char kAllOpDescs[] = "all_op_descs";
|
||||
|
||||
std::vector<ir::Node*> SortOpLikeDescOrder(const ir::Graph& graph);
|
||||
// sort op in bfs order
|
||||
std::vector<ir::Node*> BFSSortGraphOps(const ir::Graph& graph);
|
||||
|
||||
class ControlFlowGraph;
|
||||
|
||||
class AnalysisVarPass : public ir::Pass {
|
||||
protected:
|
||||
std::unique_ptr<ir::Graph> ApplyImpl(
|
||||
std::unique_ptr<ir::Graph> graph) const override;
|
||||
|
||||
private:
|
||||
// fill the variable map(var_nodes) by version.
|
||||
void InitSSAGraphNodes() const;
|
||||
// update program descs
|
||||
void RenameVarInGraphDesc(const std::string& var,
|
||||
const std::string& cache_var, size_t idx) const;
|
||||
// update ir nodes
|
||||
void RenameVarInGraphNode(const std::string& var,
|
||||
const std::string& cache_var, size_t idx,
|
||||
ir::Graph* graph) const;
|
||||
|
||||
void SubGraphOptimize(OpDesc* op_desc) const;
|
||||
// valid a tensor can be reuse or not
|
||||
bool NodeCanReused(ir::Node* node) const;
|
||||
// scan subblock and collect the output/input variables.
|
||||
std::unordered_set<std::string> GetSubBlockVars(
|
||||
const std::unordered_set<ir::Node*>&) const;
|
||||
// check op has subblock or not
|
||||
bool OpHasSubBlock(OpDesc* desc) const;
|
||||
|
||||
private:
|
||||
// Reuse Node Pool, Owned.
|
||||
mutable OrderedNodePairPool pool_;
|
||||
// controlflow Graph
|
||||
mutable std::unique_ptr<ControlFlowGraph> cfg_;
|
||||
// skip set
|
||||
mutable std::unordered_set<std::string> skip_set_;
|
||||
// var nodes
|
||||
mutable std::map<std::string, std::vector<ir::Node*>> var_nodes_;
|
||||
};
|
||||
|
||||
class ControlFlowGraph {
|
||||
public:
|
||||
ControlFlowGraph() = default;
|
||||
// For IR Graph in parallelexecutor
|
||||
explicit ControlFlowGraph(const ir::Graph& graph);
|
||||
|
||||
void LiveVariableAnalysis();
|
||||
|
||||
void RenameVarInCFGGraph(const std::string& old_node,
|
||||
const std::string& new_node, int begin_idx);
|
||||
|
||||
const std::set<std::string> LiveIn(ir::Node* op) const;
|
||||
const std::set<std::string> LiveOut(ir::Node* op) const;
|
||||
const std::set<std::string> Use(ir::Node* op) const;
|
||||
const std::vector<ir::Node*> Ops() const;
|
||||
std::vector<ir::Node*>& Ops();
|
||||
|
||||
// for ssa-graph nodes
|
||||
ir::Node* GetNodeFromVarName(const std::string& name, ir::Node* op) const;
|
||||
|
||||
private:
|
||||
void BuildCFGGraph();
|
||||
void ConnectNodes();
|
||||
using NodeListMap = std::unordered_map<ir::Node*, std::set<ir::Node*>>;
|
||||
using VarSetMap = std::map<ir::Node*, std::set<std::string>>;
|
||||
// successors ops use the output variables.
|
||||
NodeListMap successors_;
|
||||
// predecessors ops generated input variables.
|
||||
NodeListMap predecessors_;
|
||||
// variables lived before run current op.
|
||||
VarSetMap live_in_;
|
||||
// variables lived after run current op.
|
||||
VarSetMap live_out_;
|
||||
VarSetMap uses_; // op inputs
|
||||
VarSetMap defs_; // op outputs
|
||||
|
||||
std::vector<ir::Node*> ops_; // op sequence by topology sort
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
@ -0,0 +1,80 @@
|
||||
// Copyright (c) 2019 PaddlePaddle 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include "glog/logging.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "paddle/fluid/framework/ir/graph.h"
|
||||
#include "paddle/fluid/framework/ir/graph_helper.h"
|
||||
#include "paddle/fluid/framework/op_registry.h"
|
||||
#include "paddle/fluid/framework/program_desc.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
|
||||
class DummyOp : public OperatorBase {
|
||||
public:
|
||||
DummyOp(const std::string& type, const VariableNameMap& inputs,
|
||||
const VariableNameMap& outputs, const AttributeMap& attrs)
|
||||
: OperatorBase(type, inputs, outputs, attrs) {}
|
||||
|
||||
private:
|
||||
void RunImpl(const Scope& scope,
|
||||
const platform::Place& place) const override {}
|
||||
};
|
||||
|
||||
class SumOpMaker : public OpProtoAndCheckerMaker {
|
||||
public:
|
||||
void Make() {
|
||||
AddInput("X", "").AsDuplicable();
|
||||
AddOutput("Out", "");
|
||||
AddComment("");
|
||||
}
|
||||
};
|
||||
|
||||
class AssignOpMaker : public OpProtoAndCheckerMaker {
|
||||
public:
|
||||
void Make() {
|
||||
AddInput("X", "").AsDuplicable();
|
||||
AddOutput("Out", "");
|
||||
AddComment("");
|
||||
}
|
||||
};
|
||||
|
||||
class SplitOpMaker : public OpProtoAndCheckerMaker {
|
||||
public:
|
||||
void Make() {
|
||||
AddInput("X", "");
|
||||
AddOutput("Out", "").AsDuplicable();
|
||||
AddComment("");
|
||||
}
|
||||
};
|
||||
|
||||
class DummyVarTypeInference : public VarTypeInference {
|
||||
public:
|
||||
void operator()(const OpDesc& op_desc, BlockDesc* block) const override {
|
||||
auto& inputs = op_desc.Input("X");
|
||||
auto type = block->Var(inputs.front())->GetType();
|
||||
auto out_var_name = op_desc.Output("Out").front();
|
||||
block->Var(out_var_name)->SetType(type);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue