This repository was archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Kanvi/skip assert #265
Open
kanvi-nervana
wants to merge
16
commits into
master
Choose a base branch
from
kanvi/skip-assert
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Kanvi/skip assert #265
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3f96d19
Changes for skipping the Assert op
92aa2ba
Merge branch 'master' into kanvi/skip-assert
d79a4e6
Disable deadness check
31e055c
Skip Assert
cbd15d7
Fix format
59b3e57
Merge branch 'master' into kanvi/skip-assert
avijit-nervana 98abc87
Incorporate comments
75493ae
Merge branch 'master' into kanvi/skip-assert
d7696d4
Merge branch 'kanvi/skip-assert' of https://github.com/NervanaSystems…
9acd86e
Corrected spelling mistakes
2363177
Merge branch 'master' into kanvi/skip-assert
avijit-nervana 67bda54
Fix segmentation fault
c5746df
Merge branch 'kanvi/skip-assert' of https://github.com/NervanaSystems…
a540b22
Add another test
47e065b
Minor changes
0e3bafe
Merge branch 'master' into kanvi/skip-assert
avijit-nervana 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /******************************************************************************* | ||
| * Copyright 2017-2018 Intel Corporation | ||
| * | ||
| * 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 "ngraph_disable_assert.h" | ||
|
|
||
| #include "tensorflow/core/graph/graph.h" | ||
| #include "tensorflow/core/graph/node_builder.h" | ||
| #include "tensorflow/core/graph/types.h" | ||
|
|
||
| #include "ngraph_utils.h" | ||
|
|
||
| using namespace std; | ||
|
|
||
| namespace tensorflow { | ||
|
|
||
| namespace ngraph_bridge { | ||
|
|
||
| // | ||
| // Main entry point for disable assert. | ||
| // | ||
| Status DisableAssert(Graph* graph) { | ||
| std::vector<const Edge*> edges; | ||
| for (auto node : graph->op_nodes()) { | ||
| if (node->type_string() == "Assert") { | ||
| NGRAPH_VLOG(4) << "Checking: " << node->name(); | ||
| for (auto edge : node->out_edges()) { | ||
| if (edge->IsControlEdge()) { | ||
| if (edge != NULL) { | ||
| NGRAPH_VLOG(4) << "Collecting all the control edges"; | ||
| edges.push_back(edge); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| for (auto edge : edges) { | ||
| NGRAPH_VLOG(4) << "Removing control edge: " << edge->DebugString(); | ||
| graph->RemoveControlEdge(edge); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| } // namespace ngraph_bridge | ||
|
|
||
| } // namespace tensorflow |
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /******************************************************************************* | ||
| * Copyright 2017-2018 Intel Corporation | ||
| * | ||
| * 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 "tensorflow/core/graph/graph.h" | ||
|
|
||
| namespace tensorflow { | ||
|
|
||
| namespace ngraph_bridge { | ||
|
|
||
| Status DisableAssert(Graph* graph); | ||
|
|
||
| } // namespace ngraph_bridge | ||
|
|
||
| } // namespace tensorflow |
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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # ============================================================================== | ||
| # Copyright 2018 Intel Corporation | ||
| # | ||
| # 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. | ||
| # ============================================================================== | ||
| """nGraph TensorFlow bridge abs operation test | ||
|
|
||
| """ | ||
| from __future__ import absolute_import | ||
| from __future__ import division | ||
| from __future__ import print_function | ||
|
|
||
| import pytest | ||
|
|
||
| import tensorflow as tf | ||
| import os | ||
|
|
||
| from common import NgraphTest | ||
|
|
||
|
|
||
| class TestAssertOperations(NgraphTest): | ||
|
|
||
| def test_disable_assert(self): | ||
| test_input = ((1, 1)) | ||
| x = tf.placeholder(tf.int32, shape=(2,)) | ||
| y = tf.placeholder(tf.int32, shape=(2,)) | ||
| z = tf.placeholder(tf.int32, shape=(2,)) | ||
| assert_op = tf.Assert(tf.less_equal(tf.reduce_max(z), 1), [x]) | ||
|
|
||
| with tf.control_dependencies([assert_op]): | ||
| a2 = tf.add(x, y) | ||
|
|
||
| def run_test(sess): | ||
| return sess.run( | ||
| a2, feed_dict={ | ||
| x: test_input, | ||
| y: test_input, | ||
| z: test_input | ||
| }) | ||
|
|
||
| assert ( | ||
| self.with_ngraph(run_test) == self.without_ngraph(run_test)).all() | ||
|
|
||
| def test_disable_assert_tf_fails_ng_pass(self): | ||
| test_input = ((2, 2)) | ||
| x = tf.placeholder(tf.int32, shape=(2,)) | ||
| y = tf.placeholder(tf.int32, shape=(2,)) | ||
| z = tf.placeholder(tf.int32, shape=(2,)) | ||
| assert_op = tf.Assert(tf.less_equal(tf.reduce_max(z), 1), [x]) | ||
|
|
||
| with tf.control_dependencies([assert_op]): | ||
| a2 = tf.add(x, y) | ||
|
|
||
| def run_test(sess): | ||
| return sess.run( | ||
| a2, feed_dict={ | ||
| x: test_input, | ||
| y: test_input, | ||
| z: test_input | ||
| }) | ||
|
|
||
| try: | ||
| self.without_ngraph(run_test) | ||
| assert False | ||
| except tf.errors.InvalidArgumentError as e: | ||
| print("hfhrhgthgutrihy") | ||
| self.with_ngraph(run_test) | ||
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.
This test wont run with the env variable in the CI, right?