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
Add docs for arithmetic expressions #1600
Conversation
!build |
CI MESSAGE: [1042500]: BUILD STARTED |
CI MESSAGE: [1042500]: 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.
LGTM, except for a few comments
dali/python/nvidia/dali/types.py
Outdated
will be passed to DALI as `int32` and the floating point values as `float32`. | ||
Python builtin types `bool`, `int` and `float` will also be treated as those types. | ||
"""Wrapper for a constant value that can be used in DALI arithmetic expressions | ||
and applied elemtiwse to the results of DALI Operators representing Tensors in |
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.
and applied elemtiwse to the results of DALI Operators representing Tensors in | |
and applied elementwise to the results of DALI Operators representing Tensors in |
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.
Done 🤦♂️
docs/supported_ops.rst
Outdated
DALI allows using regular Python arithmetic operations within :meth:`~nvidia.dali.pipeline.Pipeline.define_graph` | ||
method on the values returned from invoking other operators. | ||
|
||
The expressions used will be incorporated into Pipeline without the need to explicitly instantiate operators |
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 expressions used will be incorporated into Pipeline without the need to explicitly instantiate operators | |
The expressions used will be incorporated into the Pipeline without the need to explicitly instantiate operators |
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.
Done
docs/supported_ops.rst
Outdated
The expressions used will be incorporated into Pipeline without the need to explicitly instantiate operators | ||
and will describe element-wise operations on Tensors. | ||
|
||
At least one of the inputs must be Tensor input that is returned by other DALI Operator. |
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.
At least one of the inputs must be Tensor input that is returned by other DALI Operator. | |
At least one of the inputs must be a Tensor input that is returned by other DALI Operator. |
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.
Done
docs/supported_ops.rst
Outdated
As the operations performed are element-wise, the shapes of all operands must match. | ||
|
||
.. note:: | ||
If one of the operands is a batch of Tensors representig scalars the scalar values |
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.
If one of the operands is a batch of Tensors representig scalars the scalar values | |
If one of the operands is a batch of Tensors representing scalars, the scalar values |
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.
Done
docs/supported_ops.rst
Outdated
|
||
.. note:: | ||
If one of the operands is a batch of Tensors representig scalars the scalar values | ||
are *broadcasted* to other operand. |
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.
are *broadcasted* to other operand. | |
are *broadcasted* to the other operand. |
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.
Done
docs/supported_ops.rst
Outdated
.. function:: Unary arithmetic operators: +, - | ||
|
||
Unary operators implementing `__pos__(self)` and `__neg__(self)`. | ||
The result of unary arithmetic operation always keeps the input 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.
The result of unary arithmetic operation always keeps the input type. | |
The result of a unary arithmetic operation always keeps the input 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.
Done. an
docs/supported_ops.rst
Outdated
Type promotions are commutative. | ||
|
||
.. note:: | ||
Only allowed arithmetic operation between two `bool` values is multiplication `*`. |
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.
Only allowed arithmetic operation between two `bool` values is multiplication `*`. | |
The only allowed arithmetic operation between two `bool` values is multiplication `*`. |
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.
Done
docs/supported_ops.rst
Outdated
|
||
.. function:: Comparison operations: ==, !=, <, <=, >, >= | ||
|
||
Comparison operations. Before applying compa |
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.
compa?
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.
Leftover.
docs/supported_ops.rst
Outdated
|
||
.. function:: Bitwise binary operations: &, |, ^ | ||
|
||
The bitwise binary operations abide the same type promotion rules as arithmetic binary operations, |
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 bitwise binary operations abide the same type promotion rules as arithmetic binary operations, | |
The bitwise binary operations abide by the same type promotion rules as the arithmetic binary operations, |
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.
Done
docs/supported_ops.rst
Outdated
but their inputs are restricted to integral types (`bool` included). | ||
|
||
.. note:: | ||
Bitwise operation can be applied to two boolean inputs. Those operations can be used |
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.
Bitwise operation can be applied to two boolean inputs. Those operations can be used | |
A bitwise operation can be applied to two boolean inputs. Those operations can be used |
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.
Done
!build |
CI MESSAGE: [1054637]: BUILD STARTED |
Add explicit documentation for arithmetic expressions. As of now they are only documented with verbose examples. This commit adds short documentation for existing operations as well as turns on autodoc for dali.types.Constant. It also adjust the docstring there. Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
!build |
CI MESSAGE: [1054649]: BUILD STARTED |
CI MESSAGE: [1054649]: BUILD PASSED |
Why we need this PR?
To have short, concise and explicit docs for supported arithmetic ops other than verbose examples.
What happened in this PR?
Add explicit documentation for arithmetic
expressions. As of now they are only
documented with verbose examples.
This commit adds short documentation for
existing operations as well as turns
on autodoc for dali.types.Constant.
It also adjust the docstring there.
The formatting is using a bit of a hack to introduce a section title and return type
with
.. function::
markerSupported Operations & API docs.
Look if the formatting is ok and the description is clear.
Local & CI docs build
Described above, this is a docs update.
JIRA TASK: [1213]