48 #define DBG (!self->silent)
52 #define GST_CAT_DEFAULT gst_tensor_debug_debug
58 #define CAPS_STRING GST_TENSORS_CAP_MAKE(GST_TENSOR_FORMAT_ALL)
63 static GstStaticPadTemplate
sink_factory = GST_STATIC_PAD_TEMPLATE (
"sink",
71 static GstStaticPadTemplate
src_factory = GST_STATIC_PAD_TEMPLATE (
"src",
88 #define C_FLAGS(v) ((guint) v)
90 #define TENSOR_DEBUG_TYPE_OUTPUT_FLAGS (tensor_debug_output_flags_get_type())
97 static GType
type = G_TYPE_INVALID;
99 if (
type == G_TYPE_INVALID) {
100 static const GFlagsValue values[] = {
102 "Disable log output and write. Do not add other flags to have this flag effective.",
105 "Console output with info. Cannot combine with other console flags",
108 "Console output with warning. Cannot combine with other console flags",
111 "Console output with error. Cannot combine with other console flags",
114 "Gstlog output with info. Cannot combine with other gstdbg flags",
117 "Gstlog output with warning. Cannot combine with other gstdbg flags",
120 "Gstlog output with error. Cannot combine with other gstdbg flags",
123 "Store at gsttensor_debug circular buffer so that it can be retrieved by the application later (NYI)",
126 "Write to a file (NYI)",
"filewrite"},
129 type = g_flags_register_static (
"gtd_output", values);
135 #define DEFAULT_TENSOR_DEBUG_OUTPUT_FLAGS (TDBG_OUTPUT_CONSOLE_I)
137 #define TENSOR_DEBUG_TYPE_CAPS (tensor_debug_cap_get_type())
144 static GType
type = G_TYPE_INVALID;
145 if (
type == G_TYPE_INVALID) {
146 static GEnumValue values[] = {
149 "Log stream capability if it is updated or initialized."},
151 "Log stream capability if the capability or dimensions of flexible/sparse tensors are updated. Logs dimension info of flexible/sparse tensors as well."},
153 "Always, log stream capability and tensor dimension information."},
156 type = g_enum_register_static (
"gtd_cap", values);
161 #define DEFAULT_TENSOR_DEBUG_CAP (TDBG_CAP_SHOW_UPDATE_F)
163 #define TENSOR_DEBUG_TYPE_META_FLAGS (tensor_debug_meta_flags_get_type())
170 static GType
type = G_TYPE_INVALID;
172 if (
type == G_TYPE_INVALID) {
173 static const GFlagsValue values[] = {
175 "Do not log stream metadata.",
"disabled"},
178 "Log tensor-query-server related information",
"queryserver"},
181 type = g_flags_register_static (
"gtd_meta", values);
186 #define DEFAULT_TENSOR_DEBUG_META_FLAGS (TDBG_META_DISABLED)
191 #define DEFAULT_SILENT TRUE
193 #define gst_tensor_debug_parent_class parent_class
198 guint prop_id,
const GValue * value, GParamSpec * pspec);
200 guint prop_id, GValue * value, GParamSpec * pspec);
207 GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
209 GstCaps * incaps, GstCaps * outcaps);
217 GObjectClass *object_class;
218 GstElementClass *element_class;
219 GstBaseTransformClass *trans_class;
221 GST_DEBUG_CATEGORY_INIT (gst_tensor_debug_debug,
"tensor_debug", 0,
222 "Element to provide debug information of other/tensors streams. If this is enabled, the pipeline performance and overhead may be deteriorated significantly.");
224 trans_class = (GstBaseTransformClass *) klass;
225 object_class = (GObjectClass *) klass;
226 element_class = (GstElementClass *) klass;
238 g_object_class_install_property (object_class,
PROP_SILENT,
239 g_param_spec_boolean (
"silent",
"silent",
"Produce verbose output",
248 g_object_class_install_property (object_class,
PROP_OUTPUT,
249 g_param_spec_flags (
"output-method",
"output",
250 "Output methods for debug/profile contents. Different methods can be enabled simultaneously.",
252 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
259 g_object_class_install_property (object_class,
PROP_CAP,
260 g_param_spec_enum (
"capability",
"cap",
261 "The logging preference for stream capability (GSTCAP)",
263 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
270 g_object_class_install_property (object_class,
PROP_META,
271 g_param_spec_flags (
"metadata",
"meta",
272 "The logging preference for stream metadata (GstMeta)",
274 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
278 gst_element_class_add_pad_template (element_class,
280 gst_element_class_add_pad_template (element_class,
283 gst_element_class_set_static_metadata (element_class,
286 "Help debug or profile a tensor stream by logging the desired details of other/tensors. Users may log the details to console, files, or memory buffers.",
287 "MyungJoo Ham <myungjoo.ham@samsung.com>");
296 trans_class->passthrough_on_same_caps =
TRUE;
298 trans_class->transform_ip_on_passthrough =
TRUE;
329 G_OBJECT_CLASS (parent_class)->finalize (
object);
337 const GValue * value, GParamSpec * pspec)
343 self->silent = g_value_get_boolean (value);
347 self->output_mode = g_value_get_flags (value);
348 silent_debug (
self,
"Set output = %x", self->output_mode);
351 self->cap_mode = g_value_get_enum (value);
355 self->meta_mode = g_value_get_flags (value);
359 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
369 GValue * value, GParamSpec * pspec)
375 g_value_set_boolean (value, self->silent);
378 g_value_set_flags (value, self->output_mode);
381 g_value_set_enum (value, self->cap_mode);
384 g_value_set_flags (value, self->meta_mode);
387 G_OBJECT_WARN_INVALID_PROPERTY_ID (
object, prop_id, pspec);
422 GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
428 return gst_caps_fixate (othercaps);
436 GstCaps * in_caps, GstCaps * out_caps)
440 return gst_caps_can_intersect (in_caps, out_caps);