Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/hal-backend-ml-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ void gst_tensors_info_copy (GstTensorsInfo * dest, const GstTensorsInfo * src)
num = dest->num_tensors = src->num_tensors;
dest->format = src->format;

if (src->format != _NNS_TENSOR_FORMAT_STATIC)
return;

/* Try to copy tensor info even if its format is not static. */
for (i = 0; i < num; i++) {
_dest = gst_tensors_info_get_nth_info (dest, i);
_src = gst_tensors_info_get_nth_info ((GstTensorsInfo *) src, i);
Expand Down
20 changes: 20 additions & 0 deletions src/nnstreamer_plugin_api_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ typedef struct _GstTensorFilterProperties
int invoke_dynamic; /**< True for supporting invoke with flexible output. */

uint32_t suspend; /**< Timeout (ms) for suspend. (Unload the framework) */

int invoke_async; /**< The sub-plugin must support asynchronous output to use this option. If set to TRUE, the sub-plugin can generate multiple outputs asynchronously per single input. Otherwise, only synchronous single-output is expected and async callback is ignored. */
GstTensorDataCallback async_callback; /**< The callback function pointer to be called every time the sub-plugin generates a new output tensor asynchronously. Note that this is internal data for tensor-filter and DO NOT change this value. */
void *async_user_data; /**< The private data to be passed to tensor data callback of asynchronous invoke. Note that this is internal data for tensor-filter and DO NOT change this value. */
} GstTensorFilterProperties;

/**
Expand Down Expand Up @@ -590,6 +594,22 @@ extern void
nnstreamer_filter_shared_model_replace (void *instance, const char *key,
void *new_interpreter, void (*replace_callback) (void *, void *), void (*free_callback) (void*));

/**
* @brief Dispatches the asynchronously generated output to the registered callback.
*
* This function is used by the sub-plugin to dispatch the output that has been generated asynchronously.
* It invokes the internal callback function of tensor-filter to handle the output data.
*
* Note:
* Before calling this function, you must enable asynchronous invocation by setting the property 'invoke-async' as true.
* Failure to do so will result in undefined behavior, as no callback and handle will be registered.
*
* @param[in] prop GstTensorFilterProperties object.
* @param[in] output The GstTensorMemory holding the asynchronously generated output. Note that this function takes the ownership of each tensor data.
*/
extern void
nnstreamer_filter_dispatch_output_async (GstTensorFilterProperties * prop, GstTensorMemory * output);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 10 additions & 0 deletions src/tensor_typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,14 @@ typedef struct

} GstTensorMetaInfo;

/**
* @brief Type definition for a callback function of tensor data stream.
* @details Note that the buffer may be deallocated after the return. To use outside, make a copy. Do not spend too much time in the callback.
* @param data The array of tensor data.
* @param info The information of tensor data.
* @param user_data The private data for the callback.
* @return 0 on success. Otherwise a negative error value.
*/
typedef int (*GstTensorDataCallback) (GstTensorMemory *data, GstTensorsInfo *info, void *user_data);

#endif /*__GST_TENSOR_TYPEDEF_H__*/
Loading