-
Notifications
You must be signed in to change notification settings - Fork 64
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
Sindhu/bfloat16 support #399
Merged
Merged
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
694e63c
initial commit
sindhu-nervana 2ab87c7
add bfloat16 test
sindhu-nervana b267ba1
Shrestha/var in compute (#388)
3ffb02e
disable the test
sindhu-nervana 367d3db
Kanvi/Add asserts in some python tests (#398)
kanvi-nervana 453a304
Merge branch 'master' into sindhu/bfloat16_support
sindhu-nervana 22e7755
Merge branch 'master' into sindhu/bfloat16_support
c6220b7
Merge branch 'master' into sindhu/bfloat16_support
kanvi-nervana bea7c4d
Merge branch 'master' into sindhu/bfloat16_support
4cfb27f
added test
266b24a
changes
062a3c3
added another test
f00e298
added another bfloat test. encapsulate always assigned device CPU
5644eb6
Merge remote-tracking branch 'origin/master' into sindhu/bfloat16_sup…
0a4ffdd
removed couts, rearranged the tests
80c46f8
device checks
eb145c7
fix by registering dummy bfloat kernel
4d91711
Merge remote-tracking branch 'origin/master' into sindhu/bfloat16_sup…
5f08083
hanging include
e50323a
changes
e35892d
minor
a95c92f
Register Stub Kernels
5d313e3
fix bazel build
f636278
update comment
d2a161f
added comments to the test
1e4923c
corrected the macros
0bb58e0
fix template
957bf01
Merge remote-tracking branch 'origin/master' into sindhu/bfloat16_sup…
9fce56c
incorporate review comments
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 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 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 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 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,72 @@ | ||
/******************************************************************************* | ||
* Copyright 2019-2020 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 "tensorflow/core/framework/op.h" | ||
#include "tensorflow/core/framework/op_kernel.h" | ||
|
||
#include "ngraph_bridge/ngraph_register_stub_kernels.h" | ||
|
||
using namespace std; | ||
|
||
namespace tensorflow { | ||
|
||
namespace ngraph_bridge { | ||
|
||
/* ------------------------------------------------- | ||
// | ||
// NGraphStubOp | ||
// | ||
---------------------------------------------------*/ | ||
// Constructor | ||
NGStubOp::NGStubOp(OpKernelConstruction* context) : OpKernel(context) { | ||
OP_REQUIRES( | ||
context, false, | ||
errors::Internal("The constructor for OpType ", type_string(), | ||
"should not get called. This Op is expected to have " | ||
"been encapsulated or replaced by other ops. Op Name: ", | ||
name(), "\n")); | ||
} | ||
// Compute | ||
void NGStubOp::Compute(OpKernelContext* context) { | ||
OP_REQUIRES( | ||
context, false, | ||
errors::Internal("This kernel for OpType ", type_string(), | ||
"should not get called. This Op is expected to have " | ||
"been encapsulated or replaced by other ops. Op Name: ", | ||
name(), "\n")); | ||
} | ||
// Destructor | ||
NGStubOp::~NGStubOp() {} | ||
|
||
/* ------------------------------------------------- */ | ||
|
||
// Register Bfloat Stub Kernels | ||
|
||
// TF Ops that work on bfloat DataType get assigned Device XLA_CPU | ||
// Since nGraph-bridge OPs work on TF DEVICE_CPU we are registering stub | ||
// bfloat16 | ||
// kernels here. The expectation is when we register the stub kernels for | ||
// bfloat16 | ||
// TF is going to assign DEVICE_CPU to the respective Ops and we will | ||
// encapsulate them | ||
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. // Since nGraph-bridge OPs work on TF DEVICE_CPU we are registering stub |
||
// These Stub Kernels/Op will never get called | ||
|
||
// Keep them in alphabetical order | ||
REGISTER_NGRAPH_STUB_BFLOAT_KERNEL("Conv2D") | ||
|
||
} // namespace ngraph_bridge | ||
|
||
} // namespace tensorflow |
This file contains 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,56 @@ | ||
/******************************************************************************* | ||
* Copyright 2019-2020 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. | ||
*******************************************************************************/ | ||
#ifndef NGRAPH_TF_BRIDGE_REGISTER_STUB_KERNELS_H_ | ||
#define NGRAPH_TF_BRIDGE_REGISTER_STUB_KERNELS_H_ | ||
|
||
#include "tensorflow/core/framework/op.h" | ||
#include "tensorflow/core/framework/op_kernel.h" | ||
|
||
using namespace std; | ||
|
||
namespace tensorflow { | ||
|
||
namespace ngraph_bridge { | ||
|
||
/* ------------------------------------------------- | ||
// | ||
// NGStubOp | ||
// | ||
---------------------------------------------------*/ | ||
|
||
class NGStubOp : public OpKernel { | ||
public: | ||
explicit NGStubOp(OpKernelConstruction* context); | ||
|
||
void Compute(OpKernelContext* context) override; | ||
|
||
private: | ||
~NGStubOp() override; | ||
}; | ||
|
||
#define REGISTER_NGRAPH_STUB_KERNEL(optype) \ | ||
REGISTER_KERNEL_BUILDER(Name(optype).Device(DEVICE_CPU), NGStubOp); | ||
|
||
#define REGISTER_NGRAPH_STUB_BFLOAT_KERNEL(optype) \ | ||
REGISTER_KERNEL_BUILDER( \ | ||
Name(optype).Device(DEVICE_CPU).TypeConstraint<bfloat16>("T"), \ | ||
NGStubOp); | ||
|
||
} // namespace ngraph_bridge | ||
|
||
} // namespace tensorflow | ||
|
||
#endif // NGRAPH_TF_BRIDGE_REGISTER_STUB_KERNELS_H_ |
This file contains 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
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.
REGISTER_NGRAPH_STUB_KERNEL
registers only for bfloat type? since its defn is:in that case is this replacement ok?
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.
changed the macros. the names were not matching the definition.