Skip to content

fix(//core/conversion/converters/Weights): Fix buffer allocation for weights data #378

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

Merged
merged 2 commits into from
Feb 25, 2021

Conversation

narendasan
Copy link
Collaborator

Description

The memcpy for weights tensors over copies when the Tensor is not a FP32 tensor. This seems to be the root cause of segfaults observed in #326 as well as failing DLA tests on aarch64 when users try to compile a model that is already in FP16.

Fixes #326

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes

weights data that occassionally may cause segfaults and causes issues
with importing FP16 weights

Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler labels Feb 25, 2021
@narendasan
Copy link
Collaborator Author

@andi4191 can you verify this change fixes the observed segfaults?

@narendasan narendasan requested a review from andi4191 February 25, 2021 20:45
@narendasan
Copy link
Collaborator Author

I would still say that the compiler should still not be considered thread-safe yet. There's at least a few parts that may still have issues (Logger, Runtime).

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

@andi4191
Copy link
Contributor

Tested it for a few iterations. It passes everytime.

Copy link
Contributor

@andi4191 andi4191 left a comment

Choose a reason for hiding this comment

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

Minor comment. LGTM

@@ -80,9 +80,29 @@ Weights::Weights(ConversionCtx* ctx, at::Tensor t) {

// Store the data in the conversion context so it remains until building is
// complete
void* buf = malloc(t_cpu.numel() * sizeof(float));

void* buf;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be initialized to nullptr.

Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to C++ style guidelines

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Code conforms to Python style guidelines

@narendasan narendasan merged commit 721b071 into master Feb 25, 2021
@narendasan narendasan deleted the fix_multithreaded_fp16 branch February 25, 2021 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

❓ [Question] Is there a way to do multithreaded half-precision compilation?
2 participants