未验证 提交 d1b25ed9 编写于 作者: W wanghuancoder 提交者: GitHub

add some RecordEvent, for dygraph timeline (#30299)

* add some RecordEvent, for dygraph timeline, test=develop

* change GpuMemcpySync to memory::Copy, test=develop

* fix compile problem, test=develop

* fix compile problem, test=develop

* fix, test=develop

* fix, test=develop
上级 bbea5a1f
......@@ -281,6 +281,8 @@ void BasicEngine::Execute() {
auto& inplace_grad_name_map = shared_cur_node->InplaceGradNameMap();
for (auto& cur_op : *shared_cur_node) {
platform::RecordEvent op_type_record_event(cur_op.Type());
++op_num;
// CheckBackWardInput
......
......@@ -206,6 +206,7 @@ void VarBase::ClearGradient() {
grad_t->mutable_value()->clear();
}
} else {
platform::RecordEvent record_event("ClearGradient");
auto* grad_t =
grad_var_->MutableVar()->GetMutable<framework::LoDTensor>();
if (grad_t->IsInitialized()) {
......
......@@ -133,6 +133,7 @@ void Tracer::TraceOp(const std::string& type, const NameVarBaseMap& ins,
const NameVarBaseMap& outs, framework::AttributeMap attrs,
const platform::Place& place, bool trace_backward,
const std::map<std::string, std::string>& inplace_map) {
platform::RecordEvent op_type_record_event(type);
VLOG(1) << "Trace Op: " << type;
if (FLAGS_use_mkldnn) {
// if both lists are empty all ops are enabled (default for
......
......@@ -29,6 +29,7 @@ limitations under the License. */
#include "paddle/fluid/platform/bfloat16.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/float16.h"
#include "paddle/fluid/platform/profiler.h"
#include "pybind11/numpy.h"
#include "pybind11/pybind11.h"
......@@ -293,6 +294,7 @@ void SetTensorFromPyArrayT(
auto dst = self->mutable_data<T>(place);
paddle::platform::GpuMemcpySync(dst, array.data(), array.nbytes(),
cudaMemcpyHostToDevice);
} else if (paddle::platform::is_cuda_pinned_place(place)) {
auto dst = self->mutable_data<T>(place);
std::memcpy(dst, array.data(), array.nbytes());
......@@ -706,8 +708,9 @@ inline py::array TensorToPyArray(const framework::Tensor &tensor,
"or double free would occur"));
size_t copy_bytes = sizeof_dtype * numel;
paddle::platform::GpuMemcpySync(py_arr.mutable_data(), tensor_buf_ptr,
copy_bytes, cudaMemcpyDeviceToHost);
auto p = BOOST_GET_CONST(platform::CUDAPlace, tensor.place());
paddle::memory::Copy(platform::CPUPlace(), py_arr.mutable_data(), p,
tensor_buf_ptr, copy_bytes, nullptr);
return py_arr;
#else
PADDLE_THROW(platform::errors::PermissionDenied(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册