Merged
Conversation
odashi
requested changes
Jul 19, 2018
| """ | ||
| CppDevice.set_default(device.wrapped[0]) | ||
| global py_primitiv_default_device | ||
| py_primitiv_default_device = device |
Contributor
Author
There was a problem hiding this comment.
Not required. The argument is typed statically, and it throws TypeError if a wrong argument is specified.
In [5]: Device.set_default({})
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-558a1bb96fcd> in <module>()
----> 1 Device.set_default({})
TypeError: Argument 'device' has incorrect type (expected primitiv._device.Device, got dict)
|
|
||
| @staticmethod | ||
| def raw_input(shape, vector[float] data, Device device = None, Graph graph = None): | ||
| if device is None: |
Member
There was a problem hiding this comment.
get_cpp_something may return NULL and NULL is acceptable by C++ APIs (if they received NULLs, it is replaced to the C++-side default objects). This may confuse the overall behavior.
It is good to add some Python-side functions get_default_or_die, or adding an option to get_default to raise an exception if the Python-side default object is null.
Contributor
Author
There was a problem hiding this comment.
Fixed. get_default() checks default object now.
odashi
approved these changes
Jul 20, 2018
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to #39
This branch holds default objects in the python module instead of using set/get_default() of the core library.
I checked that it works fine on Windows 10.