提交 9f6aaa3c 编写于 作者: S sandyhouse

reformat code, test=develop

上级 b1a23b82
...@@ -254,7 +254,7 @@ void PipelineTrainer::Finalize() { ...@@ -254,7 +254,7 @@ void PipelineTrainer::Finalize() {
const LoDTensor& minibatch_tensor = minibatch_ptr->Get<LoDTensor>(); const LoDTensor& minibatch_tensor = minibatch_ptr->Get<LoDTensor>();
TensorCopy(*static_cast<const Tensor*>(&minibatch_tensor), places_[0], TensorCopy(*static_cast<const Tensor*>(&minibatch_tensor), places_[0],
static_cast<Tensor*>(root_tensor)); static_cast<Tensor*>(root_tensor));
VLOG(4) << "Copy persitable var " << var->Name() << " to root scope"; VLOG(3) << "Copy persitable var " << var->Name() << " to root scope";
} }
} }
} }
......
...@@ -154,6 +154,7 @@ void SectionWorker::TrainFiles() { ...@@ -154,6 +154,7 @@ void SectionWorker::TrainFiles() {
} }
} }
dev_ctx_->Wait(); dev_ctx_->Wait();
VLOG(0) << "real_microbatch_num for thread 0 " << real_microbatch_num; VLOG(0) << "real_microbatch_num for thread 0 " << real_microbatch_num;
// backward pass // backward pass
for (int i = 0; i < real_microbatch_num; ++i) { for (int i = 0; i < real_microbatch_num; ++i) {
...@@ -393,9 +394,11 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -393,9 +394,11 @@ void SectionWorker::TrainFilesWithProfiler() {
std::unique_lock<std::mutex> lk(cout_mutex); std::unique_lock<std::mutex> lk(cout_mutex);
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "::FWD:B[" << batch_id_ << "]:SEC[" << thread_id_ << "]:SCOPE[" << i std::cout << "::FWD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:OP[" << op->Type() << "]:START[" << start.tv_sec * 1e6 + start.tv_usec << "]:SCOPE[" << i << "]:OP[" << op->Type()
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl; << "]:START[" << start.tv_sec * 1e6 + start.tv_usec
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]"
<< std::endl;
} }
} }
op_idx++; op_idx++;
...@@ -406,8 +409,10 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -406,8 +409,10 @@ void SectionWorker::TrainFilesWithProfiler() {
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "!!FWD:B[" << batch_id_ << "]:SEC[" << thread_id_ std::cout << "!!FWD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:START[" << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:START["
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]" << std::endl; << micro_start.tv_sec * 1e6 + micro_start.tv_usec
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec
<< "]" << std::endl;
} }
} catch (platform::EOFException&) { } catch (platform::EOFException&) {
std::unique_lock<std::mutex> lk(thread_mutex); std::unique_lock<std::mutex> lk(thread_mutex);
...@@ -469,9 +474,11 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -469,9 +474,11 @@ void SectionWorker::TrainFilesWithProfiler() {
std::unique_lock<std::mutex> lk(cout_mutex); std::unique_lock<std::mutex> lk(cout_mutex);
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "::BWD:B[" << batch_id_ << "]:SEC[" << thread_id_ << "]:SCOPE[" << i std::cout << "::BWD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:OP[" << op->Type() << "]:START[" << start.tv_sec * 1e6 + start.tv_usec << "]:SCOPE[" << i << "]:OP[" << op->Type()
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl; << "]:START[" << start.tv_sec * 1e6 + start.tv_usec
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]"
<< std::endl;
} }
} }
op_idx++; op_idx++;
...@@ -482,8 +489,10 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -482,8 +489,10 @@ void SectionWorker::TrainFilesWithProfiler() {
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "!!BWD:B[" << batch_id_ << "]:SEC[" << thread_id_ std::cout << "!!BWD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:START[" << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:START["
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]" << std::endl; << micro_start.tv_sec * 1e6 + micro_start.tv_usec
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec
<< "]" << std::endl;
} }
} }
dev_ctx_->Wait(); dev_ctx_->Wait();
...@@ -524,9 +533,11 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -524,9 +533,11 @@ void SectionWorker::TrainFilesWithProfiler() {
std::unique_lock<std::mutex> lk(cout_mutex); std::unique_lock<std::mutex> lk(cout_mutex);
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "::UPD:B[" << batch_id_ << "]:SEC[" << thread_id_ << "]:SCOPE[" << num_microbatches_ std::cout << "::UPD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:OP[" << op->Type() << "]:START[" << start.tv_sec * 1e6 + start.tv_usec << "]:SCOPE[" << num_microbatches_ << "]:OP["
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl; << op->Type() << "]:START["
<< start.tv_sec * 1e6 + start.tv_usec << "]:END["
<< end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl;
} }
} }
op_idx++; op_idx++;
...@@ -537,8 +548,10 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -537,8 +548,10 @@ void SectionWorker::TrainFilesWithProfiler() {
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "!!UPD:B[" << batch_id_ << "]:SEC[" << thread_id_ std::cout << "!!UPD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:START[" << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:START["
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]" << std::endl; << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:END["
<< micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]"
<< std::endl;
} }
dev_ctx_->Wait(); dev_ctx_->Wait();
batch_timer.Pause(); batch_timer.Pause();
...@@ -582,7 +595,8 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -582,7 +595,8 @@ void SectionWorker::TrainFilesWithProfiler() {
lk.unlock(); lk.unlock();
VLOG(0) << "============timeline============"; VLOG(0) << "============timeline============";
for (size_t i = 0; i < ops_.size(); ++i) { for (size_t i = 0; i < ops_.size(); ++i) {
VLOG(0) << "op: " << op_name[i] << ", max_time: " << op_max_time[i] VLOG(0) << "op: " << op_name[i]
<< ", max_time: " << op_max_time[i]
<< ", min_time: " << op_min_time[i] << ", min_time: " << op_min_time[i]
<< ", mean_time: " << op_total_time[i] / op_count[i]; << ", mean_time: " << op_total_time[i] / op_count[i];
} }
...@@ -634,9 +648,11 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -634,9 +648,11 @@ void SectionWorker::TrainFilesWithProfiler() {
std::unique_lock<std::mutex> lk(cout_mutex); std::unique_lock<std::mutex> lk(cout_mutex);
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "::FWD:B[" << local_batch_id_ << "]:SEC[" << thread_id_ << "]:SCOPE[" << i std::cout << "::FWD:B[" << local_batch_id_ << "]:SEC["
<< "]:OP[" << op->Type() << "]:START[" << start.tv_sec * 1e6 + start.tv_usec << thread_id_ << "]:SCOPE[" << i << "]:OP["
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl; << op->Type() << "]:START["
<< start.tv_sec * 1e6 + start.tv_usec << "]:END["
<< end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl;
} }
} }
op_idx++; op_idx++;
...@@ -647,8 +663,10 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -647,8 +663,10 @@ void SectionWorker::TrainFilesWithProfiler() {
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "!!FWD:B[" << batch_id_ << "]:SEC[" << thread_id_ std::cout << "!!FWD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:START[" << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:START["
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]" << std::endl; << micro_start.tv_sec * 1e6 + micro_start.tv_usec
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec
<< "]" << std::endl;
} }
} }
dev_ctx_->Wait(); dev_ctx_->Wait();
...@@ -687,9 +705,11 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -687,9 +705,11 @@ void SectionWorker::TrainFilesWithProfiler() {
std::unique_lock<std::mutex> lk(cout_mutex); std::unique_lock<std::mutex> lk(cout_mutex);
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "::BWD:B[" << local_batch_id_ << "]:SEC[" << thread_id_ << "]:SCOPE[" << i std::cout << "::BWD:B[" << local_batch_id_ << "]:SEC["
<< "]:OP[" << op->Type() << "]:START[" << start.tv_sec * 1e6 + start.tv_usec << thread_id_ << "]:SCOPE[" << i << "]:OP["
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl; << op->Type() << "]:START["
<< start.tv_sec * 1e6 + start.tv_usec << "]:END["
<< end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl;
} }
} }
op_idx++; op_idx++;
...@@ -700,8 +720,10 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -700,8 +720,10 @@ void SectionWorker::TrainFilesWithProfiler() {
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "!!BWD:B[" << batch_id_ << "]:SEC[" << thread_id_ std::cout << "!!BWD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:START[" << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:START["
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]" << std::endl; << micro_start.tv_sec * 1e6 + micro_start.tv_usec
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec
<< "]" << std::endl;
} }
} }
dev_ctx_->Wait(); dev_ctx_->Wait();
...@@ -740,9 +762,11 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -740,9 +762,11 @@ void SectionWorker::TrainFilesWithProfiler() {
std::unique_lock<std::mutex> lk(cout_mutex); std::unique_lock<std::mutex> lk(cout_mutex);
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "::UPD:B[" << batch_id_ << "]:SEC[" << thread_id_ << "]:SCOPE[" << num_microbatches_ std::cout << "::UPD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:OP[" << op->Type() << "]:START[" << start.tv_sec * 1e6 + start.tv_usec << "]:SCOPE[" << num_microbatches_ << "]:OP["
<< "]:END[" << end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl; << op->Type() << "]:START["
<< start.tv_sec * 1e6 + start.tv_usec << "]:END["
<< end.tv_sec * 1e6 + end.tv_usec << "]" << std::endl;
} }
} }
op_idx++; op_idx++;
...@@ -753,8 +777,10 @@ void SectionWorker::TrainFilesWithProfiler() { ...@@ -753,8 +777,10 @@ void SectionWorker::TrainFilesWithProfiler() {
std::cout << std::fixed; std::cout << std::fixed;
std::cout.precision(0); std::cout.precision(0);
std::cout << "!!UPD:B[" << batch_id_ << "]:SEC[" << thread_id_ std::cout << "!!UPD:B[" << batch_id_ << "]:SEC[" << thread_id_
<< "]:START[" << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:START["
<< "]:END[" << micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]" << std::endl; << micro_start.tv_sec * 1e6 + micro_start.tv_usec << "]:END["
<< micro_end.tv_sec * 1e6 + micro_end.tv_usec << "]"
<< std::endl;
} }
dev_ctx_->Wait(); dev_ctx_->Wait();
if (local_completed) { if (local_completed) {
......
...@@ -4132,7 +4132,7 @@ class PipelineOptimizer(object): ...@@ -4132,7 +4132,7 @@ class PipelineOptimizer(object):
index=0, index=0,
type='fill_constant', type='fill_constant',
inputs={}, inputs={},
outputs={'Out':[grad_var]}, outputs={'Out': [grad_var]},
attrs={ attrs={
'shape': grad_var.shape, 'shape': grad_var.shape,
'dtype': grad_var.dtype, 'dtype': grad_var.dtype,
...@@ -4326,6 +4326,7 @@ class PipelineOptimizer(object): ...@@ -4326,6 +4326,7 @@ class PipelineOptimizer(object):
# attribute have not been set yet. Then check all ops have the # attribute have not been set yet. Then check all ops have the
# op_device attribute. # op_device attribute.
self._add_default_opdevice_attr(main_block) self._add_default_opdevice_attr(main_block)
device_specs = self._check_validation(main_block) device_specs = self._check_validation(main_block)
# Step3: add enqueue and dequeue ops between section boundaries # Step3: add enqueue and dequeue ops between section boundaries
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册