torch_tensorrt Reorganization and API #656
Replies: 4 comments 10 replies
-
|
@narendasan, what's the thought with with |
Beta Was this translation helpful? Give feedback.
-
|
What is the intended use of |
Beta Was this translation helpful? Give feedback.
-
|
One question I had @ncomly-nvidia @peri044 is when a user gives us |
Beta Was this translation helpful? Give feedback.
-
|
There’s a default argument but it exists so in the future if there’s multiple paths users can specify that we should use one particular one
…________________________________
From: Vinh Nguyen ***@***.***>
Sent: Thursday, October 21, 2021 8:45:36 PM
To: NVIDIA/TRTorch ***@***.***>
Cc: Naren Dasan ***@***.***>; Mention ***@***.***>
Subject: Re: [NVIDIA/TRTorch] torch_tensorrt Reorganization and API (Discussion #656)
if we do conversion nevertheless, regardless of a mis-specification on user part, then do we need users to specify 'ir' after all?
Or should torch-tensorrt just detect what input it actually receives?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#656 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AANVFFOQ243RUL2ER5EGTJDUICX3BANCNFSM5FUKWQ3Q>.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
torch_tensorrt package structure
Python
With the incoming rebrand and a needing the space to be able to support alternative intermediate representations, we need to define a package structure and high level apis. The philosophy here is that the top level api will be two generalist wrapper functions:
compileandconvert_method_to_trt_engine(now is a good time to change this name). These functions will take a module of some format (torch.nn.Module,torch.jit.ScriptModule, etc) and a set of settings passed as kwargs (ones that are universal will be explicitly defined like inputs or enabled_precisions, but ir specific options like fallback will be behind **kwargs). Internal to the top level function will be a router that calls compile functions for specific ir formats. This can be controlled explicitly by setting theirflag to select a path. [Should an explicit selection be rigid or try its best to convert? e.g if the user sets theirflag totorchscriptbut provides antorch.nn.Moduleshould we convert totorch.nn.Module?]. In the the case they setirtodefaultit goes through our preference of IR to TRT. Default also means we will take what ever users provide in mod and do our best to compile. So in the case oftorch.nn.Modulewe would convert to torchscript for people viatorch.jit.script. The default option lets us change the default code path under the hood without shifting the API.The top level package will also contain general purpose classes that will be used across IR compilers
TL:
torch_tensorrttorch.nn.Moduletorch.jit.script, if it fails print error saying convert explicitly before hand by script or tracetorch.jit.ScriptModule or nn.Moduleir="default"
torch.nn.Moduletorch.jit.script, if it fails print error saying convert explicitly before hand by script or traceir="torchscript" or ir="ts"
torch.jit.ScriptModule???ir="fx"
torch_tensorrt.dump_build_info()torch_tensorrt.Inputtorch_tensorrt.Devicetorch_tensorrt.dtypetorch_tensorrt.DeviceTypetorch_tensorrt.EngineCapabilitytorch_tensorrt.TensorFormattorch_tensorrt.torchscript(aliased totorch_tensorrt.ts)Expects only a
torch.jit.ScriptModuletorch_tensorrt.ts.embed_engine_in_module(serialized_engine, device: trtorch.Device)torch_tensorrt.ts.CompileSpecC++
Lots of open questions here: There is a concept of a
torch::nn::Modulewhich can be defined and trained in C++ which is not torchscript compatible (as far as i know). I believe we should treat this as a separate IR to be supported at a later date. Similar to Python there will be a new sub namespace for the APItorch_tensorrt::tswhich will holdcompileandconvert_graph_to_enginetargeted at torchscript.We are naming the libraries
libtorchtrt.so,libtorchtrt_runtime.soandlibtorchtrt_plugins.soCLI
torchtrtcI think the CLI basically stays the same. In the event of a new serialized IR to support we can add an IR flag or auto detect the IR and select the correct code path. This will primarily remain targeted at Torchscript for the time being
Beta Was this translation helpful? Give feedback.
All reactions