-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposes base
OptionsContext
class in the API
In order to support more than just the StableHloToExecutable pipeline, we need to be able to create different option types from the API. This commit exposes the base `OptionsContext` class in the Python API and includes a mechanism for child classes to register themselves with the client, allowing them to be created through a common API.
- Loading branch information
1 parent
89e2090
commit ba839d4
Showing
8 changed files
with
190 additions
and
1 deletion.
There are no files selected for viewing
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
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
29 changes: 29 additions & 0 deletions
29
mlir-tensorrt/test/python/mlir_tensorrt_compiler/compiler_api/test_options_context.py
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,29 @@ | ||
# RUN: %PYTHON %s 2>&1 | FileCheck %s | ||
|
||
import mlir_tensorrt.compiler.api as api | ||
from mlir_tensorrt.compiler.ir import * | ||
|
||
|
||
with Context() as context: | ||
client = api.CompilerClient(context) | ||
# Try to create a non-existent option type | ||
try: | ||
opts = api.OptionsContext(client, "non-existent-options-type", []) | ||
except Exception as err: | ||
print(err) | ||
|
||
opts = api.OptionsContext( | ||
client, | ||
"stable-hlo-to-executable", | ||
[ | ||
"--tensorrt-builder-opt-level=3", | ||
"--tensorrt-strongly-typed=false", | ||
"--tensorrt-workspace-memory-pool-limit=1gb", | ||
], | ||
) | ||
|
||
opts.print() | ||
|
||
|
||
# CHECK: InvalidArgument: InvalidArgument: non-existent-options-type is not a valid option type. Valid options were: stable-hlo-to-executable | ||
# CHECK: --tensorrt-timing-cache-path= --device-infer-from-host=true --debug-only= --executor-index-bitwidth=64 --entrypoint=main --plan-clustering-disallow-host-tensors-in-tensorrt-clusters=false --tensorrt-workspace-memory-pool-limit=1073741824 --device-max-registers-per-block=65536 --tensorrt-strongly-typed=false --tensorrt-layer-info-dir= --device-compute-capability=86 --debug=false --mlir-print-ir-tree-dir= --disable-tensorrt-extension=false --tensorrt-builder-opt-level=3 --tensorrt-engines-dir= |