-
Notifications
You must be signed in to change notification settings - Fork 615
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
Tensor concatenation and stacking #2350
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
!build |
CI MESSAGE: [1697570]: BUILD STARTED |
"source": [ | ||
"# Tensor joining\n", | ||
"\n", | ||
"This notebook demonstrates two metbhods of joining tensors: stacking and concatenation.\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.
"This notebook demonstrates two metbhods of joining tensors: stacking and concatenation.\n", | |
"This notebook demonstrates two methods of joining tensors: stacking and concatenation.\n", |
"\n", | ||
"Both of these operations take multiple inputs and produce the output by joining the input tensors.\n", | ||
"The difference between these methods is that concatenation joins the tensors along an existing axis, whereas stacking inserts a new axis.\n", | ||
"Stacking can be used, for example, to combine separate combine separate coordinates into vectors, or to combine color planes into color images.\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.
"Stacking can be used, for example, to combine separate combine separate coordinates into vectors, or to combine color planes into color images.\n", | |
"Stacking can be used, for example, to combine separate coordinates into vectors, or to combine color planes into color images.\n", |
src2 = dali.types.Constant(np.array( | ||
[[], | ||
[], | ||
[]], dtype=np.int32)) |
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.
Is it in purpose that only src2 has a dtype?
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.
Others have it inferred from the values - here there are no values and it defaulted to float.
dali/operators/generic/join.cc
Outdated
out.SetLayout(output_layout_); | ||
TYPE_SWITCH(out.type().id(), type2id, T, TENSOR_JOIN_TYPES, ( | ||
RunTyped(view<T>(out), ws); | ||
), (DALI_FAIL("Internal error: unsupported type reached RunImpl function"))); // NOLINT |
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.
print the 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.
If it was ever reached, then printing the type would shift attention from the real problem: that we've encountered a type that should have been rejected in Setup.
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 think the user cares how fatal the error is, and the more debug info we get from the user the better.
This argument is mutually exclusive with ``axis``. | ||
This argument requires that at least one input has a non-empty layout and that all non-empty | ||
input layouts match.)", nullptr, false) | ||
.NumInput(1, 999) |
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.
999? Just checking, did you mean 99 (I've seen it as a limit to other operators). By the way, why not 100 or 1000?
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.
Maybe we should have a define for an infinite number of inputs (999 + 1)?
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.
That's a good idea, but maybe not for this PR...?
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.
Sure
dali/operators/generic/join.cc
Outdated
.AddOptionalArg<int>("axis", R"(The axis in the output tensor along which the inputs are stacked. | ||
|
||
The axis is inserted before a corresponding axis in the inputs. A value of 0 indicates that whole | ||
tensors are stacked. Speicfying ``axis`` equal to the number of dimensions in the inputs causes |
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.
tensors are stacked. Speicfying ``axis`` equal to the number of dimensions in the inputs causes | |
tensors are stacked. Specifying ``axis`` equal to the number of dimensions in the inputs causes |
dali/operators/generic/join.cc
Outdated
the values from the inputs to be interleaved)", 0, false) | ||
.AddOptionalArg<string>("axis_name", R"(Name of the new axis to be inserted. | ||
|
||
A one-character that will denot the new axis in the output layout. The output layout will be |
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.
A one-character that will denot the new axis in the output layout. The output layout will be | |
A one-character that will denote the new axis in the output layout. The output layout will be |
dali/operators/generic/join.cc
Outdated
.AddOptionalArg<string>("axis_name", R"(Name of the new axis to be inserted. | ||
|
||
A one-character that will denot the new axis in the output layout. The output layout will be | ||
constructed by inserting that character into the input layout at position indicated by ``axis``. |
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.
constructed by inserting that character into the input layout at position indicated by ``axis``. | |
constructed by inserting that character into the input layout at the position indicated by ``axis``. |
dali/operators/generic/join.cc
Outdated
template <typename Backend, bool new_axis> | ||
void TensorJoin<Backend, new_axis>::SetupAxis() { | ||
// axis_name indicates the join axis for concatenation only; | ||
// for stacking, it's the name of the new axiis |
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.
// for stacking, it's the name of the new axiis | |
// for stacking, it's the name of the new axis |
CI MESSAGE: [1697570]: BUILD FAILED |
dali/operators/generic/join.cc
Outdated
SetupAxis(); | ||
SetOutputLayout(ws); | ||
|
||
// Run ove inputs and store them in a vector |
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.
// Run ove inputs and store them in a vector | |
// Run over inputs and store them in a vector |
@@ -0,0 +1,404 @@ | |||
{ |
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.
metbhods -> methods
combine separate combine separate coordinates into vectors -> combine separate coordinates into vectors
Reply via ReviewNB
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
!build |
CI MESSAGE: [1697830]: BUILD STARTED |
CI MESSAGE: [1697830]: BUILD PASSED |
Why we need this PR?
Pick one, remove the rest
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
any
to store type-specific data in the operator and avoid writing full-blown pImplany
for inputsJIRA TASK: DALI-1620