Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into accelerate_ddpg
test=developrevert-15207-remove_op_handle_lock_and_fix_var
commit
3bb9b0cac2
@ -0,0 +1,63 @@
|
||||
# Tries to find Gperftools.
|
||||
#
|
||||
# Usage of this module as follows:
|
||||
#
|
||||
# find_package(Gperftools)
|
||||
#
|
||||
# Variables used by this module, they can change the default behaviour and need
|
||||
# to be set before calling find_package:
|
||||
#
|
||||
# Gperftools_ROOT_DIR Set this variable to the root installation of
|
||||
# Gperftools if the module has problems finding
|
||||
# the proper installation path.
|
||||
#
|
||||
# Variables defined by this module:
|
||||
#
|
||||
# GPERFTOOLS_FOUND System has Gperftools libs/headers
|
||||
# GPERFTOOLS_LIBRARIES The Gperftools libraries (tcmalloc & profiler)
|
||||
# GPERFTOOLS_INCLUDE_DIR The location of Gperftools headers
|
||||
|
||||
find_library(GPERFTOOLS_TCMALLOC
|
||||
NAMES tcmalloc
|
||||
HINTS ${Gperftools_ROOT_DIR}/lib)
|
||||
|
||||
find_library(GPERFTOOLS_PROFILER
|
||||
NAMES profiler
|
||||
HINTS ${Gperftools_ROOT_DIR}/lib)
|
||||
|
||||
find_library(GPERFTOOLS_TCMALLOC_AND_PROFILER
|
||||
NAMES tcmalloc_and_profiler
|
||||
HINTS ${Gperftools_ROOT_DIR}/lib)
|
||||
|
||||
find_path(GPERFTOOLS_INCLUDE_DIR
|
||||
NAMES gperftools/heap-profiler.h
|
||||
HINTS ${Gperftools_ROOT_DIR}/include)
|
||||
|
||||
set(GPERFTOOLS_LIBRARIES ${GPERFTOOLS_TCMALLOC_AND_PROFILER})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
Gperftools
|
||||
DEFAULT_MSG
|
||||
GPERFTOOLS_LIBRARIES
|
||||
GPERFTOOLS_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(
|
||||
Gperftools_ROOT_DIR
|
||||
GPERFTOOLS_TCMALLOC
|
||||
GPERFTOOLS_PROFILER
|
||||
GPERFTOOLS_TCMALLOC_AND_PROFILER
|
||||
GPERFTOOLS_LIBRARIES
|
||||
GPERFTOOLS_INCLUDE_DIR)
|
||||
|
||||
# create IMPORTED targets
|
||||
if (Gperftools_FOUND AND NOT TARGET gperftools::tcmalloc)
|
||||
add_library(gperftools::tcmalloc UNKNOWN IMPORTED)
|
||||
set_target_properties(gperftools::tcmalloc PROPERTIES
|
||||
IMPORTED_LOCATION ${GPERFTOOLS_TCMALLOC}
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}")
|
||||
add_library(gperftools::profiler UNKNOWN IMPORTED)
|
||||
set_target_properties(gperftools::profiler PROPERTIES
|
||||
IMPORTED_LOCATION ${GPERFTOOLS_PROFILER}
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${GPERFTOOLS_INCLUDE_DIR}")
|
||||
endif()
|
@ -0,0 +1,122 @@
|
||||
// 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.
|
||||
|
||||
#include "paddle/fluid/framework/details/eager_deletion_op_handle.h"
|
||||
#include "paddle/fluid/framework/lod_tensor_array.h"
|
||||
#include "paddle/fluid/framework/scope.h"
|
||||
#include "paddle/fluid/framework/selected_rows.h"
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
#include "paddle/fluid/platform/cuda_device_guard.h"
|
||||
#endif
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {
|
||||
|
||||
EagerDeletionOpHandle::EagerDeletionOpHandle(
|
||||
ir::Node *node, const Scope *scope, const platform::Place &place,
|
||||
const std::unordered_set<std::string> &var_names, GarbageCollector *gc,
|
||||
AtomicReferenceCountMap *ref_cnts)
|
||||
: OpHandleBase(node),
|
||||
scope_(scope),
|
||||
var_names_(var_names),
|
||||
gc_(gc),
|
||||
ref_cnts_(ref_cnts) {
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
if (platform::is_gpu_place(place)) {
|
||||
dev_ctx_ = reinterpret_cast<platform::CUDADeviceContext *>(
|
||||
platform::DeviceContextPool::Instance().Get(place));
|
||||
if (dynamic_cast<StreamGarbageCollector *>(gc_)) {
|
||||
platform::CUDADeviceGuard guard(
|
||||
boost::get<platform::CUDAPlace>(place).device);
|
||||
PADDLE_ENFORCE(cudaEventCreateWithFlags(&event_, cudaEventDisableTiming));
|
||||
PADDLE_ENFORCE_NOT_NULL(event_);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
EagerDeletionOpHandle::~EagerDeletionOpHandle() {
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
if (event_) {
|
||||
auto gpu_place = boost::get<platform::CUDAPlace>(dev_ctx_->GetPlace());
|
||||
platform::CUDADeviceGuard guard(gpu_place.device);
|
||||
PADDLE_ENFORCE(cudaEventDestroy(event_));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string EagerDeletionOpHandle::Name() const { return "eager_deletion"; }
|
||||
|
||||
void EagerDeletionOpHandle::RunImpl() {
|
||||
auto *exec_scope = scope_->FindVar(kLocalExecScopeName)->Get<Scope *>();
|
||||
std::deque<std::shared_ptr<memory::Allocation>> garbages;
|
||||
for (auto &name : var_names_) {
|
||||
auto it = ref_cnts_->find(name);
|
||||
// Var not found, not reference count has not decreased to 0
|
||||
if (it == ref_cnts_->end() || it->second.fetch_sub(1) != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto *var = exec_scope->FindVar(name);
|
||||
if (var == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VLOG(2) << "Erase variable " << name;
|
||||
|
||||
if (var->IsType<LoDTensor>()) {
|
||||
garbages.emplace_back(var->GetMutable<LoDTensor>()->MoveMemoryHolder());
|
||||
} else if (var->IsType<SelectedRows>()) {
|
||||
garbages.emplace_back(
|
||||
var->GetMutable<SelectedRows>()->mutable_value()->MoveMemoryHolder());
|
||||
} else if (var->IsType<LoDTensorArray>()) {
|
||||
auto *tensor_arr = var->GetMutable<LoDTensorArray>();
|
||||
for (auto &t : *tensor_arr) {
|
||||
garbages.emplace_back(t.MoveMemoryHolder());
|
||||
}
|
||||
} else {
|
||||
PADDLE_THROW("Type %s of %s is not supported eager deletion",
|
||||
var->Type().name(), name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!garbages.empty()) {
|
||||
ClearGarbages(&garbages);
|
||||
}
|
||||
}
|
||||
|
||||
void EagerDeletionOpHandle::ClearGarbages(
|
||||
std::deque<std::shared_ptr<memory::Allocation>> *garbages) {
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
if (event_) {
|
||||
auto compute_stream = dev_ctx_->stream();
|
||||
auto callback_stream =
|
||||
reinterpret_cast<StreamGarbageCollector *>(gc_)->stream();
|
||||
auto callback_func = [=]() {
|
||||
PADDLE_ENFORCE(cudaEventRecord(event_, compute_stream));
|
||||
PADDLE_ENFORCE(cudaStreamWaitEvent(callback_stream, event_, 0));
|
||||
};
|
||||
gc_->Add(std::move(*garbages), callback_func);
|
||||
} else {
|
||||
#endif
|
||||
gc_->Add(std::move(*garbages));
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
@ -0,0 +1,58 @@
|
||||
// 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 <deque>
|
||||
#include <string>
|
||||
#include "paddle/fluid/framework/details/op_handle_base.h"
|
||||
#include "paddle/fluid/framework/details/reference_count_pass_helper.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
class Scope;
|
||||
|
||||
namespace details {
|
||||
|
||||
class EagerDeletionOpHandle : public OpHandleBase {
|
||||
public:
|
||||
EagerDeletionOpHandle(ir::Node *node, const Scope *scope,
|
||||
const platform::Place &place,
|
||||
const std::unordered_set<std::string> &var_names,
|
||||
GarbageCollector *gc,
|
||||
AtomicReferenceCountMap *ref_cnts);
|
||||
|
||||
~EagerDeletionOpHandle();
|
||||
|
||||
std::string Name() const override;
|
||||
|
||||
protected:
|
||||
void RunImpl() override;
|
||||
|
||||
private:
|
||||
void ClearGarbages(std::deque<std::shared_ptr<memory::Allocation>> *garbages);
|
||||
|
||||
const Scope *scope_;
|
||||
std::unordered_set<std::string> var_names_;
|
||||
GarbageCollector *gc_; // not own
|
||||
AtomicReferenceCountMap *ref_cnts_; // not own
|
||||
#ifdef PADDLE_WITH_CUDA
|
||||
platform::CUDADeviceContext *dev_ctx_{nullptr};
|
||||
cudaEvent_t event_{nullptr};
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
@ -0,0 +1,101 @@
|
||||
// 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.
|
||||
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "paddle/fluid/framework/details/computation_op_handle.h"
|
||||
#include "paddle/fluid/framework/details/eager_deletion_op_handle.h"
|
||||
#include "paddle/fluid/framework/details/eager_deletion_pass.h"
|
||||
#include "paddle/fluid/framework/details/multi_devices_helper.h"
|
||||
#include "paddle/fluid/framework/ir/graph_helper.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {
|
||||
|
||||
std::unique_ptr<ir::Graph> EagerDeletionPass::ApplyImpl(
|
||||
std::unique_ptr<ir::Graph> graph) const {
|
||||
auto &ref_cnts =
|
||||
Get<std::vector<AtomicReferenceCountMap>>(kRuntimeReferenceCount);
|
||||
PADDLE_ENFORCE(ref_cnts.empty(),
|
||||
"kRuntimeReferenceCount should be initialized here!");
|
||||
|
||||
const auto &vars = graph->Get<GraphVars>(kGraphVars);
|
||||
ref_cnts.resize(vars.size());
|
||||
|
||||
const auto &last_live_ops =
|
||||
Get<std::vector<LastLiveOpsOfVars>>(kLastLiveOpsOfVars);
|
||||
const auto &gcs = Get<GarbageCollectorMap>(kGarbageCollector);
|
||||
const auto &places = Get<std::vector<platform::Place>>(kAllPlaces);
|
||||
|
||||
// a reverse map of last_live_ops
|
||||
// i.e., last op --> variable names which can be deleted.
|
||||
std::unordered_map<ComputationOpHandle *, std::unordered_set<std::string>>
|
||||
op_vars_map;
|
||||
|
||||
for (auto &var_ops_map : last_live_ops) {
|
||||
for (auto &var_ops_pair : var_ops_map) {
|
||||
const std::string &var_name = var_ops_pair.first;
|
||||
for (auto *op : var_ops_pair.second) {
|
||||
op_vars_map[op].insert(var_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &pair : op_vars_map) {
|
||||
auto *op = pair.first;
|
||||
auto &var_names = pair.second;
|
||||
|
||||
auto *eager_deletion_node =
|
||||
graph->CreateEmptyNode("eager_deletion", ir::Node::Type::kOperation);
|
||||
auto *eager_deletion_op = new EagerDeletionOpHandle(
|
||||
eager_deletion_node, op->GetScope(), op->GetPlace(), var_names,
|
||||
gcs.at(places[op->GetScopeIdx()]).get(),
|
||||
&(ref_cnts[op->GetScopeIdx()]));
|
||||
|
||||
auto it = std::find_if(
|
||||
op->Outputs().begin(), op->Outputs().end(), [](VarHandleBase *var) {
|
||||
return dynamic_cast<DummyVarHandle *>(var) != nullptr;
|
||||
});
|
||||
|
||||
if (it != op->Outputs().end()) {
|
||||
eager_deletion_op->AddInput(*it);
|
||||
} else {
|
||||
auto *dep_var = new DummyVarHandle(graph->CreateControlDepVar());
|
||||
graph->Get<GraphDepVars>(kGraphDepVars).emplace(dep_var);
|
||||
op->AddOutput(dep_var);
|
||||
eager_deletion_op->AddInput(dep_var);
|
||||
}
|
||||
|
||||
auto *dummy_leaf = new DummyVarHandle(graph->CreateControlDepVar());
|
||||
graph->Get<GraphDepVars>(kGraphDepVars).emplace(dummy_leaf);
|
||||
eager_deletion_op->AddOutput(dummy_leaf);
|
||||
}
|
||||
|
||||
VLOG(10) << "Create " << op_vars_map.size() << " EagerDeletionOpHandle(s)";
|
||||
return graph;
|
||||
}
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
||||
|
||||
REGISTER_PASS(eager_deletion_pass,
|
||||
paddle::framework::details::EagerDeletionPass)
|
||||
.RequirePassAttr(paddle::framework::details::kRuntimeReferenceCount)
|
||||
.RequirePassAttr(paddle::framework::details::kLastLiveOpsOfVars)
|
||||
.RequirePassAttr(paddle::framework::details::kAllPlaces)
|
||||
.RequirePassAttr(paddle::framework::details::kGarbageCollector);
|
@ -0,0 +1,32 @@
|
||||
// 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 "paddle/fluid/framework/ir/graph.h"
|
||||
#include "paddle/fluid/framework/ir/pass.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {
|
||||
|
||||
class EagerDeletionPass : public ir::Pass {
|
||||
protected:
|
||||
std::unique_ptr<ir::Graph> ApplyImpl(
|
||||
std::unique_ptr<ir::Graph> graph) const override;
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
@ -1,138 +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 <atomic>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "paddle/fluid/framework/details/op_handle_base.h"
|
||||
#include "paddle/fluid/framework/garbage_collector.h"
|
||||
#include "paddle/fluid/framework/scope.h"
|
||||
#include "paddle/fluid/framework/selected_rows.h"
|
||||
#include "paddle/fluid/framework/tensor.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {
|
||||
|
||||
using ReferenceCountMap = std::unordered_map<std::string, int>;
|
||||
using AtomicReferenceCountMap =
|
||||
std::unordered_map<std::string, std::atomic<int>>;
|
||||
using DeviceReferenceCountMap =
|
||||
std::unordered_map<int, std::unique_ptr<ReferenceCountMap>>;
|
||||
using AtomicDeviceReferenceCountMap =
|
||||
std::unordered_map<int, std::unique_ptr<AtomicReferenceCountMap>>;
|
||||
using DeviceGarbageCollectorMap =
|
||||
std::unordered_map<int,
|
||||
std::unique_ptr<GarbageCollector<framework::Tensor>>>;
|
||||
|
||||
class ReferenceCountOpHandle : public OpHandleBase {
|
||||
public:
|
||||
ReferenceCountOpHandle(ir::Node *node, const Scope *scope,
|
||||
const platform::CUDAPlace &place,
|
||||
const std::vector<std::string> &var_names,
|
||||
GarbageCollector<Tensor> *gc,
|
||||
AtomicReferenceCountMap *ref_cnts)
|
||||
: OpHandleBase(node), scope_(scope), gc_(gc), ref_cnts_(ref_cnts) {
|
||||
dev_ctx_ = static_cast<platform::CUDADeviceContext *>(
|
||||
platform::DeviceContextPool::Instance().Get(place));
|
||||
if (IsStreamGarabageCollector()) {
|
||||
platform::SetDeviceId(place.device);
|
||||
PADDLE_ENFORCE(cudaEventCreateWithFlags(&event_, cudaEventDisableTiming));
|
||||
}
|
||||
|
||||
for (auto &name : var_names) AddVar(name);
|
||||
}
|
||||
|
||||
~ReferenceCountOpHandle() {
|
||||
if (IsStreamGarabageCollector()) {
|
||||
auto gpu_place = boost::get<platform::CUDAPlace>(dev_ctx_->GetPlace());
|
||||
platform::SetDeviceId(gpu_place.device);
|
||||
PADDLE_ENFORCE(cudaEventDestroy(event_));
|
||||
}
|
||||
}
|
||||
|
||||
std::string Name() const override { return "reference_count"; }
|
||||
|
||||
void AddVar(const std::string &name) {
|
||||
auto it = var_names_.find(name);
|
||||
if (it != var_names_.end())
|
||||
++(it->second);
|
||||
else
|
||||
var_names_[name] = 1;
|
||||
}
|
||||
|
||||
protected:
|
||||
void RunImpl() override {
|
||||
auto *exec_scope = scope_->FindVar(kLocalExecScopeName)->Get<Scope *>();
|
||||
std::vector<Tensor *> tensors;
|
||||
for (auto &pair : var_names_) {
|
||||
auto &name = pair.first;
|
||||
auto it = ref_cnts_->find(name);
|
||||
if (it == ref_cnts_->end()) continue;
|
||||
|
||||
auto *var = exec_scope->FindVar(name);
|
||||
if (var == nullptr) continue;
|
||||
|
||||
if (var->IsType<LoDTensor>()) {
|
||||
if (it->second.fetch_sub(pair.second) <= pair.second) {
|
||||
tensors.emplace_back(var->GetMutable<LoDTensor>());
|
||||
}
|
||||
} else if (var->IsType<SelectedRows>()) {
|
||||
if (it->second.fetch_sub(pair.second) <= pair.second) {
|
||||
tensors.emplace_back(
|
||||
var->GetMutable<SelectedRows>()->mutable_value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tensors.empty()) {
|
||||
ClearTensors(tensors);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void ClearTensors(const std::vector<Tensor *> &tensors) {
|
||||
auto *gc = dynamic_cast<StreamGarbageCollector<Tensor> *>(gc_);
|
||||
if (gc != nullptr) {
|
||||
auto compute_stream = dev_ctx_->stream();
|
||||
auto callback_stream = gc->stream();
|
||||
auto callback_func = [=]() {
|
||||
PADDLE_ENFORCE(cudaEventRecord(event_, compute_stream));
|
||||
PADDLE_ENFORCE(cudaStreamWaitEvent(callback_stream, event_, 0));
|
||||
};
|
||||
gc_->Add(tensors, callback_func);
|
||||
} else {
|
||||
gc_->Add(tensors);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsStreamGarabageCollector() const {
|
||||
return dynamic_cast<const StreamGarbageCollector<Tensor> *>(gc_) != nullptr;
|
||||
}
|
||||
|
||||
const Scope *scope_;
|
||||
platform::CUDADeviceContext *dev_ctx_;
|
||||
std::unordered_map<std::string, int> var_names_;
|
||||
GarbageCollector<Tensor> *gc_; // not own
|
||||
AtomicReferenceCountMap *ref_cnts_; // not own
|
||||
cudaEvent_t event_;
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
// 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.
|
||||
|
||||
#include "paddle/fluid/framework/details/reference_count_pass_helper.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
@ -0,0 +1,51 @@
|
||||
// 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 <atomic>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "paddle/fluid/framework/garbage_collector.h"
|
||||
|
||||
namespace paddle {
|
||||
namespace framework {
|
||||
namespace details {
|
||||
|
||||
class ComputationOpHandle;
|
||||
|
||||
using ReferenceCountMap = std::unordered_map<std::string, size_t>;
|
||||
|
||||
using AtomicReferenceCountMap =
|
||||
std::unordered_map<std::string, std::atomic<size_t>>;
|
||||
|
||||
using GarbageCollectorMap =
|
||||
std::map<platform::Place, std::unique_ptr<GarbageCollector>>;
|
||||
|
||||
const char kGlobalReferenceCount[] = "global_reference_count";
|
||||
const char kRuntimeReferenceCount[] = "runtime_reference_count";
|
||||
const char kGarbageCollector[] = "garbage_collector";
|
||||
const char kAllPlaces[] = "all_places";
|
||||
|
||||
using LastLiveOpsOfVars =
|
||||
std::unordered_map<std::string, std::unordered_set<ComputationOpHandle*>>;
|
||||
const char kLastLiveOpsOfVars[] = "last_live_ops_of_var";
|
||||
|
||||
} // namespace details
|
||||
} // namespace framework
|
||||
} // namespace paddle
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue