Skip to content
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

Merged
merged 1 commit into from Jan 2, 2020
Merged

Conversation

klecki
Copy link
Contributor

@klecki klecki commented Dec 20, 2019

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?

  • What solution was applied:

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:: marker

  • Affected modules and functionalities:

Supported Operations & API docs.

  • Key points relevant for the review:

Look if the formatting is ok and the description is clear.

  • Validation and testing:

Local & CI docs build

  • Documentation (including examples):

Described above, this is a docs update.

JIRA TASK: [1213]

@klecki
Copy link
Contributor Author

klecki commented Dec 20, 2019

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1042500]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1042500]: BUILD PASSED

Copy link
Contributor

@jantonguirao jantonguirao left a 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

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
and applied elemtiwse to the results of DALI Operators representing Tensors in
and applied elementwise to the results of DALI Operators representing Tensors in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🤦‍♂️

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


.. note::
If one of the operands is a batch of Tensors representig scalars the scalar values
are *broadcasted* to other operand.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
are *broadcasted* to other operand.
are *broadcasted* to the other operand.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.. function:: Unary arithmetic operators: +, -

Unary operators implementing `__pos__(self)` and `__neg__(self)`.
The result of unary arithmetic operation always keeps the input type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The result of unary arithmetic operation always keeps the input type.
The result of a unary arithmetic operation always keeps the input type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. an

Type promotions are commutative.

.. note::
Only allowed arithmetic operation between two `bool` values is multiplication `*`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Only allowed arithmetic operation between two `bool` values is multiplication `*`.
The only allowed arithmetic operation between two `bool` values is multiplication `*`.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


.. function:: Comparison operations: ==, !=, <, <=, >, >=

Comparison operations. Before applying compa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compa?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover.


.. function:: Bitwise binary operations: &, |, ^

The bitwise binary operations abide the same type promotion rules as arithmetic binary operations,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@klecki
Copy link
Contributor Author

klecki commented Jan 2, 2020

!build

@dali-automaton
Copy link
Collaborator

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>
@klecki
Copy link
Contributor Author

klecki commented Jan 2, 2020

!build

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1054649]: BUILD STARTED

@dali-automaton
Copy link
Collaborator

CI MESSAGE: [1054649]: BUILD PASSED

@klecki klecki merged commit d53b6f7 into NVIDIA:master Jan 2, 2020
@klecki klecki deleted the expr-doc-00 branch January 2, 2020 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants