@Namespace(value="nvinfer1") @NoOffset @Properties(inherit=nvinfer.class) public class IExecutionContext extends INoCopy
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
IExecutionContext()
Default native constructor.
|
IExecutionContext(long size)
Native array allocator.
|
IExecutionContext(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allInputDimensionsSpecified()
\brief Whether all dynamic dimensions of input tensors have been specified
|
boolean |
allInputShapesSpecified()
Deprecated.
Deprecated in TensorRT 10.0. setInputShapeBinding() is removed since TensorRT 10.0.
|
boolean |
enqueueV3(org.bytedeco.cuda.cudart.CUstream_st stream)
\brief Enqueue inference on a stream.
|
boolean |
executeV2(Pointer bindings) |
boolean |
executeV2(PointerPointer bindings)
\brief Synchronously execute a network.
|
IDebugListener |
getDebugListener()
\brief Get the DebugListener of this execution context.
|
boolean |
getDebugState(BytePointer name) |
boolean |
getDebugState(String name)
\brief Get the debug state.
|
boolean |
getDebugSync()
\brief Get the debug sync flag.
|
ICudaEngine |
getEngine()
\brief Get the associated engine.
|
boolean |
getEnqueueEmitsProfile()
\brief Get the enqueueEmitsProfile state.
|
IErrorRecorder |
getErrorRecorder()
\brief Get the ErrorRecorder assigned to this interface.
|
org.bytedeco.cuda.cudart.CUevent_st |
getInputConsumedEvent()
\brief The event associated with consuming the input.
|
long |
getMaxOutputSize(BytePointer tensorName) |
long |
getMaxOutputSize(String tensorName)
\brief Get upper bound on an output tensor's size, in bytes, based on
the current optimization profile and input dimensions.
|
String |
getName()
\brief Return the name of the execution context.
|
nvinfer.ProfilingVerbosity |
getNvtxVerbosity()
\brief Get the NVTX verbosity of the execution context.
|
int |
getOptimizationProfile()
\brief Get the index of the currently selected optimization profile.
|
IOutputAllocator |
getOutputAllocator(BytePointer tensorName) |
IOutputAllocator |
getOutputAllocator(String tensorName)
\brief Get output allocator associated with output tensor of given name, or nullptr if the provided name does
not map to an output tensor.
|
Pointer |
getOutputTensorAddress(BytePointer tensorName) |
Pointer |
getOutputTensorAddress(String tensorName)
\brief Get memory address for given output.
|
long |
getPersistentCacheLimit()
\brief Get the maximum size for persistent cache usage.
|
IExecutionContext |
getPointer(long i) |
IProfiler |
getProfiler()
\brief Get the profiler.
|
IRuntimeConfig |
getRuntimeConfig()
\brief Get the runtime config object used during execution context creation.
|
IGpuAllocator |
getTemporaryStorageAllocator()
\brief Get allocator set by setTemporaryStorageAllocator.
|
Pointer |
getTensorAddress(BytePointer tensorName) |
Pointer |
getTensorAddress(String tensorName)
\brief Get memory address bound to given input or output tensor, or nullptr if the provided name does not map to
an input or output tensor.
|
Dims64 |
getTensorShape(BytePointer tensorName) |
Dims64 |
getTensorShape(String tensorName)
\brief Return the shape of the given input or output.
|
Dims64 |
getTensorStrides(BytePointer tensorName) |
Dims64 |
getTensorStrides(String tensorName)
\brief Return the strides of the buffer for the given tensor name.
|
boolean |
getUnfusedTensorsDebugState()
\brief Get the debug state of unfused tensors.
|
int |
inferShapes(int nbMaxNames,
byte[] tensorNames) |
int |
inferShapes(int nbMaxNames,
ByteBuffer tensorNames) |
int |
inferShapes(int nbMaxNames,
BytePointer tensorNames) |
int |
inferShapes(int nbMaxNames,
PointerPointer tensorNames)
\brief Run shape calculations.
|
IExecutionContext |
position(long position) |
boolean |
reportToProfiler()
\brief Calculate layer timing info for the current optimization profile in IExecutionContext
and update the profiler after one iteration of inference launch.
|
boolean |
setAllTensorsDebugState(boolean flag)
\brief Turn the debug state of all debug tensors on or off.
|
void |
setAuxStreams(org.bytedeco.cuda.cudart.CUstream_st auxStreams,
int nbStreams)
\brief Set the auxiliary streams that TensorRT should launch kernels on in the next enqueueV3() call.
|
boolean |
setDebugListener(IDebugListener listener)
\brief Set DebugListener for this execution context.
|
void |
setDebugSync(boolean sync)
\brief Set the debug sync flag.
|
void |
setDeviceMemory(Pointer memory)
Deprecated.
Deprecated in TensorRT 10.1. Superseded by setDeviceMemoryV2().
\warning Weight streaming related scratch memory will be allocated by TensorRT if the memory is set by this API.
Please use setDeviceMemoryV2() instead.
|
void |
setDeviceMemoryV2(Pointer memory,
long size)
\brief Set the device memory and its corresponding size for use by this execution context.
|
void |
setEnqueueEmitsProfile(boolean enqueueEmitsProfile)
\brief Set whether enqueue emits layer timing to the profiler
If set to true (default), enqueue is synchronous and does layer timing profiling implicitly if
there is a profiler attached.
|
void |
setErrorRecorder(IErrorRecorder recorder)
\brief Set the ErrorRecorder for this interface
Assigns the ErrorRecorder to this interface.
|
boolean |
setInputConsumedEvent(org.bytedeco.cuda.cudart.CUevent_st event)
\brief Mark input as consumed.
|
boolean |
setInputShape(BytePointer tensorName,
Dims64 dims) |
boolean |
setInputShape(String tensorName,
Dims64 dims)
\brief Set shape of given input.
|
boolean |
setInputTensorAddress(BytePointer tensorName,
Pointer data) |
boolean |
setInputTensorAddress(String tensorName,
Pointer data)
\brief Set memory address for given input.
|
void |
setName(BytePointer name) |
void |
setName(String name)
\brief Set the name of the execution context.
|
boolean |
setNvtxVerbosity(int verbosity) |
boolean |
setNvtxVerbosity(nvinfer.ProfilingVerbosity verbosity)
\brief Set the verbosity of the NVTX markers in the execution context.
|
boolean |
setOptimizationProfileAsync(int profileIndex,
org.bytedeco.cuda.cudart.CUstream_st stream)
\brief Select an optimization profile for the current context with async
semantics.
|
boolean |
setOutputAllocator(BytePointer tensorName,
IOutputAllocator outputAllocator) |
boolean |
setOutputAllocator(String tensorName,
IOutputAllocator outputAllocator)
\brief Set output allocator to use for output tensor of given name.
|
boolean |
setOutputTensorAddress(BytePointer tensorName,
Pointer data) |
boolean |
setOutputTensorAddress(String tensorName,
Pointer data)
\brief Set the memory address for a given output tensor.
|
void |
setPersistentCacheLimit(long size)
\brief Set the maximum size for persistent cache usage.
|
void |
setProfiler(IProfiler profiler)
\brief Set the profiler.
|
boolean |
setTemporaryStorageAllocator(IGpuAllocator allocator)
\brief Specify allocator to use for internal temporary storage.
|
boolean |
setTensorAddress(BytePointer tensorName,
Pointer data) |
boolean |
setTensorAddress(String tensorName,
Pointer data)
\brief Set memory address for given input or output tensor.
|
boolean |
setTensorDebugState(BytePointer name,
boolean flag) |
boolean |
setTensorDebugState(String name,
boolean flag)
\brief Set debug state of tensor given the tensor name.
|
boolean |
setUnfusedTensorsDebugState(boolean flag)
\brief Turn the debug state of unfused tensors on or off.
|
long |
updateDeviceMemorySizeForShapes()
\brief Recompute the internal activation buffer sizes based on the current input shapes, and return the total
amount of memory required.
|
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public IExecutionContext()
public IExecutionContext(long size)
Pointer.position(long)
.public IExecutionContext(Pointer p)
Pointer(Pointer)
.public IExecutionContext position(long position)
public IExecutionContext getPointer(long i)
getPointer
in class Pointer
@NoException(value=true) public void setDebugSync(@Cast(value="bool") boolean sync)
getDebugSync()
@Cast(value="bool") @NoException(value=true) public boolean getDebugSync()
setDebugSync()
@NoException(value=true) public void setProfiler(IProfiler profiler)
getProfiler()
@NoException(value=true) public IProfiler getProfiler()
setProfiler()
@Const @ByRef @NoException(value=true) public ICudaEngine getEngine()
ICudaEngine
@NoException(value=true) public void setName(String name)
getName()
@NoException(value=true) public void setName(@Cast(value="const char*") BytePointer name)
@NoException(value=true) public String getName()
setName()
@NoException(value=true) public void setDeviceMemory(Pointer memory)
ICudaEngine::getDeviceMemorySize()
,
ICudaEngine::getDeviceMemorySizeForProfile()
,
nvinfer.ExecutionContextAllocationStrategy
,
ICudaEngine::createExecutionContext()
,
ICudaEngine::createExecutionContextWithoutDeviceMemory()
@NoException(value=true) public void setDeviceMemoryV2(Pointer memory, @Cast(value="int64_t") long size)
ICudaEngine::getDeviceMemorySizeV2()
,
ICudaEngine::getDeviceMemorySizeForProfileV2()
,
nvinfer.ExecutionContextAllocationStrategy
,
ICudaEngine::createExecutionContext()
,
ICudaEngine::createExecutionContextWithoutDeviceMemory()
@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims64 getTensorStrides(String tensorName)
tensorName
- The name of an input or output tensor.
\warning The string tensorName must be null-terminated, and be at most 4096 bytes including the terminator.@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims64 getTensorStrides(@Cast(value="const char*") BytePointer tensorName)
@NoException(value=true) public int getOptimizationProfile()
@Cast(value="bool") @NoException(value=true) public boolean setInputShape(String tensorName, @Cast(value="const nvinfer1::Dims*") @ByRef Dims64 dims)
tensorName
- The name of an input tensor.dims
- The shape of an input tensor.@Cast(value="bool") @NoException(value=true) public boolean setInputShape(@Cast(value="const char*") BytePointer tensorName, @Cast(value="const nvinfer1::Dims*") @ByRef Dims64 dims)
@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims64 getTensorShape(String tensorName)
tensorName
- The name of an input or output tensor.
Return Dims{-1, {}} if the provided name does not map to an input or output tensor.
Otherwise return the shape of the input or output tensor.
A dimension in an input tensor will have a -1 wildcard value if all the following are true:
* setInputShape() has not yet been called for this tensor
* The dimension is a runtime dimension that is not implicitly constrained to be a single value.
A dimension in an output tensor will have a -1 wildcard value if the dimension depends
on values of execution tensors OR if all the following are true:
* It is a runtime dimension.
* setInputShape() has NOT been called for some input tensor(s) with a runtime shape.
* setTensorAddress() has NOT been called for some input tensor(s) with isShapeInferenceIO() = true.
An output tensor may also have -1 wildcard dimensions if its shape depends on values of tensors supplied to
enqueueV3().
If the request is for the shape of an output tensor with runtime dimensions,
all input tensors with isShapeInferenceIO() = true should have their value already set,
since these values might be needed to compute the output shape.
Examples of an input dimension that is implicitly constrained to a single value:
* The optimization profile specifies equal min and max values.
* The dimension is named and only one value meets the optimization profile requirements
for dimensions with that name.
\warning The string tensorName must be null-terminated, and be at most 4096 bytes including the terminator.@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims64 getTensorShape(@Cast(value="const char*") BytePointer tensorName)
@Cast(value="bool") @NoException(value=true) public boolean allInputDimensionsSpecified()
@Cast(value="bool") @Deprecated @NoException(value=true) public boolean allInputShapesSpecified()
@NoException(value=true) public void setErrorRecorder(IErrorRecorder recorder)
recorder
- The error recorder to register with this interface.getErrorRecorder()
@NoException(value=true) public IErrorRecorder getErrorRecorder()
setErrorRecorder()
@Cast(value="bool") @NoException(value=true) public boolean executeV2(@Cast(value="void*const*") PointerPointer bindings)
bindings
- An array of pointers to input and output buffers for the network.ICudaEngine::getIOTensorName()
@Cast(value="bool") @NoException(value=true) public boolean executeV2(@Cast(value="void*const*") @ByPtrPtr Pointer bindings)
@Cast(value="bool") @NoException(value=true) public boolean setOptimizationProfileAsync(int profileIndex, org.bytedeco.cuda.cudart.CUstream_st stream)
profileIndex
- Index of the profile. The value must lie between 0 and
getEngine().getNbOptimizationProfiles() - 1stream
- A CUDA stream on which the cudaMemcpyAsyncs may be
enqueued
When an optimization profile is switched via this API, TensorRT may
require that data is copied via cudaMemcpyAsync. It is the
application’s responsibility to guarantee that synchronization between
the profile sync stream and the enqueue stream occurs.
The selected profile will be used in subsequent calls to executeV2()/enqueueV3().
If the associated CUDA engine has inputs with dynamic shapes, the optimization profile must
be set with its corresponding profileIndex before calling execute or enqueue. The newly created execution
context will be assigned optimization profile 0.
If the associated CUDA engine does not have inputs with dynamic shapes,
this method need not be called, in which case the default profile index
of 0 will be used.
setOptimizationProfileAsync() must be called before calling
setInputShape() for all dynamic input
tensors or input shape tensors, which in turn must be called before
executeV2()/enqueueV3().
\warning This function will trigger layer resource updates on the next call of
executeV2()/enqueueV3(), possibly resulting in performance bottlenecks.
\warning Not synchronizing the stream used at enqueue with the stream
used to set optimization profile asynchronously using this API will
result in undefined behavior.ICudaEngine::getNbOptimizationProfiles()
@NoException(value=true) public void setEnqueueEmitsProfile(@Cast(value="bool") boolean enqueueEmitsProfile)
IExecutionContext::getEnqueueEmitsProfile()
,
IExecutionContext::reportToProfiler()
@Cast(value="bool") @NoException(value=true) public boolean getEnqueueEmitsProfile()
IExecutionContext::setEnqueueEmitsProfile()
@Cast(value="bool") @NoException(value=true) public boolean reportToProfiler()
IExecutionContext::setEnqueueEmitsProfile()
,
IExecutionContext::getEnqueueEmitsProfile()
@Cast(value="bool") @NoException(value=true) public boolean setTensorAddress(String tensorName, Pointer data)
tensorName
- The name of an input or output tensor.data
- The pointer (void*) to the data owned by the user.setOutputTensorAddress() getTensorShape() setOutputAllocator() IOutputAllocator
@Cast(value="bool") @NoException(value=true) public boolean setTensorAddress(@Cast(value="const char*") BytePointer tensorName, Pointer data)
@Const @NoException(value=true) public Pointer getTensorAddress(String tensorName)
tensorName
- The name of an input or output tensor.
Use method getOutputTensorAddress() if a non-const pointer for an output tensor is required.
\warning The string tensorName must be null-terminated, and be at most 4096 bytes including the terminator.getOutputTensorAddress()
@Const @NoException(value=true) public Pointer getTensorAddress(@Cast(value="const char*") BytePointer tensorName)
@Cast(value="bool") @NoException(value=true) public boolean setOutputTensorAddress(String tensorName, Pointer data)
tensorName
- The name of an output tensor.data
- The pointer to the buffer to which to write the output.setTensorAddress()
@Cast(value="bool") @NoException(value=true) public boolean setOutputTensorAddress(@Cast(value="const char*") BytePointer tensorName, Pointer data)
@Cast(value="bool") @NoException(value=true) public boolean setInputTensorAddress(String tensorName, @Const Pointer data)
tensorName
- The name of an input tensor.data
- The pointer (void const*) to the const data owned by the user.setTensorAddress()
@Cast(value="bool") @NoException(value=true) public boolean setInputTensorAddress(@Cast(value="const char*") BytePointer tensorName, @Const Pointer data)
@NoException(value=true) public Pointer getOutputTensorAddress(String tensorName)
tensorName
- The name of an output tensor.getTensorAddress()
@NoException(value=true) public Pointer getOutputTensorAddress(@Cast(value="const char*") BytePointer tensorName)
@NoException(value=true) public int inferShapes(int nbMaxNames, @Cast(value="const char**") PointerPointer tensorNames)
nbMaxNames
- Maximum number of names to write to tensorNames.
When the return value is a positive value n and tensorNames != nullptr,
the names of min(n,nbMaxNames) insufficiently specified input tensors are
written to tensorNames.tensorNames
- Buffer in which to place names of insufficiently specified input tensors.@NoException(value=true) public int inferShapes(int nbMaxNames, @Cast(value="const char**") @ByPtrPtr BytePointer tensorNames)
@NoException(value=true) public int inferShapes(int nbMaxNames, @Cast(value="const char**") @ByPtrPtr ByteBuffer tensorNames)
@NoException(value=true) public int inferShapes(int nbMaxNames, @Cast(value="const char**") @ByPtrPtr byte[] tensorNames)
@Cast(value="size_t") @NoException(value=true) public long updateDeviceMemorySizeForShapes()
IExecutionContext::setDeviceMemory()
@Cast(value="bool") @NoException(value=true) public boolean setInputConsumedEvent(org.bytedeco.cuda.cudart.CUevent_st event)
event
- The CUDA event that is triggered after all input tensors have been consumed.
\warning The set event must be valid during the inference.@NoException(value=true) public org.bytedeco.cuda.cudart.CUevent_st getInputConsumedEvent()
@Cast(value="bool") @NoException(value=true) public boolean setOutputAllocator(String tensorName, IOutputAllocator outputAllocator)
tensorName
- The name of an output tensor.outputAllocator
- IOutputAllocator for the tensors.IOutputAllocator
@Cast(value="bool") @NoException(value=true) public boolean setOutputAllocator(@Cast(value="const char*") BytePointer tensorName, IOutputAllocator outputAllocator)
@NoException(value=true) public IOutputAllocator getOutputAllocator(String tensorName)
IOutputAllocator
@NoException(value=true) public IOutputAllocator getOutputAllocator(@Cast(value="const char*") BytePointer tensorName)
@Cast(value="int64_t") @NoException(value=true) public long getMaxOutputSize(String tensorName)
tensorName
- The name of an output tensor.@Cast(value="int64_t") @NoException(value=true) public long getMaxOutputSize(@Cast(value="const char*") BytePointer tensorName)
@Cast(value="bool") @NoException(value=true) public boolean setTemporaryStorageAllocator(IGpuAllocator allocator)
allocator
- pointer to allocator to use. Pass nullptr to revert to using TensorRT's
default allocator.setOutputAllocator()
@NoException(value=true) public IGpuAllocator getTemporaryStorageAllocator()
@Cast(value="bool") @NoException(value=true) public boolean enqueueV3(org.bytedeco.cuda.cudart.CUstream_st stream)
stream
- A CUDA stream on which the inference kernels will be enqueued.@NoException(value=true) public void setPersistentCacheLimit(@Cast(value="size_t") long size)
size
- the size of persistent cache limitation in bytes.
The default is 0 Bytes.getPersistentCacheLimit
@Cast(value="size_t") @NoException(value=true) public long getPersistentCacheLimit()
setPersistentCacheLimit
@Cast(value="bool") @NoException(value=true) public boolean setNvtxVerbosity(nvinfer.ProfilingVerbosity verbosity)
verbosity
- The verbosity of the NVTX markers.getNvtxVerbosity()
,
ICudaEngine::getProfilingVerbosity()
@Cast(value="bool") @NoException(value=true) public boolean setNvtxVerbosity(@Cast(value="nvinfer1::ProfilingVerbosity") int verbosity)
@NoException(value=true) public nvinfer.ProfilingVerbosity getNvtxVerbosity()
setNvtxVerbosity()
@NoException(value=true) public void setAuxStreams(@ByPtrPtr org.bytedeco.cuda.cudart.CUstream_st auxStreams, int nbStreams)
auxStreams
- The pointer to an array of cudaStream_t with the array length equal to nbStreams.nbStreams
- The number of auxiliary streams provided. If nbStreams is greater than
engine->getNbAuxStreams()
, then only the first engine->getNbAuxStreams()
streams will be used. If
nbStreams
is less than engine->getNbAuxStreams()
, such as setting nbStreams
to 0, then TensorRT
will use the provided streams for the first nbStreams
auxiliary streams, and will create additional
streams internally for the rest of the auxiliary streams.
\note The provided auxiliary streams must not be the default stream and must all be different to avoid
deadlocks.enqueueV3(), IBuilderConfig::setMaxAuxStreams(), ICudaEngine::getNbAuxStreams()
@Cast(value="bool") @NoException(value=true) public boolean setDebugListener(IDebugListener listener)
listener
- DebugListener for this execution context.@NoException(value=true) public IDebugListener getDebugListener()
@Cast(value="bool") @NoException(value=true) public boolean setTensorDebugState(String name, @Cast(value="bool") boolean flag)
name
- Name of target tensor.flag
- True if turning on debug state, false if turning off debug state of tensor
The default is off.@Cast(value="bool") @NoException(value=true) public boolean setTensorDebugState(@Cast(value="const char*") BytePointer name, @Cast(value="bool") boolean flag)
@Cast(value="bool") @NoException(value=true) public boolean getDebugState(String name)
name
- Name of target tensor.@Cast(value="bool") @NoException(value=true) public boolean getDebugState(@Cast(value="const char*") BytePointer name)
@NoException(value=true) public IRuntimeConfig getRuntimeConfig()
@Cast(value="bool") @NoException(value=true) public boolean setAllTensorsDebugState(@Cast(value="bool") boolean flag)
flag
- true if turning on debug state, false if turning off debug state.@Cast(value="bool") @NoException(value=true) public boolean setUnfusedTensorsDebugState(@Cast(value="bool") boolean flag)
flag
- true if turning on debug state, false if turning off debug state.INetworkDefinition::markUnfusedTensorsAsDebugTensors()
@Cast(value="bool") @NoException(value=true) public boolean getUnfusedTensorsDebugState()
Copyright © 2025. All rights reserved.