@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()
\brief Whether all input shape bindings have been specified
|
void |
destroy()
Deprecated.
Use
delete instead. Deprecated in TRT 8.0.
\warning Calling destroy on a managed pointer will result in a double-free error. |
boolean |
enqueue(int batchSize,
Pointer bindings,
org.bytedeco.cuda.cudart.CUstream_st stream,
org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
Deprecated.
|
boolean |
enqueue(int batchSize,
PointerPointer bindings,
org.bytedeco.cuda.cudart.CUstream_st stream,
org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
Deprecated.
Deprecated in TensorRT 8.4. Superseded by enqueueV2() if the network is created with
NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag.
|
boolean |
enqueueV2(Pointer bindings,
org.bytedeco.cuda.cudart.CUstream_st stream,
org.bytedeco.cuda.cudart.CUevent_st inputConsumed) |
boolean |
enqueueV2(PointerPointer bindings,
org.bytedeco.cuda.cudart.CUstream_st stream,
org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
\brief Asynchronously execute inference.
|
boolean |
execute(int batchSize,
Pointer bindings)
Deprecated.
|
boolean |
execute(int batchSize,
PointerPointer bindings)
Deprecated.
Deprecated in TensorRT 8.4. Superseded by executeV2() if the network is created with
NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag.
\warning This function will trigger layer resource updates if hasImplicitBatchDimension()
returns true and batchSize changes between subsequent calls, possibly resulting
in performance bottlenecks.
|
boolean |
executeV2(Pointer bindings) |
boolean |
executeV2(PointerPointer bindings)
\brief Synchronously execute inference a network.
|
Dims32 |
getBindingDimensions(int bindingIndex)
\brief Get the dynamic dimensions of a binding
If the engine was built with an implicit batch dimension, same as ICudaEngine::getBindingDimensions.
|
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.
|
String |
getName()
\brief Return the name of the execution context.
|
int |
getOptimizationProfile()
\brief Get the index of the currently selected optimization profile.
|
IExecutionContext |
getPointer(long i) |
IProfiler |
getProfiler()
\brief Get the profiler.
|
boolean |
getShapeBinding(int bindingIndex,
int[] data) |
boolean |
getShapeBinding(int bindingIndex,
IntBuffer data) |
boolean |
getShapeBinding(int bindingIndex,
IntPointer data)
\brief Get values of an input tensor required for shape calculations or an output tensor produced by shape
calculations.
|
Dims32 |
getStrides(int bindingIndex)
\brief Return the strides of the buffer for the given binding.
|
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 |
setBindingDimensions(int bindingIndex,
Dims32 dimensions)
\brief Set the dynamic dimensions of a binding
|
void |
setDebugSync(boolean sync)
\brief Set the debug sync flag.
|
void |
setDeviceMemory(Pointer memory)
\brief Set the device memory 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) |
boolean |
setInputShapeBinding(int bindingIndex,
int[] data) |
boolean |
setInputShapeBinding(int bindingIndex,
IntBuffer data) |
boolean |
setInputShapeBinding(int bindingIndex,
IntPointer data)
\brief Set values of input tensor required by shape calculations.
|
void |
setName(BytePointer name) |
void |
setName(String name)
\brief Set the name of the execution context.
|
boolean |
setOptimizationProfile(int profileIndex)
Deprecated.
Superseded by setOptimizationProfileAsync. Deprecated prior to TensorRT 8.0 and will be
removed in 9.0.
|
boolean |
setOptimizationProfileAsync(int profileIndex,
org.bytedeco.cuda.cudart.CUstream_st stream)
\brief Select an optimization profile for the current context with async
semantics.
|
void |
setProfiler(IProfiler profiler)
\brief Set the profiler.
|
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, zeropublic 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@Cast(value="bool") @Deprecated @NoException(value=true) public boolean execute(int batchSize, @Cast(value="void*const*") PointerPointer bindings)
batchSize - The batch size. This is at most the max batch size value supplied to the builder when the
engine was built. If the network is created with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag, please use
executeV2() instead, and this batchSize argument has no effect.bindings - An array of pointers to input and output buffers for the network.ICudaEngine::getMaxBatchSize()@Cast(value="bool") @Deprecated @NoException(value=true) public boolean execute(int batchSize, @Cast(value="void*const*") @ByPtrPtr Pointer bindings)
@Cast(value="bool") @Deprecated @NoException(value=true) public boolean enqueue(int batchSize, @Cast(value="void*const*") PointerPointer bindings, org.bytedeco.cuda.cudart.CUstream_st stream, @ByPtrPtr org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
batchSize - The batch size. This is at most the max batch size value supplied to the builder when the
engine was built. If the network is created with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag, please use
enqueueV2() instead, and this batchSize argument has no effect.bindings - An array of pointers to input and output buffers for the network.stream - A cuda stream on which the inference kernels will be enqueued.inputConsumed - An optional event which will be signaled when the input buffers can be refilled with new
data.ICudaEngine::getMaxBatchSize()
\warning Calling enqueue() in from the same IExecutionContext object with different CUDA streams concurrently
results in undefined behavior. To perform inference concurrently in multiple streams, use one execution
context per stream.
\warning This function will trigger layer resource updates if hasImplicitBatchDimension()
returns true and batchSize changes between subsequent calls, possibly resulting in performance
bottlenecks.@Cast(value="bool") @Deprecated @NoException(value=true) public boolean enqueue(int batchSize, @Cast(value="void*const*") @ByPtrPtr Pointer bindings, org.bytedeco.cuda.cudart.CUstream_st stream, @ByPtrPtr org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
@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@Deprecated @NoException(value=true) public void destroy()
delete instead. Deprecated in TRT 8.0.
\warning Calling destroy on a managed pointer will result in a double-free error.@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::createExecutionContextWithoutDeviceMemory()@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims32 getStrides(int bindingIndex)
bindingIndex - The binding index.getBindingComponentsPerElement@Cast(value="bool") @Deprecated @NoException(value=true) public boolean setOptimizationProfile(int profileIndex)
profileIndex - Index of the profile. It must lie between 0 and
getEngine().getNbOptimizationProfiles() - 1
The selected profile will be used in subsequent calls to executeV2() or enqueueV2().
When an optimization profile is switched via this API, TensorRT may
enqueue GPU memory copy operations required to set up the new profile during the subsequent enqueueV2()
operations. To avoid these calls during enqueueV2(), use setOptimizationProfileAsync() instead.
If the associated CUDA engine has dynamic inputs, this method must be called at least once
with a unique profileIndex before calling execute or enqueue (i.e. the profile index
may not be in use by another execution context that has not been destroyed yet).
For the first execution context that is created for an engine, setOptimizationProfile(0)
is called implicitly.
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 (this is particularly
the case for all safe engines).
setOptimizationProfile() must be called before calling setBindingDimensions() and
setInputShapeBinding() for all dynamic input tensors or input shape tensors, which in
turn must be called before either executeV2() or enqueueV2().
\warning This function will trigger layer resource updates on the next
call of enqueueV2()/executeV2(), possibly resulting in performance bottlenecks.IExecutionContext::setOptimizationProfileAsync()@NoException(value=true) public int getOptimizationProfile()
@Cast(value="bool") @NoException(value=true) public boolean setBindingDimensions(int bindingIndex, @ByVal @Cast(value="nvinfer1::Dims*") Dims32 dimensions)
bindingIndex - index of an input tensor whose dimensions must be compatible with
the network definition (i.e. only the wildcard dimension -1 can be replaced with a
new dimension >= 0).dimensions - specifies the dimensions of the input tensor. It must be in the valid
range for the currently selected optimization profile, and the corresponding engine must
not be safety-certified.
This method requires the engine to be built without an implicit batch dimension.
This method will fail unless a valid optimization profile is defined for the current
execution context (getOptimizationProfile() must not be -1).
For all dynamic non-output bindings (which have at least one wildcard dimension of -1),
this method needs to be called before either enqueueV2() or executeV2() may be called.
This can be checked using the method allInputDimensionsSpecified().
\warning This function will trigger layer resource updates on the next
call of enqueueV2()/executeV2(), possibly resulting in performance bottlenecks,
if the dimensions are different than the previous set dimensions.ICudaEngine::getBindingIndex@ByVal @Cast(value="nvinfer1::Dims*") @NoException(value=true) public Dims32 getBindingDimensions(int bindingIndex)
ICudaEngine::getProfileDimensions@Cast(value="bool") @NoException(value=true) public boolean setInputShapeBinding(int bindingIndex, @Const IntPointer data)
bindingIndex - index of an input tensor for which
ICudaEngine::isShapeBinding(bindingIndex) and ICudaEngine::bindingIsInput(bindingIndex)
are both true.data - pointer to values of the input tensor. The number of values should be
the product of the dimensions returned by getBindingDimensions(bindingIndex).
If ICudaEngine::isShapeBinding(bindingIndex) and ICudaEngine::bindingIsInput(bindingIndex)
are both true, this method must be called before enqueueV2() or executeV2() may be called.
This method will fail unless a valid optimization profile is defined for the current
execution context (getOptimizationProfile() must not be -1).
\warning This function will trigger layer resource updates on the next call of
enqueueV2()/executeV2(), possibly resulting in performance bottlenecks, if the
shapes are different than the previous set shapes.@Cast(value="bool") @NoException(value=true) public boolean setInputShapeBinding(int bindingIndex, @Const IntBuffer data)
@Cast(value="bool") @NoException(value=true) public boolean setInputShapeBinding(int bindingIndex, @Const int[] data)
@Cast(value="bool") @NoException(value=true) public boolean getShapeBinding(int bindingIndex, IntPointer data)
bindingIndex - index of an input or output tensor for which
ICudaEngine::isShapeBinding(bindingIndex) is true.data - pointer to where values will be written. The number of values written is
the product of the dimensions returned by getBindingDimensions(bindingIndex).
If ICudaEngine::bindingIsInput(bindingIndex) is false, then both
allInputDimensionsSpecified() and allInputShapesSpecified() must be true
before calling this method. The method will also fail if no valid optimization profile
has been set for the current execution context, i.e. if getOptimizationProfile() returns -1.isShapeBinding(bindingIndex)@Cast(value="bool") @NoException(value=true) public boolean getShapeBinding(int bindingIndex, IntBuffer data)
@Cast(value="bool") @NoException(value=true) public boolean getShapeBinding(int bindingIndex, int[] data)
@Cast(value="bool") @NoException(value=true) public boolean allInputDimensionsSpecified()
setBindingDimensions(bindingIndex,dimensions)@Cast(value="bool") @NoException(value=true) public boolean allInputShapesSpecified()
isShapeBinding(bindingIndex)@NoException(value=true) public void setErrorRecorder(IErrorRecorder recorder)
/**@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::getMaxBatchSize()@Cast(value="bool") @NoException(value=true) public boolean executeV2(@Cast(value="void*const*") @ByPtrPtr Pointer bindings)
@Cast(value="bool") @NoException(value=true) public boolean enqueueV2(@Cast(value="void*const*") PointerPointer bindings, org.bytedeco.cuda.cudart.CUstream_st stream, @ByPtrPtr org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
bindings - An array of pointers to input and output buffers for the network.stream - A cuda stream on which the inference kernels will be enqueuedinputConsumed - An optional event which will be signaled when the input buffers can be refilled with new
dataICudaEngine::getMaxBatchSize()
\note Calling enqueueV2() with a stream in CUDA graph capture mode has a known issue. If dynamic shapes are
used, the first enqueueV2() call after a setInputShapeBinding() call will cause failure in stream capture
due to resource allocation. Please call enqueueV2() once before capturing the graph.
\warning Calling enqueueV2() in from the same IExecutionContext object with different CUDA streams concurrently
results in undefined behavior. To perform inference concurrently in multiple streams, use one execution
context per stream.@Cast(value="bool") @NoException(value=true) public boolean enqueueV2(@Cast(value="void*const*") @ByPtrPtr Pointer bindings, org.bytedeco.cuda.cudart.CUstream_st stream, @ByPtrPtr org.bytedeco.cuda.cudart.CUevent_st inputConsumed)
@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() or
enqueueV2().
If the associated CUDA engine has inputs with dynamic shapes, the
optimization profile must be set with a unique profileIndex before
calling execute or enqueue.
For the first execution context that is created for an engine,
setOptimizationProfile(0) is called implicitly.
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
setBindingDimensions() and setInputShapeBinding() for all dynamic input
tensors or input shape tensors, which in turn must be called before
either executeV2() or enqueueV2().
\warning This function will trigger layer resource updates on the next call of
enqueueV2()/executeV2(), 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(),
IExecutionContext::setOptimizationProfile()@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()Copyright © 2022. All rights reserved.