-
Notifications
You must be signed in to change notification settings - Fork 63
Shrestha/var in compute #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
2d1445c
fixed no of outputs
36a0b61
Some minor changes
e65d66f
initialize only pipelined tensors
71d0cad
initialize only pipelined tensors
cec9962
Merge branch 'shrestha/prefetch_right_inputs' of https://github.com/t…
8e429a5
GetPrefetchedTensors
2bf99a4
Added test
ac9e32d
removed test
2db801d
refactor pipeline
9c0e03f
Shared data keeps track of prefetched input indexes
8dfc795
Working state
1fe8f83
Merge remote-tracking branch 'origin/master' into shrestha/prefetch_r…
5464b7a
bazel fix
5233e69
Added test
1e2dd34
Merge remote-tracking branch 'origin/master' into shrestha/prefetch_r…
94cc450
Changed tests. Put pipelined io tensors together to avoid unnecessary…
8bc22bd
refactored
33d4431
Indexes utilities
1c1aaff
Fix test
2e51f44
Merge remote-tracking branch 'origin/master' into shrestha/prefetch_r…
958f62e
renamed the files
bfef9c0
Fixed Prefetch Tests
065db00
fixed tests
30fec16
Removed couts
5b0bd52
minor
bface40
fixed tests
d7a735f
added log
fa301de
Added logs
366c78f
Added prefetch test
d06de1f
Merge remote-tracking branch 'origin/master' into shrestha/prefetch_r…
f052c6d
Format, removed extended file
120621c
minor
7fc9507
fixed test
601c135
Merge remote-tracking branch 'origin/master' into shrestha/prefetch_r…
6d4c037
FindComplement modified
31620bb
Apply suggestions from code review
1915493
incorporate review comemnts
0593f29
Merge branch 'shrestha/prefetch_right_inputs' of https://github.com/t…
a4f9e1f
addressed review comments
8536844
remove test-prefetch-2
bf8e918
renamed the vars for indexes relative to pipelined indexes
b2300b7
examples
5222150
fixed hang seen when disable deassign
f6baec4
Extended TM to store variable shared name
fae2335
added test
09612d8
Merge remote-tracking branch 'origin/master' into shrestha/prefetch_r…
b1120c1
fix axpy var test
06c93ef
fixed var tests
76bcd8e
Merge remote-tracking branch 'origin/shrestha/prefetch_right_inputs' …
f89a28e
Fixed axpy pipelined py
0c8f2d2
Merge remote-tracking branch 'origin/master' into shrestha/tm_get_sha…
25613b6
Read only required outputs
ff18bfd
Read only required outputs
6ffc443
Merge branch 'shrestha/var_in_compute' of https://github.com/tensorfl…
3e3d887
Var uses Parallel Executor
02888d3
Implemented IOTensorsReadyForExec
ca63606
Sync for output tensors
472b8d8
Fixed output
e932e11
Merge branch 'shrestha/var_in_compute' of https://github.com/tensorfl…
34de806
Merge branch 'master' into shrestha/var_in_compute
06efb09
Merge branch 'master' into shrestha/var_in_compute
5576a47
For non var build
b130917
Solved build and fix
f821bac
Fix test_flib
53c1c38
Merge remote-tracking branch 'origin/master' into shrestha/var_in_com…
1af0efa
Removed Print function
fe5d3e8
Added Traces to Encap. Some clean up
878572a
Added comments, clean up, etc
85882bd
Removed ngraph-var in tracked_variable.cc
8fc9205
Merge remote-tracking branch 'origin/master' into shrestha/var_in_com…
983eb7b
ngraph_tracked_variable.cc changes
c992027
added traces
5ae567a
fix build
ab33837
Var Rewrite pass calls EnterPrefetchInCatalog,fixed header guard, ten…
f8ae937
small fix
85f9a39
incorporate review comments
a5f9ff2
fixed path for axpy pipelined for test_ngtf.py
b639f9d
Added more specific tracing for prefetched
cbcc036
Merge branch 'master' into shrestha/var_in_compute
0c40739
incorporate review comments
c042564
Merge branch 'shrestha/var_in_compute' of https://github.com/tensorfl…
4b21cc1
minor
36f4bec
removed print vector. added lambda
bf3b846
fix test_utils.py
8e346e8
write prefetch traces
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,9 +49,9 @@ | |
| #include "ngraph_bridge/ngraph_prefetch_shared_data.h" | ||
| #include "ngraph_bridge/ngraph_timer.h" | ||
| #include "ngraph_bridge/ngraph_utils.h" | ||
| #include "ngraph_bridge/ngraph_var.h" | ||
|
|
||
| #if defined(NGRAPH_TF_ENABLE_VARIABLES_AND_OPTIMIZERS) | ||
| #include "ngraph_bridge/enable_variable_ops/ngraph_var.h" | ||
| #include "ngraph_bridge/ngraph_catalog.h" | ||
| #endif | ||
|
|
||
|
|
@@ -88,13 +88,8 @@ NGraphEncapsulateOp::NGraphEncapsulateOp(OpKernelConstruction* ctx) | |
| ctx, backend != nullptr, | ||
| errors::Internal("Cannot get the backend object for BE: ", be_name)); | ||
|
|
||
| // If we have the VARIABLE capture on then we can't use the | ||
| // parallel executor until that support is added. | ||
| #if !defined(NGRAPH_TF_ENABLE_VARIABLES_AND_OPTIMIZERS) | ||
| // If backend executable can create tensors we use parallel executor | ||
| m_use_parallel_executor = backend->executable_can_create_tensors(); | ||
| #else | ||
| m_use_parallel_executor = false; | ||
| #endif | ||
|
|
||
| // Override the switch for debugging/testing | ||
| if (std::getenv("NGRAPH_TF_USE_LEGACY_EXECUTOR") != nullptr) { | ||
|
|
@@ -402,7 +397,7 @@ NGraphEncapsulateOp::~NGraphEncapsulateOp() { | |
| // OpKernel::Compute | ||
| //--------------------------------------------------------------------------- | ||
| void NGraphEncapsulateOp::Compute(OpKernelContext* ctx) { | ||
| ngraph::Event event_compute("Compute", "", ""); | ||
| ngraph::Event event_compute("NGEncap::Compute::" + name(), name(), ""); | ||
|
|
||
| if (m_use_parallel_executor) { | ||
| NGRAPH_VLOG(1) << "NGraphEncapsulateOp::Compute: Using Parallel Executor"; | ||
|
|
@@ -459,6 +454,7 @@ void NGraphEncapsulateOp::ComputeUsingParallelExecutor(OpKernelContext* ctx) { | |
| m_parallel_executor->GetTensorPipelineDepth())); | ||
|
|
||
| // Get Tensor Manager and some error checking | ||
| ngraph::Event event_prepare_ng_tensors("Prepare NG In/Out Tensors", "", ""); | ||
| auto tensor_manager = m_parallel_executor->GetTensorManager(); | ||
| int num_of_inputs = tensor_manager->GetNumberOfInputs(); | ||
| int num_of_outputs = tensor_manager->GetNumberOfOutputs(); | ||
|
|
@@ -499,14 +495,18 @@ void NGraphEncapsulateOp::ComputeUsingParallelExecutor(OpKernelContext* ctx) { | |
| vector<shared_ptr<ng::runtime::Tensor>> ng_inputs(num_of_inputs); | ||
| vector<shared_ptr<ng::runtime::Tensor>> ng_outputs(num_of_outputs); | ||
|
|
||
| // All inputs and outputs are pipelined. | ||
| // Of all these pipelined inputs some are prefetched | ||
| // TODO: Fit in variables | ||
| ng_inputs = get<1>(pipelined_io_tensors); | ||
| ng_outputs = get<2>(pipelined_io_tensors); | ||
| // Prepare NG Input Output Tensors | ||
| // Assemble Variable tensors and pipelined tensors to ng_input and ng_outputs | ||
| OP_REQUIRES_OK(ctx, GetIOTensorsReadyForExecution( | ||
| ctx, tensor_manager, get<1>(pipelined_io_tensors), | ||
| get<2>(pipelined_io_tensors), ng_inputs, ng_outputs)); | ||
| event_prepare_ng_tensors.Stop(); | ||
| ngraph::Event::write_trace(event_prepare_ng_tensors); | ||
|
|
||
| // And execute | ||
| ngraph::Event event_execute_graph("Execute Graph", "", ""); | ||
| ngraph::Event event_execute_graph( | ||
| "Execute Graph Pipeline Indx" + to_string(current_iter_pipeline_depth), | ||
| "", ""); | ||
|
|
||
| BackendManager::LockBackend(m_parallel_executor->GetOpBackendName()); | ||
| NGRAPH_VLOG(4) << "NGraphEncapsulateOp::Compute call starting for cluster " | ||
|
|
@@ -540,12 +540,14 @@ void NGraphEncapsulateOp::ComputeUsingParallelExecutor(OpKernelContext* ctx) { | |
| ngraph::Event::write_trace(event_execute_graph); | ||
|
|
||
| // Now prepare the output | ||
| ngraph::Event event_copy_output_tensor("Copy Output Tensor", "", ""); | ||
| // Allocate TF Tensors | ||
| NGRAPH_VLOG(4) << "NGraphEncapsulateOp::Compute Allocating TF Output Tensors " | ||
| << m_parallel_executor->GetNgraphClusterId(); | ||
|
|
||
| std::vector<std::unique_ptr<ngraph::Event>> output_copy_events; | ||
| ngraph::Event event_prepare_tf_output_tensors("Prepare TF Output Tensor", "", | ||
| ""); | ||
| vector<Tensor*> tf_output_tensors; | ||
| for (auto i = 0; i < ng_exec->get_results().size(); i++) { | ||
| std::unique_ptr<ngraph::Event> event_copy_prep( | ||
| new ngraph::Event("Copy Prep", "", "")); | ||
| auto ng_element = ng_exec->get_results()[i]; | ||
| auto ng_shape = ng_element->get_shape(); | ||
| auto ng_element_type = ng_element->get_element_type(); | ||
|
|
@@ -558,7 +560,7 @@ void NGraphEncapsulateOp::ComputeUsingParallelExecutor(OpKernelContext* ctx) { | |
| TensorShape tf_shape(dims); | ||
| Tensor* tf_output_tensor = nullptr; | ||
| OP_REQUIRES_OK(ctx, ctx->allocate_output(i, tf_shape, &tf_output_tensor)); | ||
|
|
||
| tf_output_tensors.push_back(tf_output_tensor); | ||
| // Make sure the nGraph-inferred element type agrees with what TensorFlow | ||
| // expected. | ||
| ng::element::Type expected_elem_type; | ||
|
|
@@ -569,28 +571,45 @@ void NGraphEncapsulateOp::ComputeUsingParallelExecutor(OpKernelContext* ctx) { | |
| ctx, ng_element_type == expected_elem_type, | ||
| errors::Internal("Element type inferred by nGraph does not match " | ||
| "the element type expected by TensorFlow")); | ||
| event_copy_prep->Stop(); | ||
| output_copy_events.push_back(std::move(event_copy_prep)); | ||
| } | ||
|
|
||
| // Now copy the nGraph Tensor to Host Tensor | ||
| std::unique_ptr<ngraph::Event> event_copy_d2h( | ||
| new ngraph::Event("Device to Host Copy", "", "")); | ||
| void* dst_ptr = DMAHelper::base(tf_output_tensor); | ||
| // Copy Tensors that are required | ||
| NGRAPH_VLOG(4) << "NGraphEncapsulateOp::Compute Read NG Output Tensors " | ||
| << m_parallel_executor->GetNgraphClusterId(); | ||
|
|
||
| ng_outputs[i]->read( | ||
| dst_ptr, ng_outputs[i]->get_element_count() * ng_element_type.size()); | ||
| std::vector<std::unique_ptr<ngraph::Event>> output_copy_events; | ||
|
|
||
| auto output_indexes_to_be_copied = | ||
| tensor_manager->GetOutputIndexesThatNeedCopy(); | ||
| for (auto output_index : output_indexes_to_be_copied) { | ||
| // Copy the nGraph Tensor to Host Tensor | ||
| std::unique_ptr<ngraph::Event> event_copy_d2h(new ngraph::Event( | ||
| "D2H_Output_" + std::to_string(output_index), "", "")); | ||
| void* dst_ptr = (void*)DMAHelper::base(tf_output_tensors[output_index]); | ||
| ng_outputs[output_index]->read( | ||
| dst_ptr, ng_outputs[output_index]->get_element_count() * | ||
| ng_outputs[output_index]->get_element_type().size()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note to self: instead of calling read on everything, call read only on output_indexes_to_be_copied |
||
| event_copy_d2h->Stop(); | ||
| output_copy_events.push_back(std::move(event_copy_d2h)); | ||
| } | ||
|
|
||
| for (auto& next : output_copy_events) { | ||
| ngraph::Event::write_trace(*next.get()); | ||
| } | ||
| event_prepare_tf_output_tensors.Stop(); | ||
| ngraph::Event::write_trace(event_prepare_tf_output_tensors); | ||
|
|
||
| event_copy_output_tensor.Stop(); | ||
| ngraph::Event::write_trace(event_copy_output_tensor); | ||
| // Synch Var Output Tensors as required | ||
| NGRAPH_VLOG(4) | ||
| << "NGraphEncapsulateOp::Compute Sync NG Output Variable Tensors " | ||
| << m_parallel_executor->GetNgraphClusterId(); | ||
| ngraph::Event event_update_ngvar_tensors("Update NGVar Tensors", "", ""); | ||
| OP_REQUIRES_OK(ctx, SyncOutputVarTensors(ctx, tensor_manager)); | ||
| event_update_ngvar_tensors.Stop(); | ||
| ngraph::Event::write_trace(event_update_ngvar_tensors); | ||
|
|
||
| // Now return them to the cache | ||
| NGRAPH_VLOG(4) << "NGraphEncapsulateOp::Returning Tensors " | ||
| << m_parallel_executor->GetNgraphClusterId(); | ||
| ngraph::Event event_return_tensor("Return Tensor", "", ""); | ||
| pipelined_tensor_store->return_tensors(current_iter_pipeline_depth); | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: important section here.