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

Fix: Layer norm Torchscript converter #3062

Merged
merged 3 commits into from
Aug 15, 2024
Merged

Fix: Layer norm Torchscript converter #3062

merged 3 commits into from
Aug 15, 2024

Conversation

narendasan
Copy link
Collaborator

Description

Fixes the broadcast implementation from the layer norm converter in TorchScript

Fixes # (issue)

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
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added component: tests Issues re: Tests component: conversion Issues re: Conversion stage component: core Issues re: The core compiler component: converters Issues re: Specific op converters labels Aug 5, 2024
@github-actions github-actions bot requested a review from zewenli98 August 5, 2024 22:49
@narendasan narendasan force-pushed the fix_ts_tests branch 3 times, most recently from 2623220 to 1eebc04 Compare August 6, 2024 02:23
@github-actions github-actions bot added component: runtime component: lowering Issues re: The lowering / preprocessing passes labels Aug 6, 2024
@narendasan narendasan force-pushed the fix_ts_tests branch 2 times, most recently from e3bb75d to 3e9b73f Compare August 7, 2024 18:49
Copy link
Collaborator

@peri044 peri044 left a comment

Choose a reason for hiding this comment

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

LGTM, minor comments

gamma = tensor_to_const(ctx, gamma_torch_tensor);
} else {
gamma = args[2].ITensorOrFreeze(ctx);
gamma = broadcast(ctx, n, gamma, input_shape_vec.size(), "gamma");
// gamma = broadcast(ctx, n, gamma, input_shape_vec.size(), "gamma");
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment can be removed

beta = tensor_to_const(ctx, beta_torch_tensor);
} else {
beta = args[3].ITensorOrFreeze(ctx);
beta = broadcast(ctx, n, beta, input_shape_vec.size(), "beta");
// beta = broadcast(ctx, n, beta, input_shape_vec.size(), "beta");
Copy link
Collaborator

Choose a reason for hiding this comment

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

comment can be removed

@github-actions github-actions bot removed the component: lowering Issues re: The lowering / preprocessing passes label Aug 15, 2024
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.

There are some changes that do not conform to C++ style guidelines:

diff --git a/home/runner/work/TensorRT/TensorRT/core/runtime/execute_engine.cpp b/tmp/changes.txt
index d21aa5e..6b75397 100644
--- a/home/runner/work/TensorRT/TensorRT/core/runtime/execute_engine.cpp
+++ b/tmp/changes.txt
@@ -351,16 +351,16 @@ std::vector<at::Tensor> execute_engine(std::vector<at::Tensor> inputs, c10::intr
    // If in CUDAGraph mode, results need to be copied to the result buffers (on caller stream)
    for (size_t o = 0; o < compiled_engine->output_buffers.size(); o++) {
      outputs[o].copy_(compiled_engine->output_buffers[o], false);
-  }
+    }

-  if (compiled_engine->profile_execution) {
-    LOG_INFO(std::endl << *compiled_engine->trt_engine_profiler);
-    dump_trace(compiled_engine->trt_engine_profile_path, *compiled_engine->trt_engine_profiler);
-    compiled_engine->dump_engine_layer_info();
-  }
+    if (compiled_engine->profile_execution) {
+      LOG_INFO(std::endl << *compiled_engine->trt_engine_profiler);
+      dump_trace(compiled_engine->trt_engine_profile_path, *compiled_engine->trt_engine_profiler);
+      compiled_engine->dump_engine_layer_info();
+    }

-  return outputs;
-}
+    return outputs;
+  }

} // namespace runtime
} // namespace core
ERROR: Some files do not conform to style guidelines

Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
@github-actions github-actions bot added the component: lowering Issues re: The lowering / preprocessing passes label Aug 15, 2024
BERT test is failing because of data dependent intermediate values
which aren't supported in the TS frontend

Signed-off-by: Naren Dasan <naren@nvidia.com>
Signed-off-by: Naren Dasan <naren@narendasan.com>
@narendasan narendasan merged commit 9bbba4f into main Aug 15, 2024
37 of 67 checks passed
@narendasan narendasan deleted the fix_ts_tests branch August 15, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: lowering Issues re: The lowering / preprocessing passes component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants