Skip to content

Introduce OutputDoc#1828

Closed
klecki wants to merge 1 commit into
NVIDIA:masterfrom
klecki:output-dox
Closed

Introduce OutputDoc#1828
klecki wants to merge 1 commit into
NVIDIA:masterfrom
klecki:output-dox

Conversation

@klecki

@klecki klecki commented Mar 18, 2020

Copy link
Copy Markdown
Contributor

Why we need this PR?

We want better docs

What happened in this PR?

  • What solution was applied:
    [
    Introduce OutputDoc and OutputDocStr as a mechanism for creating Returns section for Operator __call__, similar to InputDoc & InputDocString that were already present.
    Fill it for most operators with non-trivial returns.
    ]
  • Affected modules and functionalities:
    [
    OpSchema, ops.py - docstring generator, docs of some Ops
    ]
  • Key points relevant for the review:
    [
    Please suggest how to better document shapes and operators with variable number of outputs.
    ]
  • Validation and testing:
    [ Needs some proofreading mostly and looking through generated docs ]
  • Documentation (including examples):
    [ Most certainly ]

JIRA TASK: [Use DALI-XXXX or NA]

@klecki

klecki commented Mar 18, 2020

Copy link
Copy Markdown
Contributor Author

!build

@klecki klecki changed the title Introduce OutputDoc and fill it for most operator with non-trivaial returns Introduce OutputDoc and fill it for most operators with non-trivial returns Mar 18, 2020
@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [1197587]: BUILD STARTED

@mzient mzient Mar 18, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.OutputDoc(1, "sampling_rage", "TensorList of float", "Batch of sampling rates [Hz]")
.OutputDoc(1, "sampling_rate", "TensorList of float", "The sampling rates corresponding to the decoded sound recordings [Hz]")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done xD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.OutputDoc(0, "decoded", "TensorList of int16, int32 or float", "Batch of decoded data")
.OutputDoc(0, "decoded", "TensorList of int16, int32 or float", "The decoded audio recordings")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread dali/operators/audio/nonsilence_op.cc Outdated

@mzient mzient Mar 18, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.OutputDoc(0, "start", "TensorList of int", "Begin indices of nonsilent regions")
.OutputDoc(0, "start", "TensorList of int", "Start positions, in samples, of nonsilent regions")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread dali/operators/audio/nonsilence_op.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.OutputDoc(1, "length", "TensorList of int", "Lengths of nonsilent regions")
.OutputDoc(1, "length", "TensorList of int", "Lengths, in samples, of nonsilent regions")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread dali/operators/reader/file_reader_op.cc Outdated

@mzient mzient Mar 18, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.OutputDoc(0, "images", "1D TensorList of uint8", "Undecoded image data")
.OutputDoc(0, "data", "1D TensorList of uint8", "Raw file contents")

This reader can also be used for audio or whatever else...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right. Probably same with others.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
.OutputDoc(0, "images", "1D TensorList of uint8", "Undecoded image data")
.OutputDoc(0, "data", "1D TensorList of uint8", "Raw data buffers")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread dali/pipeline/operator/op_schema.h Outdated
Comment on lines 655 to 677

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I will remove it, I'm still working on some parts and wanted to render the docs for everyone to see.

Comment thread dali/pipeline/operator/op_schema.h Outdated
Comment on lines 827 to 833

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This monster should go back to the fiery chasm from whence it came ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread dali/pipeline/operator/op_schema.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [1197587]: BUILD PASSED

Comment thread dali/pipeline/operator/op_schema.cc Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Output dox cannot be used when the AdditionalOutputFn was set");
"Output doc cannot be used when the AdditionalOutputFn was set");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread dali/operators/image/crop/bbox_crop.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this will change as soon as I merge my BBox PR. I am no longer using the ltrb terminology, and now you can have an arbitrary order of the coordinates

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will wait for your PR, and replace those docs, it's basically placeholder taken from the docstring (as is in other places...).

Comment thread dali/operators/image/crop/bbox_crop.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

about to change as we'll support 3d as well (same below)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Took changes from your PR.

Comment thread dali/operators/image/crop/bbox_crop.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.InputDoc(0, "BBoxes", "TensorList of floats",
.InputDoc(0, "bboxes", "TensorList of floats",

Either all lowercase or all capitalized

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread dali/operators/image/crop/bbox_crop.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it's {batch_size, m}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope,

void RandomBBoxCrop<CPUBackend>::WriteLabelsToOutput(
  SampleWorkspace &ws, const std::vector<int> &labels) const {
  auto &labels_out = ws.Output<CPUBackend>(3);
  labels_out.Resize({static_cast<Index>(labels.size()), 1});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But it still more like batch * {m_i, 1}, where m_i is different for every sample i

Comment thread dali/operators/image/crop/bbox_crop.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

4 will change. Also, it's not clear what m stands for

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to rephrase it better. m was taken from the current description that was just using it. I'm also not sure what it stands for :P

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"If provided, the output is given the same shape as `data` and the contents are ignored")
"If provided, the output is given the same shape as `data` (data contents are ignored)")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
undecoded image data, only if image_available = true
encoded image data, only if image_available = true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd write "optical flow" instead of OF

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the rest of the doc already use OF extensively.

@jantonguirao jantonguirao Apr 10, 2020

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ok then, but I don't like using "OF" as if it was a well-established acronym

Comment thread dali/operators/ssd/box_encoder.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same comments as before

Comment thread dali/pipeline/operator/op_schema.h Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
std::string name = {};
std::string name;

isn't it the same?

Comment thread dali/pipeline/operator/op_schema.h Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
std::vector<InOutDoc> input_dox_ = {};
std::vector<InOutDoc> input_dox_;

?

Comment thread dali/pipeline/operator/op_schema.h Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

@klecki

klecki commented Mar 20, 2020

Copy link
Copy Markdown
Contributor Author

!build

@klecki

klecki commented Mar 20, 2020

Copy link
Copy Markdown
Contributor Author

Waits for #1785 to stabilize the docs.

@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [1202805]: BUILD STARTED

@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [1202805]: BUILD PASSED

…eturns

Introduce OutputDoc and OutputDocStr as a mechanism
for creating Returns section for Operator __call__,
 similar to InputDoc & InputDocString that were already present.

Allow for unnamed outputs

Signed-off-by: Krzysztof Lecki <klecki@nvidia.com>
@klecki

klecki commented Mar 26, 2020

Copy link
Copy Markdown
Contributor Author

!build

@klecki klecki changed the title Introduce OutputDoc and fill it for most operators with non-trivial returns Introduce OutputDoc Mar 26, 2020
@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [1214698]: BUILD STARTED

@dali-automaton

Copy link
Copy Markdown
Collaborator

CI MESSAGE: [1214698]: BUILD PASSED

)code")
.NumInput(1)
.NumOutput(2)
.OutputDoc(0, "decoded", "TensorList of int16, int32 or float", "The decoded audio recordings.")

@jantonguirao jantonguirao Apr 10, 2020

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I remember the conclusion was to start using TensorList for describing outputs. Wasn't it?

``{m_i ,4}`` Tensor (``m_i * [x, y, w, h]`` or ``m_i * [left, top, right, bottom]``)
and labels as ``{m_i, 1}`` Tensor (``m * category_id``).)code")
.OutputDocStr(R"code(images : 1D TensorList of uint8
Encoded image data.s.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is data.s.?

@klecki klecki marked this pull request as draft April 22, 2020 10:54
@klecki klecki mentioned this pull request Apr 27, 2020
3 tasks
@klecki

klecki commented May 14, 2020

Copy link
Copy Markdown
Contributor Author

Continued in #1908

@klecki klecki closed this May 14, 2020
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.

5 participants