-
Notifications
You must be signed in to change notification settings - Fork 3
enable ngraph context in mxnet #350
base: master
Are you sure you want to change the base?
Conversation
src/ngraph/ngraph_graph.h
Outdated
@@ -204,7 +201,8 @@ class Graph : public Node { | |||
context_(context), | |||
enable_fprop_cache(enable_fprop_cache) { | |||
fprop_cache = std::make_shared<ngraph::FpropCache>(); | |||
is_reuse_mem = context.dev_type != mxnet::Context::kNNP; | |||
is_reuse_mem = context.dev_type == mxnet::Context::CPU().dev_type || |
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.
you can use enum directly, instead of creating default and getting its type. Also, we may want to reuse mem for "ngraph:cpu" (i guess we expect users to use mx.cpu(), but just in case they decide to use ngraph:cpu).
@@ -459,6 +459,10 @@ void Compiler::DeepCopy(const nnvm::Graph& graph) { | |||
} | |||
|
|||
bool bad_type(const NodePtr& node) { | |||
if (!ngraph_context_fallback() && |
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.
we need a test for this functionality, were you able to check by exporting env.
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.
Hmm, getting an error if I export the env variable, doesn't make much sense, will debug.
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.
Fixed.
src/ngraph/ngraph_context.cc
Outdated
std::pair<std::string, int32_t> NGraphContextFromDevID(int32_t dev_id) { | ||
int32_t backend_num = dev_id >> 16; | ||
int32_t device_num = dev_id - (backend_num << 16); | ||
std::cout << "NGraphContextfromDevID " << backends.at(backend_num) << " " << device_num << " " << dev_id << std::endl; |
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.
may have to remove std::cout's.
include/mxnet/base.h
Outdated
@@ -34,6 +34,8 @@ | |||
#include <nnvm/op.h> | |||
#include <nnvm/tuple.h> | |||
#include <nnvm/symbolic.h> | |||
// ngraph context | |||
#include <mxnet/ngraph_context.h> |
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.
ngraph build guard ?
@@ -150,14 +154,14 @@ struct Context { | |||
* \return cpu::kDevMask or gpu::kDevMask | |||
*/ | |||
inline DeviceType dev_mask() const { | |||
if (dev_type == kCPUPinned || dev_type == kCPUShared || dev_type == kNNP) return kCPU; | |||
if (dev_type == kCPUPinned || dev_type == kCPUShared || dev_type == kNGraph) return kCPU; |
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.
may give compile error if built without MXNET_USE_NGRAPH
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.
Made kNGraph always compile to avoid this, but throws an error if python attempts to initialize an nGraph context when mxnet wasn't compiled with nGraph.
It didn't build for me @ashokei . |
This is the error I saw when I built with 18.04 I built with 16.04 and I got something similar |
You need to update your version of nGraph, Adam Proctor broke something a few days ago. |
|
```julia julia> x = mx.NDArray([1 2; 3 4; 5 6]) 3×2 mx.NDArray{Int64,2} @ CPU0: 1 2 3 4 5 6 julia> size(x, 1, 2, 3, 4) (3, 2, 1, 1) ```
Description
(Brief description on what this PR is about)
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments