From f47bd7230152ec38e38feb840c4620128d415fc5 Mon Sep 17 00:00:00 2001 From: Pavel Rodionov Date: Tue, 11 Aug 2020 14:35:39 +0300 Subject: [PATCH] [GNA] Remove empty PWL (#1224) --- .../src/gna_plugin/backend/am_intel_dnn.cpp | 11 ++++------- .../unit/engines/gna/gna_graph_aot_test.cpp | 17 +++++++++++++++++ .../tests_deprecated/unit/engines/gna/gna_matcher.cpp | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp b/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp index c87761a..fa0a211 100644 --- a/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp +++ b/inference-engine/src/gna_plugin/backend/am_intel_dnn.cpp @@ -1411,9 +1411,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(intel_nnet_type_t *ptr_nnet comp.num_columns_out, comp.op.affine.num_bytes_per_bias, comp.op.affine.ptr_biases), - createGna2TensorPwl( - 0, - nullptr), // Temporal PWL as not null required by Gna2OperationInitRecurrent + nullptr, create_uint32_parameter(1)); // TODO: GNA2: Handle other delays AdvanceOperationIfAllApplied(component, i, gnaOperation); #else @@ -1473,9 +1471,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(intel_nnet_type_t *ptr_nnet comp.op.conv1D.num_filters, comp.op.conv1D.num_bytes_per_bias, comp.op.conv1D.ptr_biases), - createGna2TensorPwl( - 0, - nullptr), // Temporal PWL as not null required by Gna2OperationInitConvolution + nullptr, create_shape1D_parameter( comp.op.conv1D.num_feature_maps * comp.op.conv1D.num_feature_map_columns), nullptr); @@ -1529,7 +1525,8 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(intel_nnet_type_t *ptr_nnet THROW_GNA_EXCEPTION << "Pooling component with no preceeding component"; #if GNA_LIB_VER == 2 } else if (gnaOperation->Type == Gna2OperationTypeConvolution) { - if (gnaOperation->Operands[PwlOpIdx]->Shape.Dimensions[0] != 0) { + auto pwlOperand = gnaOperation->Operands[PwlOpIdx]; + if (pwlOperand != nullptr && pwlOperand->Shape.Dimensions[0] != 0) { THROW_GNA_EXCEPTION << "Encountered activation component before pooling component at." << i; } else { const auto poolMode = reinterpret_cast(gnaUserAllocator(sizeof(Gna2PoolingMode))); diff --git a/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp index f64dd6d..2097652 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/gna_graph_aot_test.cpp @@ -104,6 +104,23 @@ TEST_F(GNAAOTTests, PermuteModel_canbe_export_imported) { .inNotCompactMode().gna().propagate_forward().called().once(); } +TEST_F(GNAAOTTests, PoolingModel_canbe_export_imported) { + +#if GNA_LIB_VER == 1 + GTEST_SKIP(); +#endif + + const std::string X = registerFileForRemove("unit_tests.bin"); + + // running export to a file + export_network(maxpoolAfterRelu()) + .inNotCompactMode().withGNAConfig(GNA_CONFIG_KEY(SCALE_FACTOR), 1.0f).as().gna().model().to(X); + + // running infer using imported model instead of IR + assert_that().onInferModel().importedFrom(X) + .inNotCompactMode().gna().propagate_forward().called().once(); +} + TEST_F(GNAAOTTests, CanConvertFromAOTtoSueModel) { #if GNA_LIB_VER == 2 diff --git a/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp b/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp index 2ca9076..59c5565 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/gna_matcher.cpp @@ -436,7 +436,7 @@ void GNAPluginAOTMatcher :: match() { // matching gna_propagate forward call. MockICNNNetwork net; - size_t weightsSize = 440*3; + size_t weightsSize = 656384; auto weights = make_shared_blob({ Precision::U8, {weightsSize}, Layout::C }); weights->allocate(); fillWeights(weights); -- 2.7.4