-
Notifications
You must be signed in to change notification settings - Fork 14
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
WIP: Adding TRT options/task #435
Draft
pranavm-nvidia
wants to merge
11
commits into
main
Choose a base branch
from
trt-task
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9fc6f31
initial commit
pranavm-nvidia e50393b
review comments
pranavm-nvidia b95a52a
add todo
pranavm-nvidia 04bfde2
add passes
pranavm-nvidia 88d48b9
fix compile
pranavm-nvidia 7965ac4
Merge branch 'main' of github.com:NVIDIA/TensorRT-Incubator into trt-…
yizhuoz004 9183619
Add OutlineTensorRTOpPass
yizhuoz004 6e552ca
Add pybindings for TensorRTToExecutableOptions
yizhuoz004 bd34da5
Remove pybindings
yizhuoz004 065d7e3
Address comments
yizhuoz004 a0c1876
Add dependent dialect, fix outlineOp pass
yizhuoz004 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
mlir-tensorrt/compiler/include/mlir-tensorrt/Compiler/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
add_subdirectory(StablehloToExecutable) | ||
add_subdirectory(TensorRTToExecutable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
mlir-tensorrt/compiler/include/mlir-tensorrt/Compiler/TensorRTToExecutable/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
set(_TABLEGEN_ARGS ) | ||
set(LLVM_TARGET_DEFINITIONS Passes.td) | ||
mlir_tablegen(Passes.h.inc -gen-pass-decls -name TensorRTToExecutable ${_TABLEGEN_ARGS}) | ||
add_public_tablegen_target(MLIRTensorRTTensorRTToExecutableIncGen) |
49 changes: 49 additions & 0 deletions
49
mlir-tensorrt/compiler/include/mlir-tensorrt/Compiler/TensorRTToExecutable/Passes.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//===- Passes.h ----------------------------------------------===// | ||
// | ||
// SPDX-FileCopyrightText: Copyright 2025 NVIDIA CORPORATION & AFFILIATES. | ||
// All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// Declarations for opt tool pipeline command-line registration for pipelines | ||
/// related to "tensorrt-to-executable". | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE_PASSES | ||
#define MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE_PASSES | ||
|
||
#include <memory> | ||
#include <mlir/Pass/Pass.h> | ||
|
||
namespace mlirtrt::compiler { | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Add Tablegen'd pass declarations and registration methods. | ||
//===----------------------------------------------------------------------===// | ||
#define GEN_PASS_DECL | ||
#define GEN_PASS_REGISTRATION | ||
#include "mlir-tensorrt/Compiler/TensorRTToExecutable/Passes.h.inc" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// Pipeline Registrations | ||
//===----------------------------------------------------------------------===// | ||
|
||
/// Register the TensorRT clustering and compilation pipelines. | ||
void registerTensorRTToExecutablePipelines(); | ||
|
||
} // namespace mlirtrt::compiler | ||
|
||
#endif // MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE_PASSES |
38 changes: 38 additions & 0 deletions
38
mlir-tensorrt/compiler/include/mlir-tensorrt/Compiler/TensorRTToExecutable/Passes.td
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//===- Passes.td ----------------------------------------------------------===// | ||
// | ||
// SPDX-FileCopyrightText: Copyright 2025 NVIDIA CORPORATION & AFFILIATES. | ||
// All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE_PASSES | ||
#define MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE_PASSES | ||
|
||
include "mlir/Pass/PassBase.td" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// OutlineTensorRTOpPass | ||
//===----------------------------------------------------------------------===// | ||
|
||
def OutlineTensorRTOpPass : Pass<"outline-tensorrt-op", | ||
"::mlir::ModuleOp"> { | ||
let summary = "Outline all tensorrt ops into a tensorrt module"; | ||
|
||
let dependentDialects = [ | ||
"::mlir::plan::PlanDialect" | ||
]; | ||
} | ||
|
||
#endif // MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE_PASSES |
97 changes: 97 additions & 0 deletions
97
...sorrt/compiler/include/mlir-tensorrt/Compiler/TensorRTToExecutable/TensorRTToExecutable.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
//===- TensorRTToExecutable.h -----------------------------------*- C++ -*-===// | ||
// | ||
// SPDX-FileCopyrightText: Copyright 2025 NVIDIA CORPORATION & AFFILIATES. | ||
// All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE | ||
#define MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE | ||
|
||
// TODO (pranavm): MLIR_TRT_TARGET_TENSORRT is only needed because we pull in | ||
// the TranslateToTensorRT.h header. If we move the translation options, we | ||
// won't need it. | ||
#ifdef MLIR_TRT_TARGET_TENSORRT | ||
#include "mlir-tensorrt-dialect/Target/TranslateToTensorRT.h" | ||
|
||
#include "mlir-tensorrt-dialect/Utils/OptionsBundle.h" | ||
#include "mlir-tensorrt/Compiler/Client.h" | ||
|
||
namespace mlirtrt::compiler { | ||
|
||
//===----------------------------------------------------------------------===// | ||
// TensorRTToExecutableOptions | ||
//===----------------------------------------------------------------------===// | ||
|
||
class TensorRTToExecutableTask; | ||
|
||
// TODO (pranavm): Figure out a better way to reuse TRT translation options - | ||
// maybe move to options providers? | ||
struct TensorRTOptions : public OptionsProvider<TensorRTOptions> { | ||
public: | ||
using OptionsProvider::OptionsProvider; | ||
mlir::tensorrt::TensorRTTranslationOptions options; | ||
|
||
TensorRTOptions(mlir::OptionsContext &ctx) : OptionsProvider(ctx) { | ||
options.addToOptions(ctx); | ||
} | ||
}; | ||
|
||
struct TensorRTToExecutableOptions | ||
: public mlir::OptionsBundle<DeviceOptions, DebugOptions, ExecutorOptions, | ||
TensorRTOptions> { | ||
// Default initialization does not require any extensions. | ||
TensorRTToExecutableOptions() = default; | ||
|
||
TensorRTToExecutableOptions(TaskExtensionRegistry extensions); | ||
|
||
Option<std::string> entrypoint{this, "entrypoint", llvm::cl::init("main"), | ||
llvm::cl::desc("entrypoint function name")}; | ||
}; | ||
|
||
//===----------------------------------------------------------------------===// | ||
// TensorRTToExecutableTask | ||
//===----------------------------------------------------------------------===// | ||
|
||
class TensorRTToExecutableTask | ||
: public CompilationTask<TensorRTToExecutableTask, | ||
TensorRTToExecutableOptions> { | ||
public: | ||
TensorRTToExecutableTask(mlir::MLIRContext *ctx, | ||
const TensorRTToExecutableOptions &options); | ||
|
||
/// Build the clustering pipeline that occurs on TensorRT Ops. | ||
static void | ||
buildTensorRTClusteringPipeline(mlir::OpPassManager &pm, | ||
const TensorRTToExecutableOptions &options); | ||
|
||
/// Build the compilation pipeline that runs after clustering. | ||
static void | ||
buildPostClusteringPipeline(mlir::OpPassManager &pm, | ||
const TensorRTToExecutableOptions &options); | ||
|
||
static void populatePassManager(mlir::PassManager &pm, | ||
const TensorRTToExecutableOptions &options); | ||
}; | ||
|
||
/// Register the task/options with the client's registry. | ||
void registerTensorRTToExecutableTask(); | ||
|
||
} // namespace mlirtrt::compiler | ||
|
||
MLIR_DECLARE_EXPLICIT_TYPE_ID(mlirtrt::compiler::TensorRTToExecutableTask) | ||
|
||
#endif | ||
#endif // MLIR_TENSORRT_COMPILER_TENSORRTTOEXECUTABLE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
mlir-tensorrt/compiler/lib/Compiler/TensorRTToExecutable/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
add_mlir_tensorrt_library(MLIRTensorRTCompilerTensorRTToExecutable | ||
TensorRTToExecutable.cpp | ||
Passes.cpp | ||
|
||
PARTIAL_SOURCES_INTENDED | ||
|
||
DEPENDS | ||
MLIRTensorRTTensorRTToExecutableIncGen | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
MLIRTensorRTRegistration | ||
MLIRTensorRTTargetLua | ||
MLIRTensorRTOptionUtils | ||
MLIRTensorRTTargetTensorRT | ||
MLIRTensorRTCompilerClient | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 catch-all library has been removed in a commit which hasn't been sync'd up yet. Just remove this and add in dependent libraries explicitly.