-
Notifications
You must be signed in to change notification settings - Fork 372
fix bugs in split converter #402
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
Conversation
} | ||
if (numRemainder) { | ||
numOutputs += 1; | ||
sizes.push_back(numRemainder); | ||
} | ||
} |
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 only modified the add_split
function in select.cpp.
Signed-off-by: Ruoqian Guo <ruoqiang@nvidia.com>
f2a9365
to
3990787
Compare
Is this really a breaking change? |
@@ -27,10 +27,13 @@ bool add_split(ConversionCtx* ctx, const torch::jit::Node* n, args& args, bool s | |||
} else { | |||
auto split_size = args[1].unwrapToInt(); | |||
numOutputs = inDimSize / split_size; | |||
if (numOutputs == 1) { | |||
numRemainder = inDimSize % split_size; | |||
for (int i = 0; i < numOutputs; 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.
style thing: use int64_t if possible
core/conversion/var/Var.cpp
Outdated
const_layer->setName(("[Freeze Tensor " + tensor_id.str() + " ]").c_str()); | ||
if (ptr_.ivalue->isTensor()) { | ||
auto tensor = ptr_.ivalue->toTensor(); | ||
if (tensor.scalar_type() == at::kLong) { |
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.
Can we remove this? #407 is adding a formal API to support this.
// Split converter generates c10::IValue which hold TensorContainer. | ||
auto output_container = ptr_.ivalue->toCustomClass<TensorContainer>(); | ||
out = output_container.get()->tensor(); |
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 looks good to me.
Previously for split, we only considered cases with split as the final output or the list unpack as the final output, which is why the bug occurred for ops that followed them.
…Var.cpp Signed-off-by: Ruoqian Guo <ruoqiang@nvidia.com>
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
Signed-off-by: Ruoqian Guo ruoqiang@nvidia.com
Description
Fix Split Converter bugs.
core/conversion/converters/select.cpp: add_split
function.Var::ITensorOrFreeze
function incore/conversion/var/Var.cpp
.In addition, i use the linters to ensure that my code matches the style guidelines. The linters changed the entire file(core/conversion/converters/impl/select.cpp) . I only modified the
add_split
part in select.cpp.Fixes #401
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: