-
Notifications
You must be signed in to change notification settings - Fork 621
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
Functional API + improved ExternalSource + improved Pipeline #1598
Conversation
!build |
CI MESSAGE: [1042036]: BUILD STARTED |
dali/python/nvidia/dali/ops.py
Outdated
|
||
if nupper > 0: | ||
out += camel[start:i].lower() | ||
out = out.replace("b_box", "bbox").replace("mx_net", "mxnet") |
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.
I think we should have a dict of special cases in one place. Here is easy to miss and extend.
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.
Yes and no. BBox is not a special case - rather a pattern. With MXNet - currently we have just one operator, but should we have more, it's already handled.
CI MESSAGE: [1042036]: BUILD PASSED |
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.
As an experimental API, if we even merge this I would first consider putting the whole thing into another module like:
nvidia.dali.experimental.ops
or nvidia.dali.experimental.eager
.
Ideally in a way, that would later allow removing the .experimental.
from the name (and maybe leaving the fallback for a while).
Still, I think it would be better to have them in module other than ops
.
If someone want's to use it, he can always alias the imported functionality.
Some documentation or at least PR description could say, that it reexports the Operators as snake_cased
functions.
We may need to introduce the EdgeReference as some first class citizen, so we can describe what it represents and how to use it in the docs. It would be also helpful for the error messages.
I would also be interested in how you plan to show those functions in docs? It would not be ideal to duplicate everything. The tensor argument inputs/python values/python lists of values would be especially tricky, as now they can be mixed in the same call.
There was also different idea to abuse the python even more and:
- pretend that we have the named inputs that can work as keyword arguments - we can do this by counting the positional inputs and checking if someone passed input as keyword.
- actually create the proper signature. This can be also useful here, we can use python-forge (the even have Dali picture on the project page :P)
https://pypi.org/project/python-forge/
Definitely it is not an eager mode. |
Yeah, just a name. |
Actually it is kinda eager in the regard how you create and parametrize the ops. |
@klecki It's not "just a name". It's not eager mode nor is it intended to be. resize
resize_cpu
resize_gpu Submodules/namespaces/whatever: ops.resize
ops.cpu.resize
ops.gpu.resize I would definitely like to keep the parametric version so the user can still provide the device as an argument - though the second solution provides a workaround: device = ops.cpu
device.resize(...) |
You all misinterpret my intention and focus on details. As for the device, I think pytorch had some experience and recent changes in that regard, we should look for hints in regard for the usability of the solution. The device argument is not the only one that will clutter the visuals of defining graph. Maybe a good thing to do would be to take some of the example pipelines that we have (especially some of the more complex/configurable ones) and to rewrite/mock them with this approach to identify what becomes harder and what easier, what are the weak points that a change in API could fix. |
373ab3d
to
5c23243
Compare
!build |
CI MESSAGE: [1060592]: BUILD STARTED |
CI MESSAGE: [1060592]: BUILD FAILED |
5c23243
to
ff07c34
Compare
!build |
CI MESSAGE: [1060685]: BUILD STARTED |
ff07c34
to
789194d
Compare
!build |
CI MESSAGE: [1060699]: BUILD STARTED |
CI MESSAGE: [1060699]: BUILD FAILED |
docs/examples/index.rst
Outdated
@@ -22,3 +22,4 @@ Tutorials | |||
audio_decoder.ipynb | |||
hsv_example.ipynb | |||
brightness_contrast_example.ipynb | |||
experimental_new_api.ipynb |
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.
I don't know if we should call it experimental?
"\n", | ||
" crop_pos = ops.Uniform(range = (0.0, 1.0))\n", | ||
" output = ops.crop_mirror_normalize(\n", | ||
" images, crop_pos_x = crop_pos(),\n", |
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.
" images, crop_pos_x = crop_pos(),\n", | |
" images,\n" | |
" crop_pos_x = crop_pos(),\n", |
I'm very much agree to use a separate module/namespace for that. |
789194d
to
2e14dc7
Compare
!build |
CI MESSAGE: [1147244]: BUILD STARTED |
55332b5
to
29fd4c1
Compare
!build |
CI MESSAGE: [1173371]: BUILD STARTED |
29fd4c1
to
a826318
Compare
Added functional API documentation, marked as experimental. Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
a826318
to
e25ddcd
Compare
CI MESSAGE: [1173447]: BUILD STARTED |
CI MESSAGE: [1173447]: BUILD PASSED |
7082edc
to
1945b46
Compare
!build |
CI MESSAGE: [1180016]: BUILD STARTED |
e6447e8
to
34428a9
Compare
CI MESSAGE: [1180145]: BUILD STARTED |
CI MESSAGE: [1180145]: BUILD PASSED |
t = _EdgeReference(t_name, output_device, self) | ||
t_name = self._name | ||
if num_output > 1: | ||
t_name += "[{}]".format(i) |
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.
Possible output name collision if the _name
is duplicated - either requires more checking or additional mangling.
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.
The docstrings for build() and set_outputs() are not rendered properly.
groups.add(group) | ||
self._input_callbacks = list(groups) | ||
|
||
def build(self, define_graph = None): |
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 adds yet another way to build a pipeline and at some point we will start causing confusion without clear doc how to do something.
Especially as this argument will now appear in docs, but just not documented.
dali/python/nvidia/dali/pipeline.py
Outdated
"""Set the outputs of the pipeline. | ||
|
||
Use of this function is an alternative to overriding `define_graph` in a derived class. | ||
|
||
Args | ||
---- | ||
`*output_data_nodes` : unpacked list of :class:`DataNode` objects | ||
The outputs of the pipeline | ||
""" |
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.
The effective docstring is all over the place in sphinx.
docs/api.rst
Outdated
.. autoclass:: nvidia.dali.backend.TensorGPU | ||
:members: | ||
:undoc-members: | ||
`Functioal API <functional_api.rst>`_ (Experimental!) section describes a psuedo-imperative API |
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.
`Functioal API <functional_api.rst>`_ (Experimental!) section describes a psuedo-imperative API | |
`Functional API <functional_api.rst>`_ (Experimental!) section describes a psuedo-imperative API |
docs/api.rst
Outdated
|
||
Tensor | ||
------ | ||
`Pipeline <pipeline.rst>`_ section describes the :class:`Pipeline` object - the central and most |
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.
`Pipeline <pipeline.rst>`_ section describes the :class:`Pipeline` object - the central and most | |
`Pipeline <pipeline.rst>`_ section describes the :class:`~nvidia.dali.pipelinePipeline` class- the central and most |
Adding the tilde is supposed to render it as only Pipeline
.
This pull request introduces 1 alert when merging f0b1c7d167e298affbdab07836666d45e8643dc6 into 107f603 - view on LGTM.com new alerts:
|
!build |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
f0b1c7d
to
687f080
Compare
CI MESSAGE: [1182951]: BUILD STARTED |
CI MESSAGE: [1182951]: BUILD PASSED |
Signed-off-by: Michal Zientkiewicz michalz@nvidia.com
Why we need this PR?
set_outputs
with
block) to manage current pipelineWhat happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
ops.py
and the example notebookJIRA TASK: DALI-1289