From: Jaeyun Jung Date: Fri, 30 Nov 2018 16:15:51 +0000 (+0900) Subject: [Transform] limit typecast in arith mode X-Git-Tag: v0.0.3~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7dd8495350c7809d985aba115a57946fe47d6a73;p=platform%2Fupstream%2Fnnstreamer.git [Transform] limit typecast in arith mode set typecast option only in the first Signed-off-by: Jaeyun Jung --- diff --git a/gst/tensor_transform/tensor_transform.c b/gst/tensor_transform/tensor_transform.c index bf85c69..8f4034f 100644 --- a/gst/tensor_transform/tensor_transform.c +++ b/gst/tensor_transform/tensor_transform.c @@ -666,6 +666,14 @@ gst_tensor_transform_set_option_data (GstTensorTransform * filter) switch (op_s->op) { case GTT_OP_TYPECAST: if (num_op > 1 && str_op[1]) { + if (i > 0) { + GST_WARNING_OBJECT (filter, + "To prevent memory re-allocation, tensor-transform limits the typecast during the sequence. " + "Please set the typecast in the first."); + op_s->op = GTT_OP_UNKNOWN; + break; + } + op_s->value.type = get_tensor_type (str_op[1]); if (op_s->value.type == _NNS_END) { diff --git a/tests/nnstreamer_plugins/unittest_plugins.cpp b/tests/nnstreamer_plugins/unittest_plugins.cpp index 6cb784c..7c5a36f7 100644 --- a/tests/nnstreamer_plugins/unittest_plugins.cpp +++ b/tests/nnstreamer_plugins/unittest_plugins.cpp @@ -383,7 +383,7 @@ TEST (test_tensor_transform, arithmetic_3) } /** - * @brief Test for tensor_transform arithmetic (typecast uint8 > float64, add .2, add .1, typecast uint16) + * @brief Test for tensor_transform arithmetic (typecast uint8 > float64, add .2, add .1, final typecast uint16 will be ignored) */ TEST (test_tensor_transform, arithmetic_4) { @@ -412,7 +412,7 @@ TEST (test_tensor_transform, arithmetic_4) gst_harness_set_src_caps (h, gst_tensor_caps_from_config (&config)); data_in_size = gst_tensor_info_get_size (&config.info); - config.info.type = _NNS_UINT16; + config.info.type = _NNS_FLOAT64; data_out_size = gst_tensor_info_get_size (&config.info); /* push buffers */ @@ -443,8 +443,8 @@ TEST (test_tensor_transform, arithmetic_4) ASSERT_TRUE (gst_memory_map (mem, &info, GST_MAP_READ)); for (i = 0; i < array_size; i++) { - uint16_t expected = (i + 1) * (b + 1); - EXPECT_EQ (((uint16_t *) info.data)[i], expected); + double expected = (i + 1) * (b + 1) + .3; + EXPECT_DOUBLE_EQ (((double *) info.data)[i], expected); } gst_memory_unmap (mem, &info);