Skip to content

Commit 2d336fb

Browse files
jaeyun-junganyj0527
authored andcommitted
[Util] sync to latest update
Code clean, sync to latest update of nnstreamer. Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
1 parent 4a4d46e commit 2d336fb

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

src/hal-backend-ml-util.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,7 @@ void gst_tensors_info_copy (GstTensorsInfo * dest, const GstTensorsInfo * src)
174174
num = dest->num_tensors = src->num_tensors;
175175
dest->format = src->format;
176176

177-
if (src->format != _NNS_TENSOR_FORMAT_STATIC)
178-
return;
179-
177+
/* Try to copy tensor info even if its format is not static. */
180178
for (i = 0; i < num; i++) {
181179
_dest = gst_tensors_info_get_nth_info (dest, i);
182180
_src = gst_tensors_info_get_nth_info ((GstTensorsInfo *) src, i);

src/nnstreamer_plugin_api_filter.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ typedef struct _GstTensorFilterProperties
136136
int invoke_dynamic; /**< True for supporting invoke with flexible output. */
137137

138138
uint32_t suspend; /**< Timeout (ms) for suspend. (Unload the framework) */
139+
140+
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. */
141+
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. */
142+
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. */
139143
} GstTensorFilterProperties;
140144

141145
/**
@@ -590,6 +594,22 @@ extern void
590594
nnstreamer_filter_shared_model_replace (void *instance, const char *key,
591595
void *new_interpreter, void (*replace_callback) (void *, void *), void (*free_callback) (void*));
592596

597+
/**
598+
* @brief Dispatches the asynchronously generated output to the registered callback.
599+
*
600+
* This function is used by the sub-plugin to dispatch the output that has been generated asynchronously.
601+
* It invokes the internal callback function of tensor-filter to handle the output data.
602+
*
603+
* Note:
604+
* Before calling this function, you must enable asynchronous invocation by setting the property 'invoke-async' as true.
605+
* Failure to do so will result in undefined behavior, as no callback and handle will be registered.
606+
*
607+
* @param[in] prop GstTensorFilterProperties object.
608+
* @param[in] output The GstTensorMemory holding the asynchronously generated output. Note that this function takes the ownership of each tensor data.
609+
*/
610+
extern void
611+
nnstreamer_filter_dispatch_output_async (GstTensorFilterProperties * prop, GstTensorMemory * output);
612+
593613
#ifdef __cplusplus
594614
}
595615
#endif

src/tensor_typedef.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,14 @@ typedef struct
310310

311311
} GstTensorMetaInfo;
312312

313+
/**
314+
* @brief Type definition for a callback function of tensor data stream.
315+
* @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.
316+
* @param data The array of tensor data.
317+
* @param info The information of tensor data.
318+
* @param user_data The private data for the callback.
319+
* @return 0 on success. Otherwise a negative error value.
320+
*/
321+
typedef int (*GstTensorDataCallback) (GstTensorMemory *data, GstTensorsInfo *info, void *user_data);
322+
313323
#endif /*__GST_TENSOR_TYPEDEF_H__*/

0 commit comments

Comments
 (0)