diff --git a/.ci/azure/linux_ngraph_onnx.yml b/.ci/azure/linux_ngraph_onnx.yml index e11e72e102d..1e13710f2c2 100644 --- a/.ci/azure/linux_ngraph_onnx.yml +++ b/.ci/azure/linux_ngraph_onnx.yml @@ -17,6 +17,8 @@ jobs: WORK_DIR: $(Pipeline.Workspace)/_w MODELS_DIR: /mount/cinfsshare/onnxtestdata TMP_DIR: /mnt/tmp + ONNX_MODEL_ZOO_SHA: "d58213534f2a4d1c4b19ba62b3bb5f544353256e" + steps: - script: | @@ -55,7 +57,7 @@ jobs: - script: docker build --tag=openvino-onnx-ci-image --file=.ci/openvino-onnx/Dockerfile . displayName: 'Docker build' - - script: ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d $(TMP_DIR) -o + - script: ngraph/python/tests/test_onnx/model_zoo_preprocess.sh -d $(TMP_DIR) -o -s "$(ONNX_MODEL_ZOO_SHA)" displayName: 'Get models' - script: | @@ -77,6 +79,6 @@ jobs: displayName: 'Create swap' - script: | - docker run --name openvino-onnx-ci-container --volume $(TMP_DIR)/model_zoo:/root/.onnx/model_zoo --volume $(MODELS_DIR)/msft:/root/.onnx/model_zoo/MSFT openvino-onnx-ci-image + docker run --name openvino-onnx-ci-container --volume $(TMP_DIR)/model_zoo/onnx_model_zoo_$(ONNX_MODEL_ZOO_SHA):/root/.onnx/model_zoo/onnx_model_zoo --volume $(MODELS_DIR)/msft:/root/.onnx/model_zoo/MSFT openvino-onnx-ci-image /bin/bash -c "tox && tox -e zoo_models" displayName: 'Docker run' diff --git a/docs/doxygen/ie_docs.xml b/docs/doxygen/ie_docs.xml index 503f9f38986..120492baef0 100644 --- a/docs/doxygen/ie_docs.xml +++ b/docs/doxygen/ie_docs.xml @@ -131,7 +131,7 @@ limitations under the License. - + @@ -189,11 +189,13 @@ limitations under the License. + + diff --git a/docs/ops/arithmetic/Ceiling_1.md b/docs/ops/arithmetic/Ceiling_1.md index 588b5ff6842..4d4cfeb9450 100644 --- a/docs/ops/arithmetic/Ceiling_1.md +++ b/docs/ops/arithmetic/Ceiling_1.md @@ -2,31 +2,31 @@ **Versioned name**: *Ceiling-1* -**Category**: Arithmetic unary operation +**Category**: Arithmetic unary operation **Short description**: *Ceiling* performs element-wise ceiling operation with given tensor. -**Attributes**: +**Detailed description**: For each element from the input tensor calculates corresponding +element in the output tensor with the following formula: - No attributes available. +\f[ +a_{i} = ceiling(a_{i}) +\f] + +**Attributes**: *Ceiling* operation has no attributes. **Inputs** -* **1**: An tensor of type T. **Required.** +* **1**: A tensor of type *T* and arbitrary shape. **Required.** **Outputs** -* **1**: The result of element-wise ceiling operation. A tensor of type T. +* **1**: The result of element-wise ceiling operation. A tensor of type *T*. **Types** * *T*: any numeric type. -*Ceiling* does the following with the input tensor *a*: - -\f[ -a_{i} = ceiling(a_{i}) -\f] **Examples** diff --git a/docs/ops/arithmetic/Negative_1.md b/docs/ops/arithmetic/Negative_1.md index 2e17112e7bc..997342c2d05 100644 --- a/docs/ops/arithmetic/Negative_1.md +++ b/docs/ops/arithmetic/Negative_1.md @@ -2,35 +2,33 @@ **Versioned name**: *Negative-1* -**Category**: Arithmetic unary operation +**Category**: Arithmetic unary operation -**Short description**: *Negative* performs element-wise negative operation with given tensor. +**Short description**: *Negative* performs element-wise negative operation on a given input tensor. -**Attributes**: +**Detailed description** - No attributes available. - -**Inputs** - -* **1**: An tensor of type T. **Required.** - -**Outputs** - -* **1**: The result of element-wise negative operation. A tensor of type T. - -**Types** - -* *T*: any numeric type. - -*Negative* does the following with the input tensor *a*: +*Negative* performs element-wise negative operation on a given input tensor, based on the following mathematical formula: \f[ a_{i} = -a_{i} \f] -**Examples** +**Attributes**: *Negative* operation has no attributes. -*Example 1* +**Inputs** + +* **1**: A tensor of type *T* and arbitrary shape. **Required.** + +**Outputs** + +* **1**: The result of element-wise *Negative* operation applied to the input tensor. A tensor of type *T* and the same shape as input tensor. + +**Types** + +* *T*: any supported signed numeric type. + +**Example** ```xml @@ -47,4 +45,4 @@ a_{i} = -a_{i} -``` \ No newline at end of file +``` diff --git a/docs/ops/convolution/DeformableConvolution_1.md b/docs/ops/convolution/DeformableConvolution_1.md index 2cba8d84039..612d3c419d4 100644 --- a/docs/ops/convolution/DeformableConvolution_1.md +++ b/docs/ops/convolution/DeformableConvolution_1.md @@ -8,6 +8,26 @@ **Detailed description**: *Deformable Convolution* is similar to regular *Convolution* but its receptive field is deformed because of additional spatial offsets used during input sampling. More thorough explanation can be found in [Deformable Convolutions Demystified](https://towardsdatascience.com/deformable-convolutions-demystified-2a77498699e8) and [Deformable Convolutional Networks](https://arxiv.org/abs/1703.06211). +Output is calculated using the following formula: + + \f[ + + y(p) = \sum_{k = 1}^{K}w_{k}x(p + p_{k} + {\Delta}p_{k}) + + \f] + +Where +* K is a number of sampling locations, e.g. for kernel 3x3 and dilation = 1, K = 9 + +* \f$x(p)\f$ and \f$y(p)\f$ denote the features at location p from the input feature maps x and output feature maps y + +* \f$w_{k}\f$ is the weight for k-th location. + +* \f$p_{k}\f$ is pre-specified offset for the k-th location, e.g. K = 9 and +\f$p_{k} \in \{(-1, -1),(-1, 0), . . . ,(1, 1)\}\f$ + +* \f${\Delta}p_{k}\f$ is the learnable offset for the k-th location. + **Attributes**: * *strides* diff --git a/docs/ops/convolution/DeformableConvolution_8.md b/docs/ops/convolution/DeformableConvolution_8.md new file mode 100644 index 00000000000..cf59584a5f4 --- /dev/null +++ b/docs/ops/convolution/DeformableConvolution_8.md @@ -0,0 +1,168 @@ +## DeformableConvolution {#openvino_docs_ops_convolution_DeformableConvolution_8} + +**Versioned name**: *DeformableConvolution-8* + +**Category**: Convolution + +**Short description**: Computes 2D deformable convolution of input and kernel tensors. + +**Detailed description**: *Deformable Convolution* is similar to regular *Convolution* but its receptive field is deformed because of additional spatial offsets used during input sampling. More thorough explanation can be found in [Deformable Convolutions Demystified](https://towardsdatascience.com/deformable-convolutions-demystified-2a77498699e8), [Deformable Convolutional Networks](https://arxiv.org/abs/1703.06211). + +Modification of DeformableConvolution using modulating scalars is also supported. Please refer to [Deformable ConvNets v2: More Deformable, Better Results](https://arxiv.org/pdf/1811.11168.pdf). + +Output is calculated using the following formula: + + \f[ + + y(p) = \sum_{k = 1}^{K}w_{k}x(p + p_{k} + {\Delta}p_{k}) * {\Delta}m_{k} + + \f] +Where +* K is a number of sampling locations, e.g. for kernel 3x3 and dilation = 1, K = 9 + +* \f$x(p)\f$ and \f$y(p)\f$ denote the features at location p from the input feature maps x and output feature maps y + +* \f$w_{k}\f$ is the weight for k-th location. + +* \f$p_{k}\f$ is pre-specified offset for the k-th location, e.g. K = 9 and +\f$p_{k} \in \{(-1, -1),(-1, 0), . . . ,(1, 1)\}\f$ + +* \f${\Delta}p_{k}\f$ is the learnable offset for the k-th location. + +* \f${\Delta}m_{k}\f$ is the modulation scalar from 0 to 1 for the k-th location. + +**Attributes**: + +* *strides* + + * **Description**: *strides* is a distance (in pixels) to slide the filter on the feature map over the `(y,x)` axes. For example, *strides* equal `2,1` means sliding the filter 2 pixel at a time over height dimension and 1 over width dimension. + * **Range of values**: integer values starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + +* *pads_begin* + + * **Description**: *pads_begin* is a number of pixels to add to the beginning along each axis. For example, *pads_begin* equal `1,2` means adding 1 pixel to the top of the input and 2 to the left of the input. + * **Range of values**: integer values starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + * **Note**: the attribute is ignored when *auto_pad* attribute is specified. + +* *pads_end* + + * **Description**: *pads_end* is a number of pixels to add to the ending along each axis. For example, *pads_end* equal `1,2` means adding 1 pixel to the bottom of the input and 2 to the right of the input. + * **Range of values**: integer values starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + * **Note**: the attribute is ignored when *auto_pad* attribute is specified. + +* *dilations* + + * **Description**: *dilations* denotes the distance in width and height between elements (weights) in the filter. For example, *dilation* equal `1,1` means that all the elements in the filter are neighbors, so it is the same as for the usual convolution. *dilation* equal `2,2` means that all the elements in the filter are matched not to adjacent elements in the input matrix, but to those that are adjacent with distance 1. + * **Range of values**: integer value starting from `0` + * **Type**: `int[]` + * **Default value**: None + * **Required**: *yes* + +* *auto_pad* + + * **Description**: *auto_pad* how the padding is calculated. Possible values: + * *explicit* - use explicit padding values from *pads_begin* and *pads_end*. + * *same_upper* - the input is padded to match the output size. In case of odd padding value an extra padding is added at the end. + * *same_lower* - the input is padded to match the output size. In case of odd padding value an extra padding is added at the beginning. + * *valid* - do not use padding. + * **Type**: `string` + * **Default value**: explicit + * **Required**: *no* + * **Note**: *pads_begin* and *pads_end* attributes are ignored when *auto_pad* is specified. + + +* *group* + + * **Description**: *group* is the number of groups which *output* and *input* should be split into. For example, *group* equal to 1 means that all filters are applied to the whole input (usual convolution), *group* equal to 2 means that both *input* and *output* channels are separated into two groups and the *i-th output* group is connected to the *i-th input* group channel. *group* equal to a number of output feature maps implies depth-wise separable convolution. + * **Range of values**: integer value starting from `1` + * **Type**: `int` + * **Default value**: `1` + * **Required**: *no* + +* *deformable_group* + + * **Description**: *deformable_group* is the number of groups in which *offsets* input and *output* should be split into along the channel axis. Apply the deformable convolution using the i-th part of the offsets part on the i-th out. + * **Range of values**: integer value starting from `1` + * **Type**: `int` + * **Default value**: `1` + * **Required**: *no* + +* *bilinear_interpolation_padding* + + * **Description**: *bilinear_interpolation_padding* is the number of pixels outside of the feature map boundary to apply bilinear interpolation. + * **Range of values**: non-negative integer value + * **Type**: `int` + * **Default value**: `0` + * **Required**: *no* + +**Inputs**: + +* **1**: Input tensor of type *T* and rank 4. Layout is `NCYX` (number of batches, number of channels, spatial axes Y and X). **Required.** + +* **2**: Offsets tensor of type *T* and rank 4. Layout is `NCYX` (number of batches, *deformable_group* \* kernel_Y \* kernel_X \* 2, spatial axes Y and X). **Required.** + +* **3**: Kernel tensor of type *T* and rank 4. Layout is `OIYX` (number of output channels, number of input channels, spatial axes Y and X). **Required.** + +* **4**: ModulationScalars tensor of type *T2* and rank 4, the values are within [0, 1]. Layout is `NCYX` (number of batches, *deformable_group* \* kernel_Y \* kernel_X, spatial axes Y and X). If the input is not provided, the values are assumed to be equal to 1. **Optional.** + + +**Outputs**: + +* **1**: Output tensor of type *T* and rank 4. Layout is `NOYX` (number of batches, number of kernel output channels, spatial axes Y and X). + +**Types**: + +* *T*: Any numeric type. +* *T2*: Any supported floating point. + +**Example** + +2D DeformableConvolution (deformable_group=1) +```xml + + + + + 1 + 4 + 224 + 224 + + + 1 + 50 + 220 + 220 + + + 64 + 4 + 5 + 5 + + + 1 + 25 + 220 + 220 + + + + + 1 + 64 + 220 + 220 + + + +``` diff --git a/docs/ops/opset8.md b/docs/ops/opset8.md index 8f43927b5ec..fc68d6f32e0 100644 --- a/docs/ops/opset8.md +++ b/docs/ops/opset8.md @@ -40,7 +40,7 @@ declared in `namespace opset8`. * [Cos](arithmetic/Cos_1.md) * [Cosh](arithmetic/Cosh_1.md) * [CumSum](arithmetic/CumSum_3.md) -* [DeformableConvolution](convolution/DeformableConvolution_1.md) +* [DeformableConvolution](convolution/DeformableConvolution_8.md) * [DeformablePSROIPooling](detection/DeformablePSROIPooling_1.md) * [DepthToSpace](movement/DepthToSpace_1.md) * [DetectionOutput](detection/DetectionOutput_1.md) diff --git a/docs/ops/sort/MatrixNMS_8.md b/docs/ops/sort/MatrixNMS_8.md new file mode 100644 index 00000000000..d3a42230722 --- /dev/null +++ b/docs/ops/sort/MatrixNMS_8.md @@ -0,0 +1,168 @@ +## MatrixNonMaxSuppression {#openvino_docs_ops_sort_MatrixNms_8} + +**Versioned name**: *MatrixNonMaxSuppression-8* + +**Category**: *Sorting and maximization* + +**Short description**: *MatrixNonMaxSuppression* performs matrix non-maximum suppression (NMS) of the boxes with predicted scores. + +**Detailed description**: The operation performs the following: + +1. Selects candidate bounding boxes with scores higher than `score_threshold`. +2. For each class, selects at most `nms_top_k` candidate boxes. +3. Decays scores of the candidate boxes according to the Matrix NMS algorithm [Wang et al](https://arxiv.org/abs/2003.10152.pdf). This algorithm is applied independently to each class and each batch element. Boxes of `background_class` are skipped and thus eliminated during the process. +4. Selects boxes with the decayed scores higher than `post_threshold`, and selects at most `keep_top_k` scoring candidate boxes per batch element. + +The Matrix NMS algorithm is described below: +1. Sort descending the candidate boxes by score, and compute `n*n` pairwise IOU (IntersectionOverUnion) matrix `X` for the top `n` boxes. Suppose `n` is the number of candidate boxes. +2. Set the lower triangle and diagonal of `X` to 0. Therefore get the upper triangular matrix `X`. +3. Take the column-wise max of `X` to compute a vector `K` of maximum IOU for each candidate box. +4. Repeat element value of `K` along axis 1. Suppose this gets a matrix `X_cmax`. +5. Compute the decay factor: `decay_factor = exp((X_cmax**2 - X**2) * gaussian_sigma)` if `decay_function` is `guassian`, else `decay_factor = (1 - X) / (1 - X_cmax)`. +6. Take the column-wise min of `decay_factor`, and element-wise multiply with scores to decay them. + +**Attributes**: + +* *sort_result* + + * **Description**: *sort_result* specifies the order of output elements. + * **Range of values**: `class`, `score`, `none` + * *class* - sort selected boxes by class id (ascending). + * *score* - sort selected boxes by score (descending). + * *none* - do not guarantee the order. + * **Type**: `string` + * **Default value**: `none` + * **Required**: *No* + +* *sort_result_across_batch* + + * **Description**: *sort_result_across_batch* is a flag that specifies whenever it is necessary to sort selected boxes across batches or not. + * **Range of values**: true or false + * *true* - sort selected boxes across batches. + * *false* - do not sort selected boxes across batches (boxes are sorted per batch element). + * **Type**: boolean + * **Default value**: false + * **Required**: *No* + +* *output_type* + + * **Description**: the tensor type of outputs `selected_indices` and `valid_outputs`. + * **Range of values**: `i64` or `i32` + * **Type**: `string` + * **Default value**: `i64` + * **Required**: *No* + +* *score_threshold* + + * **Description**: minimum score to consider box for the processing. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +* *nms_top_k* + + * **Description**: maximum number of boxes to be selected per class. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *keep_top_k* + + * **Description**: maximum number of boxes to be selected per batch element. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *background_class* + + * **Description**: the background class id. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all classes + * **Required**: *No* + +* *decay_function* + + * **Description**: decay function used to decay scores. + * **Range of values**: `gaussian`, `linear` + * **Type**: `string` + * **Default value**: `linear` + * **Required**: *No* + +* *gaussian_sigma* + + * **Description**: gaussian_sigma parameter for gaussian decay_function. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `2.0` + * **Required**: *No* + +* *post_threshold* + + * **Description**: threshold to filter out boxes with low confidence score after decaying. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +**Inputs**: + +* **1**: `boxes` - tensor of type *T* and shape `[num_batches, num_boxes, 4]` with box coordinates. The box cooridnates are layout as `[xmin, ymin, xmax, ymax]`. **Required.** + +* **2**: `scores` - tensor of type *T* and shape `[num_batches, num_classes, num_boxes]` with box scores. **Required.** + +**Outputs**: + +* **1**: `selected_outputs` - tensor of type *T_THRESHOLDS* and shape `[number of selected boxes, 6]` containing the selected boxes with score and class as tuples `[class_id, box_score, xmin, ymin, xmax, ymax]`. + +* **2**: `selected_indices` - tensor of type *T_IND* and shape `[number of selected boxes, 1]` the selected indices in the flattened input `boxes`, which are absolute values cross batches. Therefore possible valid values are in the range `[0, num_batches * num_boxes - 1]`. + +* **3**: `selected_num` - 1D tensor of type *T_IND* and shape `[num_batches]` representing the number of selected boxes for each batch element. + +When there is no box selected, `selected_num` is filled with `0`. `selected_outputs` is an empty tensor of shape `[0, 6]`, and `selected_indices` is an empty tensor of shape `[0, 1]`. + +**Types** + +* *T*: floating point type. + +* *T_MAX_BOXES*: integer type. + +* *T_THRESHOLDS*: floating point type. + +* *T_IND*: `int64` or `int32`. + +**Example** + +```xml + + + + + 3 + 100 + 4 + + + 3 + 5 + 100 + + + + + -1 + 6 + + + -1 + 1 + + + 3 + + + +``` diff --git a/docs/ops/sort/MulticlassNMS_8.md b/docs/ops/sort/MulticlassNMS_8.md new file mode 100644 index 00000000000..16997a81397 --- /dev/null +++ b/docs/ops/sort/MulticlassNMS_8.md @@ -0,0 +1,161 @@ +## MulticlassNonMaxSuppression {#openvino_docs_ops_sort_MulticlassNonMaxSuppression_8} + +**Versioned name**: *MulticlassNonMaxSuppression-8* + +**Category**: *Sorting and maximization* + +**Short description**: *MulticlassNonMaxSuppression* performs multi-class non-maximum suppression of the boxes with predicted scores. + +**Detailed description**: *MulticlassNonMaxSuppression* is a multi-phase operation. It implements non-maximum suppression algorithm as described below: + +1. Let `B = [b_0,...,b_n]` be the list of initial detection boxes, `S = [s_0,...,s_N]` be the list of corresponding scores. +2. Let `D = []` be an initial collection of resulting boxes. Let `adaptive_threshold = iou_threshold`. +3. If `B` is empty, go to step 9. +4. Take the box with highest score. Suppose that it is the box `b` with the score `s`. +5. Delete `b` from `B`. +6. If the score `s` is greater than or equal to `score_threshold`, add `b` to `D`, else go to step 9. +7. If `nms_eta < 1` and `adaptive_threshold > 0.5`, update `adaptive_threshold *= nms_eta`. +8. For each input box `b_i` from `B` and the corresponding score `s_i`, set `s_i = 0` when `iou(b, b_i) > adaptive_threshold`, and go to step 3. +9. Return `D`, a collection of the corresponding scores `S`, and the number of elements in `D`. + +This algorithm is applied independently to each class of each batch element. The operation feeds at most `nms_top_k` scoring candidate boxes to this algorithm. +The total number of output boxes of each batch element must not exceed `keep_top_k`. +Boxes of `background_class` are skipped and thus eliminated. + +**Attributes**: + +* *sort_result* + + * **Description**: *sort_result* specifies the order of output elements. + * **Range of values**: `class`, `score`, `none` + * *class* - sort selected boxes by class id (ascending). + * *score* - sort selected boxes by score (descending). + * *none* - do not guarantee the order. + * **Type**: `string` + * **Default value**: `none` + * **Required**: *No* + +* *sort_result_across_batch* + + * **Description**: *sort_result_across_batch* is a flag that specifies whenever it is necessary to sort selected boxes across batches or not. + * **Range of values**: true or false + * *true* - sort selected boxes across batches. + * *false* - do not sort selected boxes across batches (boxes are sorted per batch element). + * **Type**: boolean + * **Default value**: false + * **Required**: *No* + +* *output_type* + + * **Description**: the tensor type of outputs `selected_indices` and `valid_outputs`. + * **Range of values**: `i64` or `i32` + * **Type**: `string` + * **Default value**: `i64` + * **Required**: *No* + +* *iou_threshold* + + * **Description**: intersection over union threshold. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +* *score_threshold* + + * **Description**: minimum score to consider box for the processing. + * **Range of values**: a floating-point number + * **Type**: `float` + * **Default value**: `0` + * **Required**: *No* + +* *nms_top_k* + + * **Description**: maximum number of boxes to be selected per class. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *keep_top_k* + + * **Description**: maximum number of boxes to be selected per batch element. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all boxes + * **Required**: *No* + +* *background_class* + + * **Description**: the background class id. + * **Range of values**: an integer + * **Type**: `int` + * **Default value**: `-1` meaning to keep all classes. + * **Required**: *No* + +* *nms_eta* + + * **Description**: eta parameter for adaptive NMS. + * **Range of values**: a floating-point number in close range `[0, 1.0]`. + * **Type**: `float` + * **Default value**: `1.0` + * **Required**: *No* + +**Inputs**: + +* **1**: `boxes` - tensor of type *T* and shape `[num_batches, num_boxes, 4]` with box coordinates. The box coordinates are layout as `[xmin, ymin, xmax, ymax]`. **Required.** + +* **2**: `scores` - tensor of type *T* and shape `[num_batches, num_classes, num_boxes]` with box scores. **Required.** + +**Outputs**: + +* **1**: `selected_outputs` - tensor of type *T_THRESHOLDS* and shape `[number of selected boxes, 6]` containing the selected boxes with score and class as tuples `[class_id, box_score, xmin, ymin, xmax, ymax]`. + +* **2**: `selected_indices` - tensor of type *T_IND* and shape `[number of selected boxes, 1]` the selected indices in the flattened `boxes`, which are absolute values cross batches. Therefore possible valid values are in the range `[0, num_batches * num_boxes - 1]`. + +* **3**: `selected_num` - 1D tensor of type *T_IND* and shape `[num_batches]` representing the number of selected boxes for each batch element. + +When there is no box selected, `selected_num` is filled with `0`. `selected_outputs` is an empty tensor of shape `[0, 6]`, and `selected_indices` is an empty tensor of shape `[0, 1]`. + +**Types** + +* *T*: floating point type. + +* *T_MAX_BOXES*: integer type. + +* *T_THRESHOLDS*: floating point type. + +* *T_IND*: `int64` or `int32`. + +**Example** + +```xml + + + + + 3 + 100 + 4 + + + 3 + 5 + 100 + + + + + -1 + 6 + + + -1 + 1 + + + 3 + + + +``` diff --git a/docs/template_plugin/tests/functional/skip_tests_config.cpp b/docs/template_plugin/tests/functional/skip_tests_config.cpp index 252ed7c9a71..8d100118a9d 100644 --- a/docs/template_plugin/tests/functional/skip_tests_config.cpp +++ b/docs/template_plugin/tests/functional/skip_tests_config.cpp @@ -10,10 +10,10 @@ std::vector disabledTestPatterns() { return { ".*ExclusiveAsyncRequests.*", - ".*reusableCPUStreamsExecutor.*", + ".*ReusableCPUStreamsExecutor.*", R"(.*SplitLayerTest.*numSplits\=30.*)", // CVS-51758 ".*PreprocessConversionTest.*oLT=NHWC.*", ".*PreprocessDynamicallyInSetBlobTest.*oPRC=0.*oLT=1.*", }; -} \ No newline at end of file +} diff --git a/inference-engine/include/cpp/ie_executable_network.hpp b/inference-engine/include/cpp/ie_executable_network.hpp index eb1824f9da0..81d5b10e7dd 100644 --- a/inference-engine/include/cpp/ie_executable_network.hpp +++ b/inference-engine/include/cpp/ie_executable_network.hpp @@ -32,9 +32,6 @@ class IExecutableNetworkInternal; class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) { details::SharedObjectLoader _so; std::shared_ptr _impl; - IE_SUPPRESS_DEPRECATED_START - std::shared_ptr actual; - IE_SUPPRESS_DEPRECATED_END /** * @brief Constructs ExecutableNetwork from the initialized std::shared_ptr @@ -51,18 +48,6 @@ public: */ ExecutableNetwork() = default; - IE_SUPPRESS_DEPRECATED_START - /** - * @deprecated This ctor will be removed in 2022.1 - * @brief Constructs ExecutableNetwork from the initialized std::shared_ptr - * @param exec Initialized shared pointer - * @param splg Plugin to use. This is required to ensure that ExecutableNetwork can work properly even if plugin object is destroyed. - */ - INFERENCE_ENGINE_DEPRECATED("This ctor will be removed in 2022.1") - explicit ExecutableNetwork(std::shared_ptr exec, - std::shared_ptr splg = {}); - IE_SUPPRESS_DEPRECATED_END - /** * @brief Gets the Executable network output Data node information. * diff --git a/inference-engine/include/cpp/ie_infer_request.hpp b/inference-engine/include/cpp/ie_infer_request.hpp index fd71bf18bc2..c5d52ec6fc0 100644 --- a/inference-engine/include/cpp/ie_infer_request.hpp +++ b/inference-engine/include/cpp/ie_infer_request.hpp @@ -35,10 +35,6 @@ class ICompletionCallbackWrapper; class INFERENCE_ENGINE_API_CLASS(InferRequest) { details::SharedObjectLoader _so; std::shared_ptr _impl; - IE_SUPPRESS_DEPRECATED_START - IInferRequest::Ptr actual; - std::shared_ptr callback; - IE_SUPPRESS_DEPRECATED_END /** * @brief Constructs InferRequest from the initialized std::shared_ptr @@ -71,18 +67,6 @@ public: */ InferRequest() = default; - IE_SUPPRESS_DEPRECATED_START - /** - * @deprecated This ctor will be removed in 2022.1 - * @brief Constructs InferRequest from the initialized std::shared_ptr - * @param request Initialized shared pointer - * @param splg Plugin to use. This is required to ensure that InferRequest can work properly even if plugin object is destroyed. - */ - INFERENCE_ENGINE_DEPRECATED("This ctor will be removed in 2022.1") - explicit InferRequest(IInferRequest::Ptr request, - std::shared_ptr splg = {}); - IE_SUPPRESS_DEPRECATED_END - /** * @brief Sets input/output data to infer * diff --git a/inference-engine/include/cpp/ie_memory_state.hpp b/inference-engine/include/cpp/ie_memory_state.hpp index 0c055cec40c..8d54f79f06c 100644 --- a/inference-engine/include/cpp/ie_memory_state.hpp +++ b/inference-engine/include/cpp/ie_memory_state.hpp @@ -3,7 +3,7 @@ // /** - * @brief A header file that provides wrapper classes for IVariableState + * @brief A header file that provides VariableState * * @file ie_memory_state.hpp */ @@ -16,21 +16,17 @@ #include "ie_api.h" #include "ie_blob.h" #include "details/ie_so_loader.h" -#include "ie_imemory_state.hpp" namespace InferenceEngine { class IVariableStateInternal; /** - * @brief C++ exception based error reporting wrapper of API class IVariableState + * @brief VariableState class */ class INFERENCE_ENGINE_API_CLASS(VariableState) { details::SharedObjectLoader _so; std::shared_ptr _impl; - IE_SUPPRESS_DEPRECATED_START - std::shared_ptr actual; - IE_SUPPRESS_DEPRECATED_END /** * @brief Constructs VariableState from the initialized std::shared_ptr @@ -48,55 +44,27 @@ public: */ VariableState() = default; - IE_SUPPRESS_DEPRECATED_START /** - * @deprecated This ctor will be removed in 2022.1 - * @brief constructs VariableState from the initialized std::shared_ptr - * @param pState Initialized shared pointer - * @param plg Optional: Plugin to use. This is required to ensure that VariableState can work properly even if plugin object is destroyed. - */ - INFERENCE_ENGINE_DEPRECATED("This ctor will be removed in 2022.1") - explicit VariableState(std::shared_ptr pState, - std::shared_ptr plg = {}); - IE_SUPPRESS_DEPRECATED_END - - /** - * @copybrief IVariableState::Reset - * - * Wraps IVariableState::Reset + * @brief Reset internal variable state for relevant infer request, + * to a value specified as default for according ReadValue node */ void Reset(); /** - * @copybrief IVariableState::GetName - * - * Wraps IVariableState::GetName + * @brief Gets name of current variable state, if length of array is not enough name is truncated by len, null + * terminator is inserted as well. As variable state name `variable_id` from according `ReadValue` used. * @return A string representing a state name */ std::string GetName() const; /** - * @copybrief IVariableState::GetState - * - * Wraps IVariableState::GetState + * @brief Returns the value of the variable state. * @return A blob representing a state */ Blob::CPtr GetState() const; /** - * @copybrief IVariableState::GetLastState - * @deprecated Use IVariableState::SetState instead - * - * Wraps IVariableState::GetLastState - * @return A blob representing a last state - */ - INFERENCE_ENGINE_DEPRECATED("Use VariableState::GetState function instead") - Blob::CPtr GetLastState() const; - - /** - * @copybrief IVariableState::SetState - * - * Wraps IVariableState::SetState + * @brief Sets the new state for the next inference. * @param state The current state to set */ void SetState(Blob::Ptr state); diff --git a/inference-engine/include/gna/gna_config.hpp b/inference-engine/include/gna/gna_config.hpp index 958227696a1..3433ab58887 100644 --- a/inference-engine/include/gna/gna_config.hpp +++ b/inference-engine/include/gna/gna_config.hpp @@ -65,6 +65,7 @@ DECLARE_GNA_CONFIG_KEY(DEVICE_MODE); DECLARE_GNA_CONFIG_VALUE(AUTO); DECLARE_GNA_CONFIG_VALUE(HW); +DECLARE_GNA_CONFIG_VALUE(HW_WITH_SW_FBACK); DECLARE_GNA_CONFIG_VALUE(SW); DECLARE_GNA_CONFIG_VALUE(SW_EXACT); DECLARE_GNA_CONFIG_VALUE(SW_FP32); diff --git a/inference-engine/include/ie_iexecutable_network.hpp b/inference-engine/include/ie_iexecutable_network.hpp index caef9bb95b9..bb0a6f71c4a 100644 --- a/inference-engine/include/ie_iexecutable_network.hpp +++ b/inference-engine/include/ie_iexecutable_network.hpp @@ -18,7 +18,6 @@ #include "ie_common.h" #include "ie_icnn_network.hpp" #include "ie_iinfer_request.hpp" -#include "ie_imemory_state.hpp" #include "ie_input_info.hpp" #include "ie_parameter.hpp" #include "ie_remote_context.hpp" @@ -113,22 +112,6 @@ public: INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::ExecutableNetwork::GetExecGraphInfo instead") virtual StatusCode GetExecGraphInfo(ICNNNetwork::Ptr& graphPtr, ResponseDesc* resp) noexcept = 0; - /** - * @deprecated Use InferRequest::QueryState instead - * @brief Gets state control interface for given executable network. - * - * State control essential for recurrent networks - * - * @param pState reference to a pointer that receives internal states - * @param idx requested index for receiving memory state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success, OUT_OF_BOUNDS (-6) no memory state for - * given index - */ - INFERENCE_ENGINE_DEPRECATED("Use InferRequest::QueryState instead") - virtual StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept = 0; - IE_SUPPRESS_DEPRECATED_END - /** * @brief Sets configuration for current executable network * diff --git a/inference-engine/include/ie_iinfer_request.hpp b/inference-engine/include/ie_iinfer_request.hpp index 7d762d96a11..4fd200c0252 100644 --- a/inference-engine/include/ie_iinfer_request.hpp +++ b/inference-engine/include/ie_iinfer_request.hpp @@ -17,7 +17,6 @@ #include "ie_blob.h" #include "ie_common.h" #include "ie_preprocess.hpp" -#include "ie_imemory_state.hpp" namespace InferenceEngine { @@ -195,21 +194,6 @@ public: */ virtual InferenceEngine::StatusCode SetBatch(int batch_size, ResponseDesc* resp) noexcept = 0; - IE_SUPPRESS_DEPRECATED_START - /** - * @brief Gets state control interface for given infer request. - * - * State control essential for recurrent networks - * - * @param pState reference to a pointer that receives internal states - * @param idx requested index for receiving memory state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success, OUT_OF_BOUNDS (-6) no memory state for - * given index - */ - virtual StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept = 0; - IE_SUPPRESS_DEPRECATED_END - protected: ~IInferRequest() = default; }; diff --git a/inference-engine/include/ie_imemory_state.hpp b/inference-engine/include/ie_imemory_state.hpp deleted file mode 100644 index 7f3ef99cbd1..00000000000 --- a/inference-engine/include/ie_imemory_state.hpp +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief a header file for IVariableState interface - * - * @file ie_imemory_state.hpp - */ - -#pragma once - -#include - -#include "ie_blob.h" -#include "ie_common.h" - -namespace InferenceEngine { - -/** - * @deprecated Use InferenceEngine::VariableState C++ wrapper instead - * @interface IVariableState - * @brief Manages data for reset operations - */ -class INFERENCE_ENGINE_DEPRECATED("InferenceEngine::") IVariableState { -public: - IE_SUPPRESS_DEPRECATED_START - /** - * @brief A shared pointer to the IVariableState interface - */ - using Ptr = std::shared_ptr; - IE_SUPPRESS_DEPRECATED_END - - /** - * @brief Gets name of current variable state, if length of array is not enough name is truncated by len, null - * terminator is inserted as well. As variable state name `variable_id` from according `ReadValue` used. - * - * @param name preallocated buffer for receiving name - * @param len Length of the buffer - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - virtual StatusCode GetName(char* name, size_t len, ResponseDesc* resp) const noexcept = 0; - - /** - * @brief Reset internal variable state for relevant infer request, to a value specified as default for according ReadValue node - * - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success* - */ - virtual StatusCode Reset(ResponseDesc* resp) noexcept = 0; - - /** - * @brief Sets the new state for the next inference. - * - * This method can fail if Blob size does not match the internal state size or precision - * - * @param newState The data to use as new state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - virtual StatusCode SetState(Blob::Ptr newState, ResponseDesc* resp) noexcept = 0; - - /** - * @brief Returns the value of the variable state. - * - * @param state A reference to a blob containing a variable state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - INFERENCE_ENGINE_DEPRECATED("Use GetState function instead") - virtual StatusCode GetLastState(Blob::CPtr& state, ResponseDesc* resp) const noexcept { - return GetState(state, resp); - } - - /** - * @brief Returns the value of the variable state. - * - * @param state A reference to a blob containing a variable state - * @param resp Optional: pointer to an already allocated object to contain information in case of failure - * @return Status code of the operation: InferenceEngine::OK (0) for success - */ - virtual StatusCode GetState(Blob::CPtr& state, ResponseDesc* resp) const noexcept = 0; -}; - -IE_SUPPRESS_DEPRECATED_START - -/** - * @brief For compatibility reasons. - */ -using IMemoryState = IVariableState; - -IE_SUPPRESS_DEPRECATED_END - -} // namespace InferenceEngine \ No newline at end of file diff --git a/inference-engine/include/ie_parameter.hpp b/inference-engine/include/ie_parameter.hpp index 1343f89db32..4aa6760d474 100644 --- a/inference-engine/include/ie_parameter.hpp +++ b/inference-engine/include/ie_parameter.hpp @@ -49,26 +49,6 @@ public: std::swap(ptr, parameter.ptr); } - /** - * @deprecated Use ngraph::Variant directly - * @brief Creates parameter from variant. - * This method creates empty parameter if variant doesn't contain Parameter - * - * @param var ngraph variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - Parameter(const std::shared_ptr& var); - - /** - * @deprecated Use ngraph::Variant directly - * @brief Creates parameter from variant. - * This method creates empty parameter if variant doesn't contain Parameter - * - * @param var ngraph variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - Parameter(std::shared_ptr& var); - /** * @brief Copy constructor * @@ -86,7 +66,8 @@ public: * @param parameter object */ template ::type, Parameter>::value>::type> + typename = typename std::enable_if::type, Parameter>::value && + !std::is_abstract::type>::value>::type> Parameter(T&& parameter) { // NOLINT static_assert(!std::is_same::type, Parameter>::value, "To prevent recursion"); ptr = new RealData::type>(std::forward(parameter)); @@ -203,28 +184,6 @@ public: return dyn_cast::type>(ptr); } - /** - * @deprecated Use ngraph::Variant directly - * @brief Converts parameter to shared pointer on ngraph::Variant - * - * @return shared pointer on ngraph::Variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - std::shared_ptr asVariant() const; - - /** - * @deprecated Use ngraph::Variant directly - * @brief Casts to shared pointer on ngraph::Variant - * - * @return shared pointer on ngraph::Variant - */ - INFERENCE_ENGINE_DEPRECATED("Use ngraph::Variant directly") - operator std::shared_ptr() const { - IE_SUPPRESS_DEPRECATED_START - return asVariant(); - IE_SUPPRESS_DEPRECATED_END - } - /** * Dynamic cast to specified type * @tparam T type @@ -254,6 +213,21 @@ public: return !(*this == rhs); } + /** + * @brief Prints underlying object to the given output stream. + * Uses operator<< if it is defined, leaves stream unchanged otherwise. + * In case of empty parameter or nullptr stream immediately returns. + * + * @param object Object to be printed to the given output stream. + * @param stream Output stream object will be printed to. + */ + friend void PrintTo(const Parameter& object, std::ostream* stream) { + if (object.empty() || !stream) { + return; + } + object.ptr->print(*stream); + } + private: template struct CheckOperatorEqual { @@ -273,6 +247,24 @@ private: template struct HasOperatorEqual : CheckOperatorEqual::type {}; + template + struct CheckOutputStreamOperator { + template + static auto test(W*) -> decltype(std::declval() << std::declval(), std::true_type()) { + return {}; + } + + template + static auto test(...) -> std::false_type { + return {}; + } + + using type = typename std::is_same(nullptr))>::type; + }; + + template + struct HasOutputStreamOperator : CheckOutputStreamOperator::type {}; + struct Any { #ifdef __ANDROID__ virtual ~Any(); @@ -282,6 +274,7 @@ private: virtual bool is(const std::type_info&) const = 0; virtual Any* copy() const = 0; virtual bool operator==(const Any& rhs) const = 0; + virtual void print(std::ostream&) const = 0; }; template @@ -318,6 +311,20 @@ private: bool operator==(const Any& rhs) const override { return rhs.is(typeid(T)) && equal(*this, rhs); } + + template + typename std::enable_if::value, void>::type + print(std::ostream& stream, const U& object) const {} + + template + typename std::enable_if::value, void>::type + print(std::ostream& stream, const U& object) const { + stream << object; + } + + void print(std::ostream& stream) const override { + print(stream, get()); + } }; template diff --git a/inference-engine/include/ie_unicode.hpp b/inference-engine/include/ie_unicode.hpp deleted file mode 100644 index dc943d6f558..00000000000 --- a/inference-engine/include/ie_unicode.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief This is a header file with common inference engine definitions - * - * @file ie_unicode.hpp - */ -#pragma once - -#include -#include -#include -#include -#include -#include - -#ifdef UNICODE -typedef wchar_t tchar; -typedef std::wstring file_name_t; -#else -typedef char tchar; -typedef std::string file_name_t; -#endif - -namespace InferenceEngine { - -/** - * @deprecated Use OS-native conversion utilities - * @brief Conversion from possibly-wide character string to a single-byte chain. - * @param str A possibly-wide character string - * @return A single-byte character string - */ -INFERENCE_ENGINE_DEPRECATED("Use OS-native conversion utilities") -inline std::string fileNameToString(const file_name_t& str) { -#ifdef UNICODE - size_t maxlen = (str.length() + 1) * sizeof(wchar_t) / sizeof(char); - std::vector mbstr(maxlen); - mbstr[0] = 0; - std::wcstombs(&mbstr[0], str.c_str(), maxlen); - std::string res = std::string(&mbstr[0]); - return res; -#else - return str; -#endif -} - -/** - * @deprecated Use OS-native conversion utilities - * @brief Conversion from single-byte character string to a possibly-wide one - * @param str A single-byte character string - * @return A possibly-wide character string - */ -INFERENCE_ENGINE_DEPRECATED("Use OS-native conversion utilities") -inline file_name_t stringToFileName(const std::string& str) { -#ifdef UNICODE - size_t maxlen = str.length() + 1; - std::vector wcstr(maxlen); - wcstr[0] = 0; - std::mbstowcs(&wcstr[0], str.c_str(), maxlen); - file_name_t res = file_name_t(&wcstr[0]); - return res; -#else - return str; -#endif -} - -} // namespace InferenceEngine diff --git a/inference-engine/samples/speech_sample/main.cpp b/inference-engine/samples/speech_sample/main.cpp index 2b9131774ad..57db61a8e9e 100644 --- a/inference-engine/samples/speech_sample/main.cpp +++ b/inference-engine/samples/speech_sample/main.cpp @@ -236,7 +236,8 @@ float getGnaFrequencyMHz() { const uint8_t cannon_lake_model = 102; const uint8_t gemini_lake_model = 122; const uint8_t ice_lake_model = 126; - const uint8_t next_model = 140; + const uint8_t tgl_model = 140; + const uint8_t next_model = 151; native_cpuid(&eax, &ebx, &ecx, &edx); family = (eax >> 8) & 0xF; @@ -254,6 +255,7 @@ float getGnaFrequencyMHz() { switch (model) { case cannon_lake_model: case ice_lake_model: + case tgl_model: case next_model: return 400; case gemini_lake_model: @@ -287,13 +289,14 @@ void printReferenceCompareResults(score_error_t const& totalError, size_t frames /** * @brief Print a report on the performance counts * @param utterancePerfMap reference to a map to store performance counters - * @param callsNum frame index + * @param numberOfFrames number of frames * @param stream output stream * @param fullDeviceName full device name string + * @param numberOfFramesOnHw number of frames delivered to GNA HW * @return none. */ -void printPerformanceCounters(std::map const& utterancePerfMap, size_t callsNum, std::ostream& stream, - std::string fullDeviceName) { +void printPerformanceCounters(std::map const& utterancePerfMap, size_t numberOfFrames, + std::ostream& stream, std::string fullDeviceName, const uint64_t numberOfFramesOnHw) { #if !defined(__arm__) && !defined(_M_ARM) && !defined(__aarch64__) && !defined(_M_ARM64) stream << std::endl << "Performance counts:" << std::endl; stream << std::setw(10) << std::right << "" @@ -305,29 +308,29 @@ void printPerformanceCounters(std::map(it.second.realTime_uSec); - float call_units = current_units / callsNum; - // if GNA HW counters - // get frequency of GNA module - float freq = getGnaFrequencyMHz(); - current_units /= freq * 1000; - call_units /= freq; + float current_units_us = static_cast(it.second.realTime_uSec) / freq; + float call_units_us = current_units_us / numberOfFrames; if (FLAGS_d.find("GNA") != std::string::npos) { stream << std::setw(30) << std::left << counter_name.substr(4, counter_name.size() - 1); } else { stream << std::setw(30) << std::left << counter_name; } - stream << std::setw(16) << std::right << current_units; - stream << std::setw(21) << std::right << call_units; + stream << std::setw(16) << std::right << current_units_us / 1000; + stream << std::setw(21) << std::right << call_units_us; stream << std::endl; } stream << std::endl; std::cout << std::endl; std::cout << "Full device name: " << fullDeviceName << std::endl; std::cout << std::endl; + stream << "Number of frames delivered to GNA HW: " << numberOfFramesOnHw; + stream << "/" << numberOfFrames; + stream << std::endl; #endif } @@ -346,16 +349,20 @@ void getPerformanceCounters(InferenceEngine::InferRequest& request, std::map const& perfCounters, - std::map& totalPerfCounters) { + std::map& totalPerfCounters, uint64_t& totalRunsOnHw) { + auto runOnHw = false; for (const auto& pair : perfCounters) { totalPerfCounters[pair.first].realTime_uSec += pair.second.realTime_uSec; + runOnHw |= pair.second.realTime_uSec > 0; // if realTime is above zero, that means that a primitive was executed on the device } + totalRunsOnHw += runOnHw; } /** @@ -443,6 +450,7 @@ bool ParseAndCheckCommandLine(int argc, char* argv[]) { "GPU", "GNA_AUTO", "GNA_HW", + "GNA_HW_WITH_SW_FBACK", "GNA_SW_EXACT", "GNA_SW", "GNA_SW_FP32", @@ -829,6 +837,7 @@ int main(int argc, char* argv[]) { /** Work with each utterance **/ for (uint32_t utteranceIndex = 0; utteranceIndex < numUtterances; ++utteranceIndex) { std::map utterancePerfMap; + uint64_t totalNumberOfRunsOnHw = 0; std::string uttName; uint32_t numFrames(0), n(0); std::vector numFrameElementsInput; @@ -984,7 +993,7 @@ int main(int argc, char* argv[]) { // retrieve new counters getPerformanceCounters(inferRequest.inferRequest, callPerfMap); // summarize retrieved counters with all previous - sumPerformanceCounters(callPerfMap, utterancePerfMap); + sumPerformanceCounters(callPerfMap, utterancePerfMap, totalNumberOfRunsOnHw); } } // ----------------------------------------------------------------------------------------------------- @@ -1092,7 +1101,7 @@ int main(int argc, char* argv[]) { std::cout << "Average Infer time per frame:\t\t" << totalTime / static_cast(numFrames) << " ms" << std::endl; if (FLAGS_pc) { // print performance results - printPerformanceCounters(utterancePerfMap, frameIndex, std::cout, getFullDeviceName(ie, FLAGS_d)); + printPerformanceCounters(utterancePerfMap, frameIndex, std::cout, getFullDeviceName(ie, FLAGS_d), totalNumberOfRunsOnHw); } if (!FLAGS_r.empty()) { // print statistical score error diff --git a/inference-engine/samples/speech_sample/speech_sample.hpp b/inference-engine/samples/speech_sample/speech_sample.hpp index cafe4db5c61..66d3b24a4c5 100644 --- a/inference-engine/samples/speech_sample/speech_sample.hpp +++ b/inference-engine/samples/speech_sample/speech_sample.hpp @@ -21,10 +21,9 @@ static const char model_message[] = "Required. Path to an .xml file with a train /// @brief message for assigning cnn calculation to device static const char target_device_message[] = "Optional. Specify a target device to infer on. CPU, GPU, MYRIAD, GNA_AUTO, GNA_HW, " - "GNA_SW_FP32, " + "GNA_HW_WITH_SW_FBACK, GNA_SW_FP32, " "GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU" - " as a secondary (e.g. HETERO:GNA,CPU) are supported. The list of available devices is shown " - "below. " + " as a secondary (e.g. HETERO:GNA,CPU) are supported. " "The sample will look for a suitable plugin for device specified."; /// @brief message for execution target diff --git a/inference-engine/src/gna_plugin/CMakeLists.txt b/inference-engine/src/gna_plugin/CMakeLists.txt index f3ce2858570..36b9d6d5cc0 100644 --- a/inference-engine/src/gna_plugin/CMakeLists.txt +++ b/inference-engine/src/gna_plugin/CMakeLists.txt @@ -29,12 +29,15 @@ endif() # # Shared plugin library -# +# ie_add_plugin(NAME ${TARGET_NAME} DEVICE_NAME "GNA" SOURCES ${SOURCES} ${HEADERS}) +# Enable support of CC for the plugin +ie_mark_target_as_cc(${TARGET_NAME}) + # saving rpath to GNA shared library be used by CI log_rpath_from_dir(GNA ${libGNA_LIBRARIES_BASE_PATH}) @@ -67,7 +70,8 @@ target_compile_definitions(${TARGET_NAME}_test_static target_link_libraries(${TARGET_NAME}_test_static PUBLIC inference_engine_preproc_s inference_engine_transformations libGNA::API) target_include_directories(${TARGET_NAME}_test_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - $) + $ + PRIVATE $) set_target_properties(${TARGET_NAME}_test_static PROPERTIES COMPILE_PDB_NAME ${TARGET_NAME}_test_static) set_target_properties(${TARGET_NAME} ${TARGET_NAME}_test_static @@ -76,6 +80,6 @@ set_target_properties(${TARGET_NAME} ${TARGET_NAME}_test_static # install file(GLOB_RECURSE source_list "${libGNA_LIBRARIES_BASE_PATH}/*${CMAKE_SHARED_LIBRARY_SUFFIX}*") -install(FILES ${source_list} +install(FILES ${source_list} DESTINATION ${IE_CPACK_IE_DIR}/external/gna/lib COMPONENT gna) diff --git a/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp b/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp index 1f3f125a029..b57813858ac 100644 --- a/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp +++ b/inference-engine/src/gna_plugin/frontend/model_quantizer.hpp @@ -15,6 +15,7 @@ #include "layer_quantizer.hpp" #include "scale_factor_calc.hpp" #include "weights_converter.hpp" +#include "gna_itt.hpp" namespace GNAPluginNS { @@ -40,6 +41,7 @@ class ModelQuantizer { template InferenceEngine::CNNNetwork quantize(const InferenceEngine::CNNNetwork &model, const PreQuantisationCb &cb, std::vector scaleFactor) const { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ModelQuantizer::quantize"); auto visitor = [&](InferenceEngine::CNNLayerPtr lp) { auto newLayer = InferenceEngine::injectData(lp); transformLayer(newLayer, WeightsConverter()); diff --git a/inference-engine/src/gna_plugin/gna_device.cpp b/inference-engine/src/gna_plugin/gna_device.cpp index cbfc47f57aa..85a246ea34f 100644 --- a/inference-engine/src/gna_plugin/gna_device.cpp +++ b/inference-engine/src/gna_plugin/gna_device.cpp @@ -96,14 +96,12 @@ void GNADeviceHelper::setUpActiveList(const uint32_t requestConfigId, uint32_t l const auto status = Gna2RequestConfigEnableActiveList(requestConfigId, layerIndex, num_active_indices, ptr_active_indices); checkGna2Status(status, "Gna2RequestConfigEnableActiveList"); } -void GNADeviceHelper::propagateSync(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode) { - wait(propagate(requestConfigId, gna2AccelerationMode)); -} uint32_t GNADeviceHelper::propagate(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode) { std::unique_lock lockGnaCalls{ acrossPluginsSync }; uint32_t reqId{}; - if (gna2AccelerationMode == Gna2AccelerationModeHardware && + if ((gna2AccelerationMode == Gna2AccelerationModeHardware || + gna2AccelerationMode == Gna2AccelerationModeHardwareWithSoftwareFallback) && detectedGnaDevVersion == Gna2DeviceVersionSoftwareEmulation) { gnawarn() << "GNA Device not detected, consider using other mode of acceleration"; } @@ -541,6 +539,8 @@ void GNADeviceHelper::updateGnaPerfCounters() { #if GNA_LIB_VER == 2 instrumentationTotal[0] = instrumentationResults[0]; instrumentationTotal[1] = instrumentationResults[1]; + instrumentationResults[0] = 0; + instrumentationResults[1] = 0; #else nGNAPerfResultsTotal.hw.stall = nGNAPerfResults.hw.stall; nGNAPerfResultsTotal.hw.total = nGNAPerfResults.hw.total; diff --git a/inference-engine/src/gna_plugin/gna_device.hpp b/inference-engine/src/gna_plugin/gna_device.hpp index e032e5532da..cae32c70b1d 100644 --- a/inference-engine/src/gna_plugin/gna_device.hpp +++ b/inference-engine/src/gna_plugin/gna_device.hpp @@ -117,18 +117,12 @@ public: uint8_t *alloc(uint32_t size_requested, uint32_t *size_granted); #if GNA_LIB_VER == 1 - void propagateSync(const intel_nnet_type_t *pNeuralNetwork, - const uint32_t *pActiveIndices, - uint32_t nActiveIndices, - intel_gna_proc_t nGNAProcType); - uint32_t propagate(const intel_nnet_type_t *pNeuralNetwork, const uint32_t *pActiveIndices, uint32_t nActiveIndices, intel_gna_proc_t nGNAProcType); #else void setUpActiveList(unsigned req_config_id, uint32_t layerIndex, uint32_t* ptr_active_indices, uint32_t num_active_indices); - void propagateSync(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode); uint32_t propagate(const uint32_t requestConfigId, Gna2AccelerationMode gna2AccelerationMode); uint32_t createModel(Gna2Model& gnaModel) const; void releaseModel(const uint32_t model_id); diff --git a/inference-engine/src/gna_plugin/gna_itt.hpp b/inference-engine/src/gna_plugin/gna_itt.hpp new file mode 100644 index 00000000000..3fa02119733 --- /dev/null +++ b/inference-engine/src/gna_plugin/gna_itt.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief Defines openvino domains for tracing + * @file gna_itt.hpp + */ + +#pragma once + +#include + +namespace GNAPluginNS { +namespace itt { +namespace domains { + OV_ITT_DOMAIN(GNAPlugin); + OV_ITT_DOMAIN(GNA_LT); +} +} +} diff --git a/inference-engine/src/gna_plugin/gna_plugin.cpp b/inference-engine/src/gna_plugin/gna_plugin.cpp index f49d543def1..cb227304649 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin.cpp @@ -37,7 +37,7 @@ #include #include "gna_graph_patterns.hpp" #include "gna_tensor_tools.hpp" -#include +#include "gna_itt.hpp" #include #include @@ -391,6 +391,7 @@ GNAPlugin::GNAPlugin(const std::map& configMap) { } void GNAPlugin::Init() { + OV_ITT_SCOPED_TASK(itt::domains::GNAPlugin, "Init"); dnn = std::make_shared(backend::AMIntelDNN()); inputsDesc = std::make_shared(GNAPluginNS::InputDesc()); gnaFlags = std::make_shared(GNAPluginNS::GNAFlags()); @@ -401,6 +402,7 @@ void GNAPlugin::Init() { } void GNAPlugin::InitGNADevice() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InitGNADevice"); #if GNA_LIB_VER == 1 gnadevice = std::make_shared(gnaFlags->gna_lib_async_threads_num, gnaFlags->gna_openmp_multithreading, @@ -419,6 +421,7 @@ void GNAPlugin::InitGNADevice() { } void GNAPlugin::UpdateGnaQuantModeFromNetwork(InferenceEngine::CNNNetwork & network) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UpdateGnaQuantModeFromNetwork"); // fp32 emulation mode dont need any modifications to configuration if (config.gnaFlags.sw_fp32) return; @@ -454,6 +457,7 @@ void GNAPlugin::UpdateGnaQuantModeFromNetwork(InferenceEngine::CNNNetwork & netw } void GNAPlugin::UpdateInputScaleFromNetwork(InferenceEngine::CNNNetwork & network) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UpdateInputScaleFromNetwork"); // fp32 emulation mode dont need any modifications to configuration if (config.gnaFlags.sw_fp32) return; @@ -561,6 +565,7 @@ bool GNAPlugin::TryToInitOutput(int portId, InferenceEngine::CNNLayerPtr layer) } void GNAPlugin::FillInputsAndOutputsTranspositionInfo(const InferenceEngine::CNNNetwork& net) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FillInputsAndOutputsTranspositionInfo"); auto printTranspositionInfo = [](const std::vector &transpositionInfo) { for (const auto &transpositionInfoPart : transpositionInfo) { gnalog() << "transpose=" << transpositionInfoPart.transpose << " rows_num=" << transpositionInfoPart.num_transpose_rows @@ -663,6 +668,7 @@ void GNAPlugin::AddDebugProperties(const InferenceEngine::CNNLayerPtr layer, #endif void GNAPlugin::LoadNetwork(CNNNetwork & _network) { + OV_ITT_SCOPED_TASK(itt::domains::GNAPlugin, "LoadNetwork"); std::shared_ptr convertedNetwork; if (_network.getFunction()) { CNNNetwork clonedNetwork = InferenceEngine::cloneNetwork(_network); diff --git a/inference-engine/src/gna_plugin/gna_plugin_config.cpp b/inference-engine/src/gna_plugin/gna_plugin_config.cpp index 2dcb05d6ab8..766e7d2d52c 100644 --- a/inference-engine/src/gna_plugin/gna_plugin_config.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin_config.cpp @@ -23,6 +23,7 @@ static const caseless_unordered_map supported_values = { {GNAConfigParams::GNA_SW_EXACT, GNA_SOFTWARE & GNA_HARDWARE} }; static const std::vector supported_values_on_gna2 = { + GNAConfigParams::GNA_HW_WITH_SW_FBACK, GNAConfigParams::GNA_GEN, GNAConfigParams::GNA_GEN_EXACT, GNAConfigParams::GNA_SSE, @@ -34,18 +35,19 @@ static const std::vector supported_values_on_gna2 = { }; #else static const caseless_unordered_map > supported_values = { - {GNAConfigParams::GNA_AUTO, {Gna2AccelerationModeAuto, false}}, - {GNAConfigParams::GNA_HW, {Gna2AccelerationModeHardware, false}}, - {GNAConfigParams::GNA_SW, {Gna2AccelerationModeSoftware, false}}, - {GNAConfigParams::GNA_SW_EXACT, {Gna2AccelerationModeSoftware, true}}, - {GNAConfigParams::GNA_GEN, {Gna2AccelerationModeGeneric, false}}, - {GNAConfigParams::GNA_GEN_EXACT, {Gna2AccelerationModeGeneric, true}}, - {GNAConfigParams::GNA_SSE, {Gna2AccelerationModeSse4x2, false}}, - {GNAConfigParams::GNA_SSE_EXACT, {Gna2AccelerationModeSse4x2, true}}, - {GNAConfigParams::GNA_AVX1, {Gna2AccelerationModeAvx1, false}}, - {GNAConfigParams::GNA_AVX1_EXACT, {Gna2AccelerationModeAvx1, true}}, - {GNAConfigParams::GNA_AVX2, {Gna2AccelerationModeAvx2, false}}, - {GNAConfigParams::GNA_AVX2_EXACT, {Gna2AccelerationModeAvx2, true}}, + {GNAConfigParams::GNA_AUTO, {Gna2AccelerationModeAuto, false}}, + {GNAConfigParams::GNA_HW, {Gna2AccelerationModeHardware, false}}, + {GNAConfigParams::GNA_HW_WITH_SW_FBACK, {Gna2AccelerationModeHardwareWithSoftwareFallback, false}}, + {GNAConfigParams::GNA_SW, {Gna2AccelerationModeSoftware, false}}, + {GNAConfigParams::GNA_SW_EXACT, {Gna2AccelerationModeSoftware, true}}, + {GNAConfigParams::GNA_GEN, {Gna2AccelerationModeGeneric, false}}, + {GNAConfigParams::GNA_GEN_EXACT, {Gna2AccelerationModeGeneric, true}}, + {GNAConfigParams::GNA_SSE, {Gna2AccelerationModeSse4x2, false}}, + {GNAConfigParams::GNA_SSE_EXACT, {Gna2AccelerationModeSse4x2, true}}, + {GNAConfigParams::GNA_AVX1, {Gna2AccelerationModeAvx1, false}}, + {GNAConfigParams::GNA_AVX1_EXACT, {Gna2AccelerationModeAvx1, true}}, + {GNAConfigParams::GNA_AVX2, {Gna2AccelerationModeAvx2, false}}, + {GNAConfigParams::GNA_AVX2_EXACT, {Gna2AccelerationModeAvx2, true}}, }; #endif diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index ef333e7e46f..5355a7b28f1 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -41,6 +41,7 @@ #include "gna_graph_patterns.hpp" #include "gna_data_types.hpp" #include "gna_tensor_tools.hpp" +#include "gna_itt.hpp" using namespace InferenceEngine; using namespace InferenceEngine::details; @@ -112,6 +113,7 @@ static void insertDiagonalLayerBetween(InferenceEngine::CNNLayerPtr prevLayer, */ static CNNLayerPtr InsertCopyLayer(CNNLayerPtr prevLayer, CNNLayerPtr nextLayer, int beforeIdx, std::shared_ptr passmanager, std::string copyLayerType) { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertCopyLayer"); auto quantized = InferenceEngine::getInjectedData(prevLayer); std::string copyName = copyLayerType + std::string("_") + std::to_string(passmanager->getIntVar(copyLayersCounter)++); gnalog() << "Inserted " << copyName << " between: " << prevLayer->name << " and " << nextLayer->name << std::endl; @@ -257,6 +259,7 @@ static std::vector getCandidatesForIdentityInsertion(const CNNLayer } void InsertDiagonalLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertDiagonalLayerPass"); bool lowPrecision = getPassManager()->isLowPrecision(); for (auto & l : *pLayers) { @@ -304,6 +307,7 @@ void InsertDiagonalLayerPass::run() { } void HandleMultipleActivationsForTheLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "HandleMultipleActivationsForTheLayerPass"); // found layer followed by multiple activations for (auto & l : *pLayers) { CNNLayerSet activations; @@ -333,6 +337,7 @@ void HandleMultipleActivationsForTheLayerPass::run() { } void ForbidActivationFusingPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ForbidActivationFusingPass"); for (auto& l : *pLayers) { if (LayerInfo(l).isActivation()) { auto prevLayer = CNNNetPrevLayer(l); @@ -370,6 +375,7 @@ namespace { } // namespace void ReorderMaxPoolPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ReorderMaxPoolPass"); // detecting following pattern // conv->activation->maxpooling // changing it to conv->maxpooling->activation @@ -398,6 +404,7 @@ void ReorderMaxPoolPass::run() { } void SubstituteSoftSignPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "SubstituteSoftSignPass"); //detecting following pattern // irv7 model: irv10 model: // a layer a layer @@ -501,6 +508,7 @@ void SubstituteSoftSignPass::run() { } } void SubstitutePReluPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "SubstitutePReluPass"); auto getScale = [](CNNLayer* layer) { auto powerCandidate = LayerInfo(layer); if (!powerCandidate.isPower()) return 0.0f; @@ -606,6 +614,7 @@ void SubstitutePReluPass::run() { } void ReversePermutationsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ReversePermutationsPass"); std::function)> prevLayerSkipCertain = [&prevLayerSkipCertain](CNNLayerPtr layer, std::function shouldSkip) -> CNNLayerPtr { if (CNNNetHasPrevLayer(layer.get())) { @@ -698,6 +707,7 @@ void ReversePermutationsPass::run() { } void RemovePermutationsNHWCToNCHWPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "RemovePermutationsNHWCToNCHWPass"); std::set permutations_to_remove; std::list> nhwc_layout_patterns; for (auto& l : *pLayers) { @@ -781,6 +791,7 @@ void RemovePermutationsNHWCToNCHWPass::run() { } void InsertIdentityLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertIdentityLayerPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); auto createIdentityLayer = [quantized, this](const TensorDesc& tensorDesc) { int numOfIdentityLayers = this->getPassManager()->getIntVar(identityLayersCounterName)++; @@ -898,6 +909,7 @@ void InsertIdentityLayerPass::run() { } void InsertCopyLayerPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertCopyLayerPass"); // Copy layer insertion happens in few cases: // Crop output goes to concat layer -> copy layer insertion // Splitted part of input goes to concat layer -> copy layer insertion @@ -1020,6 +1032,7 @@ void InsertCopyLayerPass::run() { } void FlattenTrivialConcatPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FlattenTrivialConcatPass"); // change all trivial concatenations (concatenation where output buffer is a buffer made by appending input buffers) // by reshaping its inputs to 1 x total_input_size and its output to 1 x total_cocat_size and chaning the axis to 1 // for example if 4D concat have unaligned inputs then ConcatAlignFilters need to be used if sizes before @@ -1103,6 +1116,7 @@ void FlattenTrivialConcatPass::run() { } void InsertConcatAligningFilterPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertConcatAligningFilterPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); if (getPassManager()->getPolicy().ConcatAlignmentPolicy == Policy::ConcatAlignment::DISABLED) { @@ -1221,6 +1235,7 @@ void InsertConcatAligningFilterPass::run() { } void ReorderConcatInputsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "ReorderConcatInputsPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); // aligning specific not required in fp32 mode if (getPassManager()->getPolicy().ConcatAlignmentPolicy == Policy::ConcatAlignment::DISABLED_FOR_FP32 && !quantized) { @@ -1318,6 +1333,7 @@ void ReorderConcatInputsPass::run() { } void InsertSplitAligningFilterPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertSplitAligningFilterPass"); // currently split layer only supports 2 bytes in int16 and int8 mode. In fp32 mode this is not necessary but is useful for testing const int bytesPerSplitElement = 2; auto quantized = InferenceEngine::getInjectedData(pLayers->front()); @@ -1437,6 +1453,7 @@ static InferenceEngine::Blob::Ptr tileBlob(Blob::Ptr& blob, size_t TileTo) { } void EltwiseSplitOverChannelsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "EltwiseSplitOverChannelsPass"); if (getPassManager()->getPolicy().GNAAffineDiagonalPolicy.limitedTo == Policy::GNAAffineDiagonal::UNLIMIT) { return; } @@ -1552,6 +1569,7 @@ void EltwiseSplitOverChannelsPass::run() { } void SubstituteScaleShiftBroadCastPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "SubstituteScaleShiftBroadCastPass"); std::map reshaped_data; auto quantized = InferenceEngine::getInjectedData(pLayers->front()); @@ -1633,6 +1651,7 @@ void SubstituteScaleShiftBroadCastPass::run() { } void BroadcastConstPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "BroadcastConstPass"); for (auto constLayer : *pLayers) { if (!LayerInfo(constLayer).isConst()) { continue; @@ -1685,6 +1704,7 @@ void BroadcastConstPass::run() { } void InsertIdentityToLSTMCellPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "InsertIdentityToLSTMCellPass"); for (auto layer : *pLayers) { if (layer->type == "LSTMCell") { // This fixed the cases when both functional and non-functional outputs are mixed (or not outputs are used) @@ -1722,6 +1742,7 @@ void InsertIdentityToLSTMCellPass::run() { } void BreakFusingOfOutputLayersPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "BreakFusingOfOutputLayersPass"); #if GNA_LIB_VER == 1 return; #endif @@ -1765,6 +1786,7 @@ void BreakFusingOfOutputLayersPass::run() { } void UnrollLSTMCellPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UnrollLSTMCellPass"); InferenceEngine::NetPass::UnrollRNN_if(getPassManager()->getNetwork(), [] (const RNNCellBase& rnn) -> bool { if (rnn.clip != 0.0f) return true; @@ -1781,6 +1803,7 @@ void UnrollLSTMCellPass::run() { } void UnrollTIPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "UnrollTIPass"); auto sts = InferenceEngine::NetPass::UnrollTI(getPassManager()->getNetwork()); if (!sts) { THROW_GNA_EXCEPTION << "TensorIterator layer cannot be unrolled!"; @@ -1788,6 +1811,7 @@ void UnrollTIPass::run() { } void RemoveConstPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "RemoveConstPass"); auto network = getPassManager()->getNetwork(); IE_SUPPRESS_DEPRECATED_START auto & icnnnet = static_cast(network); @@ -1801,6 +1825,7 @@ void RemoveConstPass::run() { } void RemoveSingleInputConcatPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "RemoveSingleInputConcatPass"); for (auto &l : *pLayers) { if (l->type == "Concat") { auto concat = dynamic_cast(l.get()); @@ -1828,6 +1853,7 @@ void RemoveSingleInputConcatPass::run() { } void FuseMultipleIdentitiesPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FuseMultipleIdentitiesPass"); for (auto &l : *pLayers) { if (l->insData.empty()) continue; @@ -1909,6 +1935,7 @@ void FuseMultipleIdentitiesPass::run() { } void FuseFQIntoWeightsPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "FuseFQIntoWeightsPass"); auto isNonFunctional = [](CNNLayerPtr ptr) { return LayerInfo(ptr).isNonFunctional(); }; @@ -2067,6 +2094,7 @@ void FuseFQIntoWeightsPass::run() { } void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "MoveFakeQuantizeLayerIntoQuantParamsPass"); auto quantized = InferenceEngine::getInjectedData(pLayers->front()); if (!quantized) { return; @@ -2268,6 +2296,7 @@ void MoveFakeQuantizeLayerIntoQuantParamsPass :: run() { } void TransposeWeightsFromNCHWToNHWCPass::run() { + OV_ITT_SCOPED_TASK(itt::domains::GNA_LT, "TransposeWeightsFromNCHWToNHWCPass"); if (!MustBeConvertedFromNCHWToNHWC(*pLayers)) return; auto printTranspositionInfo = [](const std::vector &transpositionInfo) { diff --git a/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp index da7e6279624..e49d95ac2f2 100644 --- a/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp +++ b/inference-engine/src/gna_plugin/transformations/convert_matmul_to_pointwise_convolution.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "transformations/convert_matmul_to_pointwise_convolution.hpp" @@ -107,6 +108,7 @@ static bool Convert(std::shared_ptr matmul_node, } ConvertMatmulToPointWiseConvolution::ConvertMatmulToPointWiseConvolution() { + MATCHER_SCOPE(ConvertMatmulToPointWiseConvolution); auto const_input = ngraph::pattern::wrap_type(); auto const_fq = ngraph::pattern::wrap_type({const_input, ngraph::pattern::wrap_type(), @@ -121,11 +123,12 @@ ConvertMatmulToPointWiseConvolution::ConvertMatmulToPointWiseConvolution() { return Convert(pattern_map.at(matmul).get_node_shared_ptr(), nullptr, nullptr, nullptr); }; - auto m = std::make_shared(matmul, "ConvertMatmulToPointWiseConvolution"); + auto m = std::make_shared(matmul, matcher_name); this->register_matcher(m, callback); } ConvertMatmulWithBiasToPointWiseConvolution::ConvertMatmulWithBiasToPointWiseConvolution() { + MATCHER_SCOPE(ConvertMatmulWithBiasToPointWiseConvolution); auto const_input = ngraph::pattern::wrap_type(); auto const_fq = ngraph::pattern::wrap_type({const_input, ngraph::pattern::wrap_type(), @@ -143,11 +146,12 @@ ConvertMatmulWithBiasToPointWiseConvolution::ConvertMatmulWithBiasToPointWiseCon pattern_map.at(bias).get_node_shared_ptr(), nullptr); }; - auto m = std::make_shared(add, "ConvertMatmulWithBiasToPointWiseConvolution"); + auto m = std::make_shared(add, matcher_name); this->register_matcher(m, callback); } ConvertMatmulWithFqToPointWiseConvolution::ConvertMatmulWithFqToPointWiseConvolution() { + MATCHER_SCOPE(ConvertMatmulWithFqToPointWiseConvolution); auto const_input = ngraph::pattern::wrap_type(); auto const_fq = ngraph::pattern::wrap_type({const_input, ngraph::pattern::wrap_type(), @@ -175,6 +179,6 @@ ConvertMatmulWithFqToPointWiseConvolution::ConvertMatmulWithFqToPointWiseConvolu pattern_map.at(out_fq).get_node_shared_ptr()); }; - auto m = std::make_shared(out_fq, "ConvertMatmulWithFqToPointWiseConvolution"); + auto m = std::make_shared(out_fq, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp b/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp index 6bfef2587ae..4954529762d 100644 --- a/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp +++ b/inference-engine/src/gna_plugin/transformations/insert_transpose_after_convolution_or_pooling.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "transformations/insert_transpose_after_convolution_or_pooling.hpp" @@ -16,6 +17,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(InsertTransposeAfterConvOrPool, "InsertTransposeAfterConvOrPool", 0); bool InsertTransposeAfterConvOrPool::run_on_function(std::shared_ptr f) { + RUN_ON_FUNCTION_SCOPE(InsertTransposeAfterConvOrPool); bool is_graph_modfied = false; for (auto& node : f->get_ordered_ops()) { if (std::dynamic_pointer_cast(node) == nullptr && diff --git a/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp b/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp index 4de8966d351..3e5c579af8f 100644 --- a/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp +++ b/inference-engine/src/gna_plugin/transformations/insert_transpose_before_matmul.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "transformations/insert_transpose_before_matmul.hpp" #include @@ -13,6 +15,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(InsertTransposeBeforeMatmul, "InsertTransposeBeforeMatmul", 0); InsertTransposeBeforeMatmul::InsertTransposeBeforeMatmul() { + MATCHER_SCOPE(InsertTransposeBeforeMatmul); auto reshape = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}, ngraph::pattern::rank_equals(2)); @@ -59,6 +62,6 @@ InsertTransposeBeforeMatmul::InsertTransposeBeforeMatmul() { return true; }; - auto m = std::make_shared(root, "InsertTransposeBeforeMatmul"); + auto m = std::make_shared(root, matcher_name); this->register_matcher(m, callback); } diff --git a/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp b/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp index 1a7d6da2a33..e1cfdefa311 100644 --- a/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp +++ b/inference-engine/src/gna_plugin/transformations/remove_extra_reshapes.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "transformations/remove_extra_reshapes.hpp" #include @@ -12,6 +14,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(RemoveExtraReshapes, "RemoveExtraReshapes", 0); RemoveExtraReshapes::RemoveExtraReshapes() { + MATCHER_SCOPE(RemoveExtraReshapes); const auto reshape = ngraph::pattern::wrap_type(); const auto pooling = ngraph::pattern::wrap_type({reshape}); @@ -26,6 +29,6 @@ RemoveExtraReshapes::RemoveExtraReshapes() { return true; }; - auto m = std::make_shared(pooling, "RemoveExtraReshapes"); + auto m = std::make_shared(pooling, matcher_name); this->register_matcher(m, callback); } diff --git a/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp b/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp index 69bab295ba7..7e67d900e38 100644 --- a/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp +++ b/inference-engine/src/gna_plugin/transformations/reorder_activation_and_pooling.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "transformations/reorder_activation_and_pooling.hpp" #include @@ -15,6 +17,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(ReorderActivationAndPooling, "ReorderActivationAndPooling", 0); ReorderActivationAndPooling::ReorderActivationAndPooling() { + MATCHER_SCOPE(ReorderActivationAndPooling); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); auto add = ngraph::pattern::wrap_type({conv, ngraph::pattern::any_input()}); @@ -63,6 +66,6 @@ ReorderActivationAndPooling::ReorderActivationAndPooling() { return true; }; - auto m = std::make_shared(pool, "ReorderActivationAndPooling"); + auto m = std::make_shared(pool, matcher_name); this->register_matcher(m, callback); } diff --git a/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp index a9d79c831ab..2e750308e5f 100644 --- a/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp +++ b/inference-engine/src/gna_plugin/transformations/split_convolution_with_large_buffer_size.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "transformations/split_convolution_with_large_buffer_size.hpp" @@ -77,6 +78,7 @@ static bool Convert(std::shared_ptr conv, } SplitConvolution::SplitConvolution() { + MATCHER_SCOPE(SplitConvolution); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); @@ -85,11 +87,12 @@ SplitConvolution::SplitConvolution() { return Convert(pattern_map.at(conv).get_node_shared_ptr(), nullptr, nullptr, nullptr); }; - auto m = std::make_shared(conv, "SplitConvolution"); + auto m = std::make_shared(conv, matcher_name); this->register_matcher(m, callback); } SplitConvolutionWithBias::SplitConvolutionWithBias() { + MATCHER_SCOPE(SplitConvolutionWithBias); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); auto bias = ngraph::pattern::wrap_type(); @@ -101,11 +104,12 @@ SplitConvolutionWithBias::SplitConvolutionWithBias() { pattern_map.at(bias).get_node_shared_ptr(), nullptr); }; - auto m = std::make_shared(add, "SplitConvolutionWithBias"); + auto m = std::make_shared(add, matcher_name); this->register_matcher(m, callback); } SplitConvolutionWithFq::SplitConvolutionWithFq() { + MATCHER_SCOPE(SplitConvolutionWithFq); auto conv = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}); auto bias = ngraph::pattern::wrap_type(); @@ -126,6 +130,6 @@ SplitConvolutionWithFq::SplitConvolutionWithFq() { return Convert(pattern_map.at(conv).get_node_shared_ptr(), add_node, bias_node, pattern_map.at(out_fq).get_node_shared_ptr()); }; - auto m = std::make_shared(out_fq, "SplitConvolutionWithFq"); + auto m = std::make_shared(out_fq, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file diff --git a/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp b/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp index 9a725c33cf7..d177b83ba40 100644 --- a/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp +++ b/inference-engine/src/gna_plugin/transformations/swap_input_matmul_gna.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include @@ -19,6 +21,7 @@ using namespace GNAPluginNS; NGRAPH_RTTI_DEFINITION(SwapInputMatMul, "SwapInputMatMul", 0); SwapInputMatMul::SwapInputMatMul() { + MATCHER_SCOPE(SwapInputMatMul); auto matmul = ngraph::pattern::wrap_type({ngraph::pattern::any_input( ngraph::pattern::has_static_shape()), ngraph::pattern::any_input(ngraph::pattern::has_static_shape())}, ngraph::pattern::has_static_shape()); @@ -95,6 +98,6 @@ SwapInputMatMul::SwapInputMatMul() { return true; }; - auto m = std::make_shared(matmul, "SwapInputMatMul"); + auto m = std::make_shared(matmul, matcher_name); this->register_matcher(m, callback); } \ No newline at end of file diff --git a/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp b/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp index 6de781d11e6..a4afee5a28b 100644 --- a/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp @@ -25,47 +25,15 @@ ExecutableNetwork::ExecutableNetwork(const details::SharedObjectLoader& so, IE_SUPPRESS_DEPRECATED_START -ExecutableNetwork::ExecutableNetwork(IExecutableNetwork::Ptr exec, - std::shared_ptr splg) - : _so(), _impl(), actual(exec) { - if (splg) { - _so = *splg; - } - - // plg can be null, but not the actual - if (actual == nullptr) - IE_THROW(NotAllocated) << "ExecutableNetwork was not initialized."; -} - ConstOutputsDataMap ExecutableNetwork::GetOutputsInfo() const { - if (actual) { - ConstOutputsDataMap data; - CALL_STATUS_FNC(GetOutputsInfo, data); - return data; - } - EXEC_NET_CALL_STATEMENT(return _impl->GetOutputsInfo()); } ConstInputsDataMap ExecutableNetwork::GetInputsInfo() const { - if (actual) { - ConstInputsDataMap info; - CALL_STATUS_FNC(GetInputsInfo, info); - return info; - } - EXEC_NET_CALL_STATEMENT(return _impl->GetInputsInfo()); } void ExecutableNetwork::reset(IExecutableNetwork::Ptr newActual) { - if (actual) { - if (newActual == nullptr) { - THROW_IE_EXCEPTION << "ExecutableNetwork wrapper used for reset was not initialized."; - } - this->actual.swap(newActual); - return; - } - if (_impl == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; if (newActual == nullptr) IE_THROW() << "ExecutableNetwork wrapper used for reset was not initialized."; auto newBase = std::dynamic_pointer_cast(newActual); @@ -76,36 +44,10 @@ void ExecutableNetwork::reset(IExecutableNetwork::Ptr newActual) { } ExecutableNetwork::operator IExecutableNetwork::Ptr() { - if (actual) { - return actual; - } - return std::make_shared(_impl); } std::vector ExecutableNetwork::QueryState() { - if (actual) { - if (actual == nullptr) THROW_IE_EXCEPTION << "ExecutableNetwork was not initialized."; - IVariableState::Ptr pState = nullptr; - auto res = OK; - std::vector controller; - for (size_t idx = 0; res == OK; ++idx) { - ResponseDesc resp; - IE_SUPPRESS_DEPRECATED_START - res = actual->QueryState(pState, idx, &resp); - IE_SUPPRESS_DEPRECATED_END - if (res != OK && res != OUT_OF_BOUNDS) { - THROW_IE_EXCEPTION << resp.msg; - } - if (res != OUT_OF_BOUNDS) { - controller.push_back(VariableState(pState, - std::make_shared(_so))); - } - } - - return controller; - } - std::vector controller; EXEC_NET_CALL_STATEMENT( for (auto&& state : _impl->QueryState()) { @@ -115,13 +57,6 @@ std::vector ExecutableNetwork::QueryState() { } InferRequest ExecutableNetwork::CreateInferRequest() { - if (actual) { - IInferRequest::Ptr req; - CALL_STATUS_FNC(CreateInferRequest, req); - if (req.get() == nullptr) THROW_IE_EXCEPTION << "Internal error: pointer to infer request is null"; - return InferRequest(req, std::make_shared(_so)); - } - EXEC_NET_CALL_STATEMENT(return {_so, _impl->CreateInferRequest()}); } @@ -130,72 +65,38 @@ InferRequest::Ptr ExecutableNetwork::CreateInferRequestPtr() { } void ExecutableNetwork::Export(const std::string& modelFileName) { - if (actual) { - CALL_STATUS_FNC(Export, modelFileName); - return; - } EXEC_NET_CALL_STATEMENT(_impl->Export(modelFileName)); } void ExecutableNetwork::Export(std::ostream& networkModel) { - if (actual) { - CALL_STATUS_FNC(Export, networkModel); - return; - } EXEC_NET_CALL_STATEMENT(_impl->Export(networkModel)); } CNNNetwork ExecutableNetwork::GetExecGraphInfo() { - if (actual) { - IE_SUPPRESS_DEPRECATED_START - ICNNNetwork::Ptr ptr = nullptr; - CALL_STATUS_FNC(GetExecGraphInfo, ptr); - return CNNNetwork(ptr); - IE_SUPPRESS_DEPRECATED_END - } EXEC_NET_CALL_STATEMENT(return _impl->GetExecGraphInfo()); } void ExecutableNetwork::SetConfig(const std::map& config) { - if (actual) { - CALL_STATUS_FNC(SetConfig, config); - return; - } EXEC_NET_CALL_STATEMENT(_impl->SetConfig(config)); } Parameter ExecutableNetwork::GetConfig(const std::string& name) const { - if (actual) { - Parameter configValue; - CALL_STATUS_FNC(GetConfig, name, configValue); - return configValue; - } EXEC_NET_CALL_STATEMENT(return _impl->GetConfig(name)); } Parameter ExecutableNetwork::GetMetric(const std::string& name) const { - if (actual) { - Parameter metricValue; - CALL_STATUS_FNC(GetMetric, name, metricValue); - return metricValue; - } EXEC_NET_CALL_STATEMENT(return _impl->GetMetric(name)); } RemoteContext::Ptr ExecutableNetwork::GetContext() const { - if (actual) { - RemoteContext::Ptr pContext; - CALL_STATUS_FNC(GetContext, pContext); - return pContext; - } EXEC_NET_CALL_STATEMENT(return _impl->GetContext()); } bool ExecutableNetwork::operator!() const noexcept { - return !_impl || !actual; + return !_impl; } ExecutableNetwork::operator bool() const noexcept { - return !!_impl || !!actual; + return !!_impl; } } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp b/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp index 2f813c0b783..c87b1fc7098 100644 --- a/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp @@ -18,7 +18,6 @@ #include #include #include "cpp/exception2status.hpp" -#include "ie_variable_state_base.hpp" #include "ie_infer_async_request_base.hpp" namespace InferenceEngine { @@ -64,29 +63,10 @@ public: TO_STATUS(_impl->Export(networkModel)); } - IE_SUPPRESS_DEPRECATED_START StatusCode GetExecGraphInfo(ICNNNetwork::Ptr& graphPtr, ResponseDesc* resp) noexcept override { - // should be refactored together with ExecutableNetwork interface TO_STATUS(graphPtr = _impl->GetExecGraphInfo()); } - INFERENCE_ENGINE_DEPRECATED("Use InferRequest::QueryState instead") - StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept override { - try { - auto v = _impl->QueryState(); - if (idx >= v.size()) { - return OUT_OF_BOUNDS; - } - pState = std::make_shared(v[idx]); - return OK; - } catch (const std::exception& ex) { - return InferenceEngine::DescriptionBuffer(GENERAL_ERROR, resp) << ex.what(); - } catch (...) { - return InferenceEngine::DescriptionBuffer(UNEXPECTED); - } - } - IE_SUPPRESS_DEPRECATED_END - StatusCode SetConfig(const std::map& config, ResponseDesc* resp) noexcept override { TO_STATUS(_impl->SetConfig(config)); } diff --git a/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp b/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp index 1253947eeaf..6ede78f720e 100644 --- a/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_infer_async_request_base.hpp @@ -10,10 +10,10 @@ #include "cpp/exception2status.hpp" #include "cpp_interfaces/plugin_itt.hpp" -#include "ie_variable_state_base.hpp" #include #include "ie_iinfer_request.hpp" #include "ie_preprocess.hpp" + namespace InferenceEngine { #define CATCH_IE_EXCEPTION_TO_STATUS_NO_RESP(StatusCode, ExceptionType) catch (const ExceptionType& ex) { \ @@ -169,23 +169,6 @@ public: StatusCode SetBatch(int batch_size, ResponseDesc* resp) noexcept override { TO_STATUS(_impl->SetBatch(batch_size)); } - - IE_SUPPRESS_DEPRECATED_START - StatusCode QueryState(IVariableState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept override { - try { - auto v = _impl->QueryState(); - if (idx >= v.size()) { - return OUT_OF_BOUNDS; - } - pState = std::make_shared(v[idx]); - return OK; - } catch (const std::exception& ex) { - return InferenceEngine::DescriptionBuffer(GENERAL_ERROR, resp) << ex.what(); - } catch (...) { - return InferenceEngine::DescriptionBuffer(UNEXPECTED); - } - } - IE_SUPPRESS_DEPRECATED_END }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp b/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp index 97fba9af7f9..9e68666b7a3 100644 --- a/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp @@ -23,44 +23,17 @@ namespace InferenceEngine { InferRequest::InferRequest(const details::SharedObjectLoader& so, const IInferRequestInternal::Ptr& impl) - : _so(so), _impl(impl), actual() { + : _so(so), _impl(impl) { IE_ASSERT(_impl != nullptr); } IE_SUPPRESS_DEPRECATED_START -InferRequest::InferRequest(IInferRequest::Ptr request, - std::shared_ptr splg) - : _so(), _impl(), actual(request) { - if (splg) { - _so = *splg; - } - - // plg can be null, but not the actual - if (actual == nullptr) - IE_THROW(NotAllocated) << "InferRequest was not initialized."; -} - void InferRequest::SetBlob(const std::string& name, const Blob::Ptr& data) { - if (actual) { - CALL_STATUS_FNC(SetBlob, name.c_str(), data); - return; - } INFER_REQ_CALL_STATEMENT(_impl->SetBlob(name, data);) } Blob::Ptr InferRequest::GetBlob(const std::string& name) { - if (actual) { - Blob::Ptr data; - CALL_STATUS_FNC(GetBlob, name.c_str(), data); - std::string error = "Internal error: blob with name `" + name + "` is not allocated!"; - auto blobPtr = data.get(); - const bool remoteBlobPassed = blobPtr->is(); - if (blobPtr == nullptr) IE_THROW() << error; - if (!remoteBlobPassed && blobPtr->buffer() == nullptr) IE_THROW() << error; - return data; - } - Blob::Ptr blobPtr; INFER_REQ_CALL_STATEMENT(blobPtr = _impl->GetBlob(name);) std::string error = "Internal error: blob with name `" + name + "` is not allocated!"; @@ -71,60 +44,26 @@ Blob::Ptr InferRequest::GetBlob(const std::string& name) { } void InferRequest::SetBlob(const std::string &name, const Blob::Ptr &data, const PreProcessInfo& info) { - if (actual) { - CALL_STATUS_FNC(SetBlob, name.c_str(), data, info); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->SetBlob(name, data, info);) } const PreProcessInfo& InferRequest::GetPreProcess(const std::string& name) const { - if (actual) { - const PreProcessInfo* info = nullptr; - CALL_STATUS_FNC(GetPreProcess, name.c_str(), &info); - return *info; - } - INFER_REQ_CALL_STATEMENT(return _impl->GetPreProcess(name);) } void InferRequest::Infer() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(Infer); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->Infer();) } void InferRequest::Cancel() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(Cancel); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->Cancel();) } std::map InferRequest::GetPerformanceCounts() const { - if (actual) { - std::map perfMap; - CALL_STATUS_FNC(GetPerformanceCounts, perfMap); - return perfMap; - } - INFER_REQ_CALL_STATEMENT(return _impl->GetPerformanceCounts();) } void InferRequest::SetInput(const BlobMap& inputs) { - if (actual) { - for (auto&& input : inputs) { - CALL_STATUS_FNC(SetBlob, input.first.c_str(), input.second); - } - return; - } - INFER_REQ_CALL_STATEMENT( for (auto&& input : inputs) { _impl->SetBlob(input.first, input.second); @@ -133,13 +72,6 @@ void InferRequest::SetInput(const BlobMap& inputs) { } void InferRequest::SetOutput(const BlobMap& results) { - if (actual) { - for (auto&& result : results) { - CALL_STATUS_FNC(SetBlob, result.first.c_str(), result.second); - } - return; - } - INFER_REQ_CALL_STATEMENT( for (auto&& result : results) { _impl->SetBlob(result.first, result.second); @@ -148,106 +80,19 @@ void InferRequest::SetOutput(const BlobMap& results) { } void InferRequest::SetBatch(const int batch) { - if (actual) { - CALL_STATUS_FNC(SetBatch, batch); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->SetBatch(batch);) } void InferRequest::StartAsync() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(StartAsync); - return; - } - INFER_REQ_CALL_STATEMENT(_impl->StartAsync();) } StatusCode InferRequest::Wait(int64_t millis_timeout) { - if (actual) { - ResponseDesc resp; - if (actual == nullptr) IE_THROW() << "InferRequest was not initialized."; - auto res = actual->Wait(millis_timeout, &resp); - if (res != OK && res != RESULT_NOT_READY && - res != INFER_NOT_STARTED && res != INFER_CANCELLED) { - IE_EXCEPTION_SWITCH(res, ExceptionType, - InferenceEngine::details::ThrowNow{} - <<= std::stringstream{} << IE_LOCATION << resp.msg) - } - return res; - } - INFER_REQ_CALL_STATEMENT(return _impl->Wait(millis_timeout);) } -namespace details { - -class ICompletionCallbackWrapper { -public: - virtual ~ICompletionCallbackWrapper() = default; - - virtual void call(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) const noexcept = 0; -}; - -template -class CompletionCallbackWrapper : public ICompletionCallbackWrapper { - T lambda; - -public: - explicit CompletionCallbackWrapper(const T& lambda): lambda(lambda) {} - - void call(InferenceEngine::IInferRequest::Ptr /*request*/, InferenceEngine::StatusCode /*code*/) const - noexcept override { - lambda(); - } -}; - -template <> -class CompletionCallbackWrapper : public ICompletionCallbackWrapper { - IInferRequest::CompletionCallback callBack; - -public: - explicit CompletionCallbackWrapper(const IInferRequest::CompletionCallback& callBack): callBack(callBack) {} - - void call(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) const noexcept override { - callBack(request, code); - } -}; - -template <> -class CompletionCallbackWrapper> : public ICompletionCallbackWrapper { - std::function lambda; - -public: - explicit CompletionCallbackWrapper(const std::function& lambda) - : lambda(lambda) {} - - void call(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) const noexcept override { - lambda(InferRequest(request), code); - } -}; - -void callWrapper(InferenceEngine::IInferRequest::Ptr request, InferenceEngine::StatusCode code) { - details::ICompletionCallbackWrapper* pWrapper = nullptr; - ResponseDesc dsc; - request->GetUserData(reinterpret_cast(&pWrapper), &dsc); - pWrapper->call(request, code); -} - -} // namespace details - void InferRequest::SetCompletionCallbackImpl(std::function callbackToSet) { - if (actual) { - using T = std::function; - callback.reset(new details::CompletionCallbackWrapper(callbackToSet)); - CALL_STATUS_FNC(SetUserData, callback.get()); - actual->SetCompletionCallback(InferenceEngine::details::callWrapper); - return; - } - INFER_REQ_CALL_STATEMENT( _impl->SetCallback([callbackToSet] (std::exception_ptr) { callbackToSet(); @@ -274,14 +119,6 @@ void InferRequest::SetCompletionCallbackImpl(std::function callbackToSet void InferRequest::SetCompletionCallbackImpl(std::function callbackToSet) { - if (actual) { - using T = std::function; - callback.reset(new details::CompletionCallbackWrapper(callbackToSet)); - CALL_STATUS_FNC(SetUserData, callback.get()); - actual->SetCompletionCallback(InferenceEngine::details::callWrapper); - return; - } - INFER_REQ_CALL_STATEMENT( auto weakThis = InferRequest{_so, std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}}; _impl->SetCallback([callbackToSet, weakThis] (std::exception_ptr exceptionPtr) { @@ -303,14 +140,6 @@ void InferRequest::SetCompletionCallbackImpl(std::function(callbackToSet)); - CALL_STATUS_FNC(SetUserData, callback.get()); - actual->SetCompletionCallback(InferenceEngine::details::callWrapper); - return; - } - INFER_REQ_CALL_STATEMENT( IInferRequest::Ptr weakThis = InferRequest{_so, std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}}; _impl->SetCallback([callbackToSet, weakThis] (std::exception_ptr exceptionPtr) { @@ -332,38 +161,12 @@ void InferRequest::SetCompletionCallbackImpl(IInferRequest::CompletionCallback c } InferRequest::operator IInferRequest::Ptr () { - if (actual) { - return actual; - } - INFER_REQ_CALL_STATEMENT( return std::make_shared(_impl); ) } std::vector InferRequest::QueryState() { - if (actual) { - IE_SUPPRESS_DEPRECATED_START - if (actual == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; - IVariableState::Ptr pState = nullptr; - auto res = OK; - std::vector controller; - for (size_t idx = 0; res == OK; ++idx) { - ResponseDesc resp; - res = actual->QueryState(pState, idx, &resp); - if (res != OK && res != OUT_OF_BOUNDS) { - IE_THROW() << resp.msg; - } - if (res != OUT_OF_BOUNDS) { - controller.push_back(VariableState(pState, - std::make_shared(_so))); - } - } - IE_SUPPRESS_DEPRECATED_END - - return controller; - } - std::vector controller; INFER_REQ_CALL_STATEMENT( for (auto&& state : _impl->QueryState()) { @@ -374,11 +177,11 @@ std::vector InferRequest::QueryState() { } bool InferRequest::operator!() const noexcept { - return !_impl || !actual; + return !_impl; } InferRequest::operator bool() const noexcept { - return (!!_impl) || (!!actual); + return (!!_impl); } bool InferRequest::operator!=(const InferRequest& r) const noexcept { @@ -386,7 +189,7 @@ bool InferRequest::operator!=(const InferRequest& r) const noexcept { } bool InferRequest::operator==(const InferRequest& r) const noexcept { - return r._impl == _impl && r.actual == actual; + return r._impl == _impl; } } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp index 46f99d3fc6c..63f7305e8b2 100644 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp @@ -4,7 +4,6 @@ #include "details/ie_so_loader.h" #include "cpp/ie_memory_state.hpp" -#include "ie_imemory_state.hpp" #include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" #include "exception2status.hpp" @@ -24,57 +23,19 @@ VariableState::VariableState(const details::SharedObjectLoader& so, IE_SUPPRESS_DEPRECATED_START -VariableState::VariableState(std::shared_ptr state, - std::shared_ptr splg) - : _so(), _impl(), actual(state) { - if (splg) { - _so = *splg; - } - - // plg can be null, but not the actual - if (actual == nullptr) - IE_THROW(NotAllocated) << "VariableState was not initialized."; -} - -Blob::CPtr VariableState::GetLastState() const { - return GetState(); -} - void VariableState::Reset() { - if (actual) { - CALL_STATUS_FNC_NO_ARGS(Reset); - return; - } - VARIABLE_CALL_STATEMENT(_impl->Reset()); } std::string VariableState::GetName() const { - if (actual) { - char name[256]; - CALL_STATUS_FNC(GetName, name, sizeof(name)); - return name; - } - VARIABLE_CALL_STATEMENT(return _impl->GetName()); } Blob::CPtr VariableState::GetState() const { - if (actual) { - Blob::CPtr stateBlob; - CALL_STATUS_FNC(GetState, stateBlob); - return stateBlob; - } - VARIABLE_CALL_STATEMENT(return _impl->GetState()); } void VariableState::SetState(Blob::Ptr state) { - if (actual) { - CALL_STATUS_FNC(SetState, state); - return; - } - VARIABLE_CALL_STATEMENT(_impl->SetState(state)); } diff --git a/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp b/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp deleted file mode 100644 index 2481ca67852..00000000000 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -#include "cpp/exception2status.hpp" -#include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" -#include "ie_imemory_state.hpp" - -namespace InferenceEngine { - -IE_SUPPRESS_DEPRECATED_START - -/** - * @brief Default implementation for IVariableState - * @ingroup ie_dev_api_variable_state_api - */ -class VariableStateBase : public IVariableState { - std::shared_ptr impl; - -public: - /** - * @brief Constructor with actual underlying implementation. - * @param impl Underlying implementation of type IVariableStateInternal - */ - explicit VariableStateBase(std::shared_ptr impl): impl(impl) { - if (impl == nullptr) { - IE_THROW() << "VariableStateBase implementation is not defined"; - } - } - - StatusCode GetName(char* name, size_t len, ResponseDesc* resp) const noexcept override { - for (size_t i = 0; i != len; i++) { - name[i] = 0; - } - DescriptionBuffer buf(name, len); - TO_STATUS(buf << impl->GetName()); - return OK; - } - - StatusCode Reset(ResponseDesc* resp) noexcept override { - TO_STATUS(impl->Reset()); - } - - StatusCode SetState(Blob::Ptr newState, ResponseDesc* resp) noexcept override { - TO_STATUS(impl->SetState(newState)); - } - - StatusCode GetState(Blob::CPtr& state, ResponseDesc* resp) const noexcept override { - TO_STATUS(state = impl->GetState()); - } -}; - -IE_SUPPRESS_DEPRECATED_END - -} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp index 0171292d36b..a499e816ee0 100644 --- a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp @@ -23,7 +23,4 @@ Blob::CPtr IVariableStateInternal::GetState() const { return state; } -Blob::CPtr IVariableStateInternal::GetLastState() const { - return GetState(); -} } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/ie_parameter.cpp b/inference-engine/src/inference_engine/ie_parameter.cpp deleted file mode 100644 index 61fbf54c37d..00000000000 --- a/inference-engine/src/inference_engine/ie_parameter.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include - -namespace ngraph { - -template class INFERENCE_ENGINE_API_CLASS(VariantImpl); - -template <> -class INFERENCE_ENGINE_API_CLASS(VariantWrapper) : public VariantImpl { -public: - static constexpr VariantTypeInfo type_info {"Variant::InferenceEngine::Parameter", 0}; - const VariantTypeInfo& get_type_info() const override { - return type_info; - } - VariantWrapper(const value_type& value): VariantImpl(value) {} // NOLINT -}; - -} // namespace ngraph - -constexpr ngraph::VariantTypeInfo ngraph::VariantWrapper::type_info; - -InferenceEngine::Parameter::Parameter(const std::shared_ptr& var) { - if (auto paramWrapper = std::dynamic_pointer_cast>(var)) { - auto param = paramWrapper->get(); - if (!param.empty()) ptr = param.ptr->copy(); - } -} - -InferenceEngine::Parameter::Parameter(std::shared_ptr& var) { - if (auto paramWrapper = std::dynamic_pointer_cast>(var)) { - auto param = paramWrapper->get(); - if (!param.empty()) ptr = param.ptr->copy(); - } -} - - -std::shared_ptr InferenceEngine::Parameter::asVariant() const { - return std::make_shared>(*this); -} diff --git a/inference-engine/src/low_precision_transformations/src/split.cpp b/inference-engine/src/low_precision_transformations/src/split.cpp index 486111dd737..919c6b5e87b 100644 --- a/inference-engine/src/low_precision_transformations/src/split.cpp +++ b/inference-engine/src/low_precision_transformations/src/split.cpp @@ -111,13 +111,13 @@ void SplitTransformation::updateOutputs( updateOutput(context, lastNodes[0], originalNode); } else { const std::string originalName = originalNode->get_friendly_name(); - for (auto& lastNode : lastNodes) { + for (size_t outIdx = 0; outIdx < lastNodes.size(); ++outIdx) { for (size_t i = 0; i < outputSize; ++i) { std::shared_ptr result = context.function->get_output_op(i); std::shared_ptr outputNode = result->get_input_node_shared_ptr(0); - if (outputNode.get() == lastNode.get()) { + if (outputNode.get() == lastNodes[outIdx].get()) { originalNode->set_friendly_name(originalName + LayerTransformation::originalLayerPostfix); - lastNode->set_friendly_name(originalName + "." + std::to_string(i)); + lastNodes[outIdx]->set_friendly_name(originalName + "." + std::to_string(outIdx)); break; } } diff --git a/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp b/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp index ce0ae3473d9..babcc95303c 100644 --- a/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp +++ b/inference-engine/src/low_precision_transformations/src/weightable_layer_transformation.cpp @@ -157,10 +157,15 @@ bool WeightableLayerTransformation::canBeTransformed(const TransformationContext } const size_t outChannelsShapeIndex = is_type(layer) ? 1ul : 0ul; - if ( // Check if all dimensions of scale except the output channels are all ones + if ( + // expected, it's ok: return true + (shape_size(constOutputShape) != 1ul) && + // not expected, something wrong: return false + ((constOutputShape.size() <= outChannelsShapeIndex) || + // Check if all dimensions of scale except the output channels are all ones (shape_size(constOutputShape) != constOutputShape[outChannelsShapeIndex]) || ((constOutputShape[outChannelsShapeIndex] != 1ul) && - (fqFromWeights->get_output_shape(0)[outChannelsShapeIndex] != constOutputShape[outChannelsShapeIndex]))) { + (fqFromWeights->get_output_shape(0)[outChannelsShapeIndex] != constOutputShape[outChannelsShapeIndex])))) { return false; } } else { diff --git a/inference-engine/src/mkldnn_plugin/utils/README.md b/inference-engine/src/mkldnn_plugin/utils/README.md index d3b98f1cb48..bd3f1329a5e 100644 --- a/inference-engine/src/mkldnn_plugin/utils/README.md +++ b/inference-engine/src/mkldnn_plugin/utils/README.md @@ -6,7 +6,7 @@ Use the following cmake option to enable debug capabilities: ## Blob dumping Blob dumping is controlled by environment variables (filters). -The variables define conditions of the node which input, output and internal blobs +The variables define conditions of the node which input and output blobs should be dumped for. > **NOTE**: Nothing is dumped by default @@ -15,11 +15,13 @@ should be dumped for. Environment variables can be set per execution, for example: ```sh - OV_CPU_BLOB_DUMP_DIR=dump_dir binary ... + OV_CPU_BLOB_DUMP_DIR=dump_dir OV_CPU_BLOB_DUMP_FORMAT=TEXT OV_CPU_BLOB_DUMP_NODE_PORTS=OUT binary ... ``` or for shell session (bash example): ```sh export OV_CPU_BLOB_DUMP_DIR=dump_dir + export OV_CPU_BLOB_DUMP_FORMAT=TEXT + export OV_CPU_BLOB_DUMP_NODE_PORTS=OUT binary ... ``` ### Specify dump directory @@ -35,8 +37,22 @@ Options are: * BIN (default) * TEXT +### Filter input / output blobs +To dump only input / output blobs: +```sh + OV_CPU_BLOB_DUMP_NODE_PORTS='' binary ... +``` +Example: +```sh + OV_CPU_BLOB_DUMP_NODE_PORTS=OUT binary ... +``` +Options are: +* IN +* OUT +* ALL + ### Filter by execution ID -To dump blobs only for node with specified execution IDs: +To dump blobs only for nodes with specified execution IDs: ```sh OV_CPU_BLOB_DUMP_NODE_EXEC_ID='' binary ... ``` @@ -46,19 +62,19 @@ Example: ``` ### Filter by type -To dump blobs only for node with specified type: +To dump blobs only for nodes with specified types: ```sh - OV_CPU_BLOB_DUMP_NODE_TYPE= binary ... + OV_CPU_BLOB_DUMP_NODE_TYPE= binary ... ``` Example: ```sh - OV_CPU_BLOB_DUMP_NODE_TYPE=Convolution binary ... + OV_CPU_BLOB_DUMP_NODE_TYPE='Convolution Reorder' binary ... ``` > **NOTE**: see **enum Type** in [mkldnn_node.h](../mkldnn_node.h) for list of the types ### Filter by name -To dump blobs only for node with name matching specified regex: +To dump blobs only for nodes with name matching specified regex: ```sh OV_CPU_BLOB_DUMP_NODE_NAME= binary ... ``` @@ -68,9 +84,17 @@ Example: ``` ### Dump all the blobs +```sh + OV_CPU_BLOB_DUMP_NODE_NAME="*" binary ... +``` + or ```sh OV_CPU_BLOB_DUMP_NODE_NAME=".+" binary ... ``` + or +```sh + OV_CPU_BLOB_DUMP_NODE_PORTS=ALL binary ... +``` ## Graph serialization The functionality allows to serialize execution graph using environment variable: diff --git a/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h b/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h index be6e7a830c2..c2784f8a467 100644 --- a/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h +++ b/inference-engine/src/mkldnn_plugin/utils/debug_capabilities.h @@ -20,6 +20,7 @@ public: readParam(blobDumpDir, "OV_CPU_BLOB_DUMP_DIR"); readParam(blobDumpFormat, "OV_CPU_BLOB_DUMP_FORMAT"); readParam(blobDumpNodeExecId, "OV_CPU_BLOB_DUMP_NODE_EXEC_ID"); + readParam(blobDumpNodePorts, "OV_CPU_BLOB_DUMP_NODE_PORTS"); readParam(blobDumpNodeType, "OV_CPU_BLOB_DUMP_NODE_TYPE"); readParam(blobDumpNodeName, "OV_CPU_BLOB_DUMP_NODE_NAME"); readParam(execGraphPath, "OV_CPU_EXEC_GRAPH_PATH"); @@ -28,6 +29,7 @@ public: std::string blobDumpDir; std::string blobDumpFormat; std::string blobDumpNodeExecId; + std::string blobDumpNodePorts; std::string blobDumpNodeType; std::string blobDumpNodeName; std::string execGraphPath; diff --git a/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp b/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp index 9f3af44a66a..1cfbae1ab5f 100644 --- a/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp +++ b/inference-engine/src/mkldnn_plugin/utils/node_dumper.cpp @@ -20,7 +20,7 @@ using namespace InferenceEngine; namespace MKLDNNPlugin { NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) - : dumpFormat(DUMP_FORMAT::BIN) + : dumpFormat(FORMAT::BIN) , dumpDirName("mkldnn_dump") , count(_count) { if (!config.blobDumpDir.empty()) @@ -32,6 +32,9 @@ NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) if (!config.blobDumpNodeExecId.empty()) dumpFilters[FILTER::BY_EXEC_ID] = config.blobDumpNodeExecId; + if (!config.blobDumpNodePorts.empty()) + dumpFilters[FILTER::BY_PORTS] = config.blobDumpNodePorts; + if (!config.blobDumpNodeType.empty()) dumpFilters[FILTER::BY_TYPE] = config.blobDumpNodeType; @@ -40,7 +43,7 @@ NodeDumper::NodeDumper(const DebugCaps::Config& config, const int _count) } void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { - if (!shouldBeDumped(node)) + if (!shouldBeDumped(node, "IN")) return; auto exec_order = std::to_string(node->getExecIndex()); @@ -60,7 +63,7 @@ void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { file_name = file_name.substr(file_name.size() - 240); auto dump_file = dumpDirName + "/#" + exec_order + "_" + file_name; - std::cout << "Dump before: " << dump_file << std::endl; + std::cout << "Dump inputs: " << dump_file << std::endl; TensorDesc desc = prEdge->getDesc(); if (desc.getPrecision() == Precision::BIN) @@ -77,7 +80,7 @@ void NodeDumper::dumpInputBlobs(const MKLDNNNodePtr& node) const { } void NodeDumper::dumpOutputBlobs(const MKLDNNNodePtr& node) const { - if (!shouldBeDumped(node)) + if (!shouldBeDumped(node, "OUT")) return; auto exec_order = std::to_string(node->getExecIndex()); @@ -96,7 +99,7 @@ void NodeDumper::dumpOutputBlobs(const MKLDNNNodePtr& node) const { file_name = file_name.substr(file_name.size() - 240); auto dump_file = dumpDirName + "/#" + exec_order + "_" + file_name; - std::cout << "Dump after: " << dump_file << std::endl; + std::cout << "Dump outputs: " << dump_file << std::endl; TensorDesc desc = childEdge->getDesc(); if (desc.getPrecision() == Precision::BIN) @@ -130,56 +133,77 @@ void NodeDumper::dumpInternalBlobs(const MKLDNNNodePtr& node) const { void NodeDumper::dump(const BlobDumper& bd, const std::string& file) const { switch (dumpFormat) { - case DUMP_FORMAT::BIN: { + case FORMAT::BIN: { bd.dump(file); break; } - case DUMP_FORMAT::TEXT: { + case FORMAT::TEXT: { bd.dumpAsTxt(file); break; } default: - IE_THROW() << "Unknown dump format"; + IE_THROW() << "NodeDumper: Unknown dump format"; } } -bool NodeDumper::shouldBeDumped(const MKLDNNNodePtr& node) const { +bool NodeDumper::shouldBeDumped(const MKLDNNNodePtr& node, const std::string& portsKind) const { if (dumpFilters.empty()) return false; - if (dumpFilters.count(FILTER::BY_EXEC_ID)) { // filter by exec id env set + if (dumpFilters.count(FILTER::BY_PORTS)) { // filter by ports configured + if (dumpFilters.at(FILTER::BY_PORTS) != "ALL" && + portsKind != dumpFilters.at(FILTER::BY_PORTS)) + return false; + } + + if (dumpFilters.count(FILTER::BY_EXEC_ID)) { // filter by exec id configured std::stringstream ss(dumpFilters.at(FILTER::BY_EXEC_ID)); int id; bool matched = false; + while (ss >> id) { - if (node->getExecIndex() == id) // exec id matches + if (node->getExecIndex() == id) {// exec id matches matched = true; + break; + } } if (!matched) return false; } - if (dumpFilters.count(FILTER::BY_TYPE)) { // filter by type env set - if (NameFromType(node->getType()) != dumpFilters.at(FILTER::BY_TYPE)) // type does not match + if (dumpFilters.count(FILTER::BY_TYPE)) { // filter by type configured + std::stringstream ss(dumpFilters.at(FILTER::BY_TYPE)); + std::string type; + bool matched = false; + + while (ss >> type) { + if (NameFromType(node->getType()) == type) {// type does not match + matched = true; + break; + } + } + + if (!matched) return false; } - if (dumpFilters.count(FILTER::BY_NAME)) { // filter by name env set - if (!std::regex_match(node->getName(), std::regex(dumpFilters.at(FILTER::BY_NAME)))) // name does not match + if (dumpFilters.count(FILTER::BY_NAME)) { // filter by name configured + if (dumpFilters.at(FILTER::BY_NAME) != "*" && // to have 'single char' option for matching all the names + !std::regex_match(node->getName(), std::regex(dumpFilters.at(FILTER::BY_NAME)))) // name does not match return false; } return true; } -NodeDumper::DUMP_FORMAT NodeDumper::parseDumpFormat(const std::string& format) const { +NodeDumper::FORMAT NodeDumper::parseDumpFormat(const std::string& format) const { if (format == "BIN") - return DUMP_FORMAT::BIN; + return FORMAT::BIN; else if (format == "TEXT") - return DUMP_FORMAT::TEXT; + return FORMAT::TEXT; else - IE_THROW() << "Unknown dump format"; + IE_THROW() << "NodeDumper: Unknown dump format"; } void NodeDumper::formatNodeName(std::string& name) const { diff --git a/inference-engine/src/mkldnn_plugin/utils/node_dumper.h b/inference-engine/src/mkldnn_plugin/utils/node_dumper.h index 0580bee4731..bac237c8883 100644 --- a/inference-engine/src/mkldnn_plugin/utils/node_dumper.h +++ b/inference-engine/src/mkldnn_plugin/utils/node_dumper.h @@ -31,28 +31,29 @@ public: private: void dumpInternalBlobs(const MKLDNNNodePtr& node) const; void dump(const BlobDumper& bd, const std::string& file) const; - bool shouldBeDumped(const MKLDNNNodePtr &node) const; + bool shouldBeDumped(const MKLDNNNodePtr &node, const std::string& portsKind) const; - enum class DUMP_FORMAT { + enum class FORMAT { BIN, TEXT, }; - DUMP_FORMAT parseDumpFormat(const std::string& format) const; + FORMAT parseDumpFormat(const std::string& format) const; void formatNodeName(std::string& name) const; - DUMP_FORMAT dumpFormat; + FORMAT dumpFormat; std::string dumpDirName; int count; enum FILTER { + BY_PORTS, BY_EXEC_ID, BY_TYPE, BY_NAME, - COUNT, }; - std::unordered_map dumpFilters; + // std::hash is necessary for Ubuntu-16.04 (gcc-5.4 and defect in C++11 standart) + std::unordered_map> dumpFilters; }; } // namespace MKLDNNPlugin #endif // CPU_DEBUG_CAPS diff --git a/inference-engine/src/offline_transformations/include/mask_attribute.hpp b/inference-engine/src/offline_transformations/include/mask_attribute.hpp index 48c5b4ee9f0..282f81b054e 100644 --- a/inference-engine/src/offline_transformations/include/mask_attribute.hpp +++ b/inference-engine/src/offline_transformations/include/mask_attribute.hpp @@ -96,7 +96,8 @@ public: auto mask_2_iter = mask->rbegin(); while (mask_1_iter != rend() && - mask_2_iter != mask->rend()) { + mask_2_iter != mask->rend() && + result_iter != result_mask->rend()) { // Merge mask dimension values for both masks // Example: (MaskValue[1,2,3,4], MaskValue[2,3]) -> MaskValue[2,3] for (const auto & value : *mask_1_iter) { @@ -119,7 +120,8 @@ public: auto mask_2_iter = mask->rbegin(); while (mask_1_iter != rend() && - mask_2_iter != mask->rend()) { + mask_2_iter != mask->rend() && + result_iter != result_mask->rend()) { // Union mask dimension values for both masks // Example: (MaskValue[1,2,3,4], MaskValue[2, 5]) -> MaskValue[1, 2, 3, 4, 5] for (const auto & value : *mask_1_iter) { diff --git a/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp b/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp index 424b6ae9583..271b200f31b 100644 --- a/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp +++ b/inference-engine/src/offline_transformations/src/pruning/propagate_masks.cpp @@ -246,6 +246,9 @@ public: // To allow pruning on weights (allow reshape input Group (0) dim changing) replace Reshape Shape constant // [G, 1, 1, X, Y, Z] by [-1, 1, 1, X, Y, Z]. auto old_shape_const = std::dynamic_pointer_cast(m_shape.get_node_shared_ptr()); + if (!old_shape_const) { + return false; + } auto shape_value = old_shape_const.get()->cast_vector(); shape_value[0] = -1; auto new_const = opset6::Constant::create(old_shape_const->get_element_type(), @@ -462,6 +465,9 @@ public: const auto & pattern_map = m.get_pattern_value_map(); const auto & m_output = pattern_map.at(concat); auto concat_ptr = std::dynamic_pointer_cast(m_output.get_node_shared_ptr()); + if (!concat_ptr) { + return false; + } auto axis = concat_ptr->get_concatenation_axis(); auto inputs = concat_ptr->inputs(); diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp index f92fd556f00..d34af53631a 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp @@ -50,14 +50,6 @@ public: */ virtual Blob::CPtr GetState() const; - /** - * @deprecated Use IVariableStateInternal::GetState method instead - * @brief Returns the value of the variable state. - * @return The value of the variable state - */ - INFERENCE_ENGINE_DEPRECATED("Use IVariableStateInternal::GetState method instead") - virtual Blob::CPtr GetLastState() const; - protected: /** * @brief A default dtor diff --git a/inference-engine/src/plugin_api/debug.h b/inference-engine/src/plugin_api/debug.h index 838c5b02941..d52c7b0b942 100644 --- a/inference-engine/src/plugin_api/debug.h +++ b/inference-engine/src/plugin_api/debug.h @@ -25,6 +25,9 @@ #include "ie_algorithm.hpp" +namespace InferenceEngine { +namespace details { + /** * @brief Serializes a `std::vector` to a `std::ostream` * @ingroup ie_dev_api_error_debug @@ -32,7 +35,6 @@ * @param vec A vector to serialize * @return A reference to a `std::stream` */ -namespace std { template inline std::ostream& operator<<(std::ostream& out, const std::vector& vec) { if (vec.empty()) return std::operator<<(out, "[]"); @@ -42,10 +44,7 @@ inline std::ostream& operator<<(std::ostream& out, const std::vector& vec) { } return out << "]"; } -} // namespace std -namespace InferenceEngine { -namespace details { /** * @brief trim from start (in place) * @ingroup ie_dev_api_error_debug diff --git a/inference-engine/src/vpu/common/include/vpu/configuration.hpp b/inference-engine/src/vpu/common/include/vpu/configuration.hpp new file mode 100644 index 00000000000..4ed6f77b91f --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration.hpp @@ -0,0 +1,99 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "caseless.hpp" + +#include "vpu/utils/optional.hpp" + +namespace vpu { + +struct CompilationConfig { + int numSHAVEs = -1; + int numCMXSlices = -1; + int numExecutors = -1; + int tilingCMXLimitKB = -1; + + bool hwOptimization = true; + bool hwExtraSplit = false; + + std::string irWithVpuScalesDir; + + std::string customLayers; + + bool detectBatch = true; + + Optional injectSwOps; + Optional packDataInCmx; + bool mergeHwPoolToConv = true; + bool hwDilation = false; + bool forceDeprecatedCnnConversion = false; + bool enableEarlyEltwiseReLUFusion = true; + + std::map> ioStrides; + + // + // Debug options + // + + InferenceEngine::details::caseless_set hwWhiteList; + InferenceEngine::details::caseless_set hwBlackList; + + bool hwDisabled(const std::string& layerName) const { + if (!hwWhiteList.empty()) { + return hwWhiteList.count(layerName) == 0; + } + + if (!hwBlackList.empty()) { + return hwBlackList.count(layerName) != 0; + } + + return false; + } + + InferenceEngine::details::caseless_set noneLayers; + + bool skipAllLayers() const { + if (noneLayers.size() == 1) { + const auto& val = *noneLayers.begin(); + return val == "*"; + } + return false; + } + + bool skipLayerType(const std::string& layerType) const { + return noneLayers.count(layerType) != 0; + } + bool ignoreUnknownLayers = false; + + std::string dumpInternalGraphFileName; + std::string dumpInternalGraphDirectory; + bool dumpAllPasses; + + bool disableReorder = false; // TODO: rename to enableReorder and switch logic. + bool disableConvertStages = false; + bool enablePermuteMerging = true; + bool enableReplWithSCRelu = false; + bool enableReplaceWithReduceMean = true; + bool enableTensorIteratorUnrolling = false; + bool forcePureTensorIterator = false; + bool enableMemoryTypesAnnotation = false; + bool enableWeightsAnalysis = true; + bool checkPreprocessingInsideModel = true; + bool enableCustomReshapeParam = false; + + // + // Deprecated options + // + + float inputScale = 1.0f; + float inputBias = 0.0f; +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp new file mode 100644 index 00000000000..4d480461ec7 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/as_parameter_enabler.hpp @@ -0,0 +1,18 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "ie_parameter.hpp" + +template +struct AsParsedParameterEnabler { + static InferenceEngine::Parameter asParameter(const std::string& value) { return {OptionConcept::parse(value)}; } +}; + +struct AsParameterEnabler { + static InferenceEngine::Parameter asParameter(const std::string& value); +}; diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp new file mode 100644 index 00000000000..5777774fdf4 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/options/copy_optimization.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "vpu/configuration/as_parameter_enabler.hpp" + +namespace vpu { + +namespace details { + +enum class Access; +enum class Category; + +} // namespace details + +class PluginConfiguration; + +struct CopyOptimizationOption : public AsParsedParameterEnabler { + using value_type = bool; + + static std::string key(); + static void validate(const std::string&); + static void validate(const PluginConfiguration&); + static std::string defaultValue(); + static value_type parse(const std::string&); + static details::Access access(); + static details::Category category(); +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp new file mode 100644 index 00000000000..48ced0d2fbb --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/options/log_level.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "vpu/configuration/as_parameter_enabler.hpp" + +namespace vpu { + +enum class LogLevel; + +namespace details { + +enum class Access; +enum class Category; + +} // namespace details + +class PluginConfiguration; + +struct LogLevelOption : public AsParameterEnabler { + using value_type = LogLevel; + + static std::string key(); + static void validate(const std::string&); + static void validate(const PluginConfiguration&); + static std::string defaultValue(); + static value_type parse(const std::string&); + static details::Access access(); + static details::Category category(); +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp new file mode 100644 index 00000000000..ced07f36477 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/plugin_configuration.hpp @@ -0,0 +1,142 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "ie_parameter.hpp" + +#include "vpu/utils/logger.hpp" + +namespace vpu { + +class PluginConfiguration; + +struct ConfigurationOptionConcept { + virtual std::string key() const = 0; + virtual void validate(const std::string&) const = 0; + virtual void validate(const PluginConfiguration&) const = 0; + virtual InferenceEngine::Parameter asParameter(const std::string&) const = 0; +}; + +namespace details { + +template +struct ConfigurationOptionModel : public ConfigurationOptionConcept { + std::string key() const override { return Option::key(); } + void validate(const std::string& value) const override { return Option::validate(value); } + void validate(const PluginConfiguration& options) const override { Option::validate(options); } + InferenceEngine::Parameter asParameter(const std::string& value) const override { return Option::asParameter(value); } +}; + +enum class Deprecation { + Off, + On +}; + +enum class Access { + Private, + Public +}; + +enum class Category { + CompileTime, + RunTime +}; + +class ConfigurationEntry { +public: + template + ConfigurationEntry(Option, details::Deprecation deprecation) + : m_access(Option::access()) + , m_deprecation(deprecation) + , m_category(Option::category()) + , m_value(std::make_shared>()) + {} + + ConfigurationOptionConcept& get(); + const ConfigurationOptionConcept& get() const; + + std::string key() const; + bool isPrivate() const; + bool isDeprecated() const; + Category getCategory() const; + +private: + Access m_access = Access::Public; + Deprecation m_deprecation = Deprecation::Off; + Category m_category = Category::CompileTime; + std::shared_ptr m_value; +}; + +} // namespace details + +// TODO: remove virtual inheritance once all options are migrated +// it's needed to pass updated compilation config to graph transformer +class PluginConfiguration : public virtual ParsedConfig { +public: + PluginConfiguration(); + + void from(const std::map& config); + void fromAtRuntime(const std::map& config); + std::unordered_set getPublicKeys() const; + bool supports(const std::string& key) const; + + template + void registerOption() { + const auto& key = Option::key(); + concepts.emplace(key, details::ConfigurationEntry(Option{}, details::Deprecation::Off)); + if (values.count(key) == 0) { + // option could be registered more than once if there are deprecated versions of it + values.emplace(key, Option::defaultValue()); + } + } + + template + void registerDeprecatedOption(const std::string& deprecatedKey) { + const auto& key = Option::key(); + concepts.emplace(deprecatedKey, details::ConfigurationEntry(Option{}, details::Deprecation::On)); + if (values.count(key) == 0) { + // option could be registered more than once if there are deprecated versions of it + values.emplace(key, Option::defaultValue()); + } + } + + template + typename Option::value_type get() const { + const auto& key = Option::key(); + validate(key); + return Option::parse(values.at(key)); + } + + void set(const std::string& key, const std::string& value); + + const std::string& operator[](const std::string& key) const; + + InferenceEngine::Parameter asParameter(const std::string& key) const; + + virtual void validate() const; + +private: + std::unordered_map concepts; + std::unordered_map values; + + Logger::Ptr logger; + + enum class Mode { + Default, + RunTime + }; + void create(const std::map& config, Mode mode = Mode::Default); + + void validate(const std::string& key) const; +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp b/inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp new file mode 100644 index 00000000000..0348286871a --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/configuration/switch_converters.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace vpu { + +const std::unordered_map& string2switch(); +const std::unordered_map& switch2string(); + +} // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/parsed_config.hpp b/inference-engine/src/vpu/common/include/vpu/parsed_config.hpp similarity index 80% rename from inference-engine/src/vpu/graph_transformer/include/vpu/parsed_config.hpp rename to inference-engine/src/vpu/common/include/vpu/parsed_config.hpp index d220cda3c3b..aa1793806e9 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/parsed_config.hpp +++ b/inference-engine/src/vpu/common/include/vpu/parsed_config.hpp @@ -10,11 +10,11 @@ #include #include +#include #include #include -#include #include #include #include @@ -23,6 +23,12 @@ namespace vpu { class ParsedConfig : public ParsedConfigBase { public: + ParsedConfig() = default; + ParsedConfig(const ParsedConfig&) = default; + ParsedConfig& operator=(const ParsedConfig&) = default; + ParsedConfig(ParsedConfig&&) = delete; + ParsedConfig& operator=(ParsedConfig&&) = delete; + const std::string& compilerLogFilePath() const { return _compilerLogFilePath; } @@ -31,6 +37,10 @@ public: return _compileConfig; } + CompilationConfig& compileConfig() { + return _compileConfig; + } + bool printReceiveTensorTime() const { return _printReceiveTensorTime; } diff --git a/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp b/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp index 6c7e776461d..fc57ea8ed24 100644 --- a/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp +++ b/inference-engine/src/vpu/common/include/vpu/parsed_config_base.hpp @@ -25,10 +25,6 @@ VPU_DECLARE_ENUM(ConfigMode, class ParsedConfigBase { public: - LogLevel logLevel() const { - return _logLevel; - } - bool exclusiveAsyncRequests() const { return _exclusiveAsyncRequests; } @@ -37,11 +33,9 @@ public: ParsedConfigBase(); virtual ~ParsedConfigBase(); - void update( - const std::map& config, - ConfigMode mode = ConfigMode::Any); - protected: + void update(const std::map& config, ConfigMode mode = ConfigMode::Any); + virtual const std::unordered_set& getCompileOptions() const; virtual const std::unordered_set& getRunTimeOptions() const; virtual const std::unordered_set& getDeprecatedOptions() const; @@ -130,7 +124,6 @@ protected: Logger::Ptr _log; private: - LogLevel _logLevel = LogLevel::None; bool _exclusiveAsyncRequests = false; }; diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp b/inference-engine/src/vpu/common/include/vpu/private_plugin_config.hpp similarity index 100% rename from inference-engine/src/vpu/graph_transformer/include/vpu/private_plugin_config.hpp rename to inference-engine/src/vpu/common/include/vpu/private_plugin_config.hpp diff --git a/inference-engine/src/vpu/common/include/vpu/utils/containers.hpp b/inference-engine/src/vpu/common/include/vpu/utils/containers.hpp new file mode 100644 index 00000000000..745613c977e --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/utils/containers.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "error.hpp" + +namespace vpu { + +template class Map> +inline std::vector getKeys(const Map& map) { + auto keys = std::vector{}; + keys.reserve(map.size()); + std::transform(map.cbegin(), map.cend(), std::back_inserter(keys), [](const std::pair& entry) { return entry.first; }); + return keys; +} + +template class Map> +inline std::vector getValues(const Map& map) { + auto values = std::vector{}; + values.reserve(map.size()); + std::transform(map.cbegin(), map.cend(), std::back_inserter(values), [](const std::pair& entry) { return entry.second; }); + return values; +} + +template class Map> +inline Map inverse(const Map& map) { + auto inverted = Map{}; + for (const auto& entry : map) { + const auto& insertion = inverted.emplace(entry.second, entry.first); + VPU_THROW_UNLESS(insertion.second, "Could not invert map {} due to duplicated value \"{}\"", map, entry.second); + } + return inverted; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/utils/error.hpp b/inference-engine/src/vpu/common/include/vpu/utils/error.hpp index 2180e6c86c0..1c36e1f7dd4 100644 --- a/inference-engine/src/vpu/common/include/vpu/utils/error.hpp +++ b/inference-engine/src/vpu/common/include/vpu/utils/error.hpp @@ -29,6 +29,11 @@ public: using VPUException::VPUException; }; +class UnsupportedConfigurationOptionException : public VPUException { +public: + using VPUException::VPUException; +}; + template void throwFormat(const char* fileName, int lineNumber, const char* messageFormat, Args&&... args) { IE_THROW(GeneralError) << '\n' << fileName << ':' << lineNumber << ' ' @@ -47,13 +52,20 @@ void throwFormat(const char* fileName, int lineNumber, const char* messageFormat } \ } while (false) -#define VPU_THROW_UNSUPPORTED_UNLESS(condition, ...) \ +#define VPU_THROW_UNSUPPORTED_LAYER_UNLESS(condition, ...) \ do { \ if (!(condition)) { \ ::vpu::details::throwFormat<::vpu::details::UnsupportedLayerException>(__FILE__, __LINE__, __VA_ARGS__); \ } \ } while (false) +#define VPU_THROW_UNSUPPORTED_OPTION_UNLESS(condition, ...) \ + do { \ + if (!(condition)) { \ + ::vpu::details::throwFormat<::vpu::details::UnsupportedConfigurationOptionException>(__FILE__, __LINE__, __VA_ARGS__); \ + } \ + } while (false) + #ifdef NDEBUG # define VPU_INTERNAL_CHECK(condition, ...) \ do { \ diff --git a/inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp b/inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp new file mode 100644 index 00000000000..51eb7531508 --- /dev/null +++ b/inference-engine/src/vpu/common/include/vpu/utils/log_level.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "vpu/utils/enums.hpp" + +namespace vpu { + +VPU_DECLARE_ENUM(LogLevel, + None, + Fatal, /* used for very severe error events that will most probably cause the application to terminate */ + Error, /* reporting events which are not expected during normal execution, containing probable reason */ + Warning, /* indicating events which are not usual and might lead to errors later */ + Info, /* short enough messages about ongoing activity in the process */ + Debug, /* more fine-grained messages with references to particular data and explanations */ + Trace /* involved and detailed information about execution, helps to trace the execution flow, produces huge output */ +) + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp b/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp index de06c8511ad..931d02a1648 100644 --- a/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp +++ b/inference-engine/src/vpu/common/include/vpu/utils/logger.hpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace vpu { @@ -39,20 +40,6 @@ OutputStream::Ptr fileOutput(const std::string& fileName); OutputStream::Ptr defaultOutput(const std::string& fileName = std::string()); -// -// Logger -// - -VPU_DECLARE_ENUM(LogLevel, - None, - Fatal, /* used for very severe error events that will most probably cause the application to terminate */ - Error, /* reporting events which are not expected during normal execution, containing probable reason */ - Warning, /* indicating events which are not usual and might lead to errors later */ - Info, /* short enough messages about ongoing activity in the process */ - Debug, /* more fine-grained messages with references to particular data and explanations */ - Trace /* involved and detailed information about execution, helps to trace the execution flow, produces huge output */ -) - class Logger final { public: using Ptr = std::shared_ptr; diff --git a/inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp b/inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp new file mode 100644 index 00000000000..04c9d525971 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/as_parameter_enabler.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +InferenceEngine::Parameter AsParameterEnabler::asParameter(const std::string& value) { + return {value}; +} + diff --git a/inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp b/inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp new file mode 100644 index 00000000000..7fc384aac01 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/options/copy_optimization.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/private_plugin_config.hpp" +#include "vpu/utils/containers.hpp" +#include "vpu/configuration/options/copy_optimization.hpp" +#include "vpu/configuration/switch_converters.hpp" +#include "vpu/configuration/plugin_configuration.hpp" + +namespace vpu { + +void CopyOptimizationOption::validate(const std::string& value) { + const auto& converters = string2switch(); + VPU_THROW_UNLESS(converters.count(value) != 0, R"(unexpected copy optimization option value "{}", only {} are supported)", value, getKeys(converters)); +} + +void CopyOptimizationOption::validate(const PluginConfiguration& configuration) { + validate(configuration[key()]); +} + +std::string CopyOptimizationOption::key() { + return InferenceEngine::MYRIAD_COPY_OPTIMIZATION; +} + +details::Access CopyOptimizationOption::access() { + return details::Access::Private; +} + +details::Category CopyOptimizationOption::category() { + return details::Category::CompileTime; +} + +std::string CopyOptimizationOption::defaultValue() { + return InferenceEngine::PluginConfigParams::YES; +} + +CopyOptimizationOption::value_type CopyOptimizationOption::parse(const std::string& value) { + const auto& converters = string2switch(); + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(converters.count(value) != 0, R"(unexpected copy optimization option value "{}", only {} are supported)", + value, getKeys(converters)); + return converters.at(value); +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/src/configuration/options/log_level.cpp b/inference-engine/src/vpu/common/src/configuration/options/log_level.cpp new file mode 100644 index 00000000000..79729aebfef --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/options/log_level.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/configuration/options/log_level.hpp" +#include "vpu/utils/log_level.hpp" +#include "vpu/utils/containers.hpp" +#include "vpu/configuration/plugin_configuration.hpp" + +#include "ie_plugin_config.hpp" + +#include + +namespace vpu { + +namespace { + +const std::unordered_map& string2level() { + static const std::unordered_map converters = { + {CONFIG_VALUE(LOG_NONE), LogLevel::None}, + {CONFIG_VALUE(LOG_ERROR), LogLevel::Error}, + {CONFIG_VALUE(LOG_WARNING), LogLevel::Warning}, + {CONFIG_VALUE(LOG_INFO), LogLevel::Info}, + {CONFIG_VALUE(LOG_DEBUG), LogLevel::Debug}, + {CONFIG_VALUE(LOG_TRACE), LogLevel::Trace}, + }; + return converters; +} + +} // namespace + +void LogLevelOption::validate(const std::string& value) { + const auto& converters = string2level(); + VPU_THROW_UNLESS(converters.count(value) != 0, R"(unexpected log level option value "{}", only {} are supported)", value, getKeys(converters)); +} + +void LogLevelOption::validate(const PluginConfiguration& configuration) { + validate(configuration[key()]); +} + +std::string LogLevelOption::key() { + return InferenceEngine::PluginConfigParams::KEY_LOG_LEVEL; +} + +details::Access LogLevelOption::access() { + return details::Access::Public; +} + +details::Category LogLevelOption::category() { + return details::Category::CompileTime; +} + +std::string LogLevelOption::defaultValue() { + return InferenceEngine::PluginConfigParams::LOG_NONE; +} + +LogLevelOption::value_type LogLevelOption::parse(const std::string& value) { + const auto& converters = string2level(); + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(converters.count(value) != 0, R"(unexpected log level option value "{}", only {} are supported)", + value, getKeys(converters)); + return converters.at(value); +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp b/inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp new file mode 100644 index 00000000000..6e051606c67 --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/plugin_configuration.cpp @@ -0,0 +1,114 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/utils/error.hpp" +#include "vpu/configuration/plugin_configuration.hpp" + +#include "ie_plugin_config.hpp" + +namespace vpu { + +namespace details { + +ConfigurationOptionConcept& ConfigurationEntry::get() { + return *m_value; +} + +const ConfigurationOptionConcept& ConfigurationEntry::get() const { + return *m_value; +} + +bool ConfigurationEntry::isPrivate() const { + return m_access == Access::Private; +} + +bool ConfigurationEntry::isDeprecated() const { + return m_deprecation == Deprecation::On; +} + +Category ConfigurationEntry::getCategory() const { + return m_category; +} + +std::string ConfigurationEntry::key() const { + return m_value->key(); +} + +} // namespace details + +PluginConfiguration::PluginConfiguration() : logger(std::make_shared("Configuration", LogLevel::Warning, consoleOutput())) {} + + +std::unordered_set PluginConfiguration::getPublicKeys() const { + auto publicKeys = std::unordered_set{}; + for (const auto& entry : concepts) { + const auto& key = entry.first; + const auto& option = entry.second; + if (option.isPrivate()) { + continue; + } + publicKeys.insert(key); + } + return publicKeys; +} + +bool PluginConfiguration::supports(const std::string& key) const { + return concepts.count(key) != 0; +} + +void PluginConfiguration::from(const std::map& config) { + create(config); +} + +void PluginConfiguration::fromAtRuntime(const std::map& config) { + create(config, Mode::RunTime); +} + +void PluginConfiguration::validate() const { + for (const auto& option : concepts) { + option.second.get().validate(*this); + } +} + +void PluginConfiguration::create(const std::map& config, Mode mode) { + for (const auto& entry : config) { + const auto& key = entry.first; + validate(key); + + const auto& optionConcept = concepts.at(key); + if (mode == Mode::RunTime && optionConcept.getCategory() == details::Category::CompileTime) { + logger->warning("Configuration option \"{}\" is used after network is loaded. Its value is going to be ignored.", key); + continue; + } + + const auto& value = entry.second; + set(key, value); + } +} + +InferenceEngine::Parameter PluginConfiguration::asParameter(const std::string& key) const { + const auto& value = operator[](key); + return concepts.at(key).get().asParameter(value); +} + +void PluginConfiguration::validate(const std::string& key) const { + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(supports(key), "Encountered an unsupported key {}, supported keys are {}", key, getPublicKeys()); + if (concepts.at(key).isDeprecated()) { + logger->warning("Encountered deprecated option {} usage, consider replacing it with {} option", key, concepts.at(key).key()); + } +} + +const std::string& PluginConfiguration::operator[](const std::string& key) const { + validate(key); + return values.at(concepts.at(key).key()); +} + +void PluginConfiguration::set(const std::string& key, const std::string& value) { + validate(key); + const auto& optionConcept = concepts.at(key).get(); + optionConcept.validate(value); + values[optionConcept.key()] = value; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/common/src/configuration/switch_converters.cpp b/inference-engine/src/vpu/common/src/configuration/switch_converters.cpp new file mode 100644 index 00000000000..232b184cf8d --- /dev/null +++ b/inference-engine/src/vpu/common/src/configuration/switch_converters.cpp @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "vpu/utils/containers.hpp" +#include "vpu/configuration/switch_converters.hpp" + +#include "ie_plugin_config.hpp" + +namespace vpu { + +const std::unordered_map& string2switch() { + static const std::unordered_map converters = { + {CONFIG_VALUE(NO), false}, + {CONFIG_VALUE(YES), true} + }; + return converters; +} + +const std::unordered_map& switch2string() { + static const auto converters = inverse(string2switch()); + return converters; +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/src/parsed_config.cpp b/inference-engine/src/vpu/common/src/parsed_config.cpp similarity index 99% rename from inference-engine/src/vpu/graph_transformer/src/parsed_config.cpp rename to inference-engine/src/vpu/common/src/parsed_config.cpp index 5e8779a7312..b0a2ec46c93 100644 --- a/inference-engine/src/vpu/graph_transformer/src/parsed_config.cpp +++ b/inference-engine/src/vpu/common/src/parsed_config.cpp @@ -169,7 +169,6 @@ void ParsedConfig::parse(const std::map& config) { setOption(_compileConfig.dumpAllPasses, switches, config, ie::MYRIAD_DUMP_ALL_PASSES); setOption(_compileConfig.detectBatch, switches, config, ie::MYRIAD_DETECT_NETWORK_BATCH); - setOption(_compileConfig.copyOptimization, switches, config, ie::MYRIAD_COPY_OPTIMIZATION); setOption(_compileConfig.packDataInCmx, switches, config, ie::MYRIAD_PACK_DATA_IN_CMX); setOption(_compileConfig.ignoreUnknownLayers, switches, config, ie::MYRIAD_IGNORE_UNKNOWN_LAYERS); setOption(_compileConfig.hwOptimization, switches, config, ie::MYRIAD_ENABLE_HW_ACCELERATION); diff --git a/inference-engine/src/vpu/common/src/parsed_config_base.cpp b/inference-engine/src/vpu/common/src/parsed_config_base.cpp index 876232bd15e..c9e8a36f4a7 100644 --- a/inference-engine/src/vpu/common/src/parsed_config_base.cpp +++ b/inference-engine/src/vpu/common/src/parsed_config_base.cpp @@ -59,13 +59,7 @@ void ParsedConfigBase::update( } const std::unordered_set& ParsedConfigBase::getCompileOptions() const { -IE_SUPPRESS_DEPRECATED_START - static const std::unordered_set options = { - CONFIG_KEY(LOG_LEVEL), - VPU_CONFIG_KEY(LOG_LEVEL) - }; -IE_SUPPRESS_DEPRECATED_END - + static const std::unordered_set options; return options; } @@ -73,8 +67,6 @@ const std::unordered_set& ParsedConfigBase::getRunTimeOptions() con IE_SUPPRESS_DEPRECATED_START static const std::unordered_set options = { CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS), - CONFIG_KEY(LOG_LEVEL), - VPU_CONFIG_KEY(LOG_LEVEL) }; IE_SUPPRESS_DEPRECATED_END @@ -82,37 +74,12 @@ IE_SUPPRESS_DEPRECATED_END } const std::unordered_set& ParsedConfigBase::getDeprecatedOptions() const { - IE_SUPPRESS_DEPRECATED_START - static const std::unordered_set options = { - VPU_CONFIG_KEY(LOG_LEVEL) - }; - IE_SUPPRESS_DEPRECATED_END - + static const std::unordered_set options; return options; } void ParsedConfigBase::parse(const std::map& config) { - static const std::unordered_map logLevels = { - { CONFIG_VALUE(LOG_NONE), LogLevel::None }, - { CONFIG_VALUE(LOG_ERROR), LogLevel::Error }, - { CONFIG_VALUE(LOG_WARNING), LogLevel::Warning }, - { CONFIG_VALUE(LOG_INFO), LogLevel::Info }, - { CONFIG_VALUE(LOG_DEBUG), LogLevel::Debug }, - { CONFIG_VALUE(LOG_TRACE), LogLevel::Trace } - }; - - setOption(_logLevel, logLevels, config, CONFIG_KEY(LOG_LEVEL)); setOption(_exclusiveAsyncRequests, switches, config, CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS)); - -IE_SUPPRESS_DEPRECATED_START - setOption(_logLevel, logLevels, config, VPU_CONFIG_KEY(LOG_LEVEL)); -IE_SUPPRESS_DEPRECATED_END - -#ifndef NDEBUG - if (const auto envVar = std::getenv("IE_VPU_LOG_LEVEL")) { - _logLevel = logLevels.at(envVar); - } -#endif } std::unordered_set ParsedConfigBase::merge( diff --git a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt index bc73ab5b155..1de08e8cae3 100644 --- a/inference-engine/src/vpu/graph_transformer/CMakeLists.txt +++ b/inference-engine/src/vpu/graph_transformer/CMakeLists.txt @@ -48,8 +48,13 @@ function(add_graph_transformer_target TARGET_NAME STATIC_IE) target_link_libraries(${TARGET_NAME} PUBLIC pugixml vpu_common_lib) endif() - target_link_libraries(${TARGET_NAME} PUBLIC ${NGRAPH_LIBRARIES} - PRIVATE openvino::itt) + target_link_libraries(${TARGET_NAME} + PUBLIC + ${NGRAPH_LIBRARIES} + PRIVATE + openvino::itt + mvnc # TODO: remove once all options are migrated + ) if(WIN32) target_compile_definitions(${TARGET_NAME} PRIVATE NOMINMAX) diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp index 157b13a0b59..3228c7e1a4c 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/compile_env.hpp @@ -8,28 +8,29 @@ #include #include #include +#include namespace vpu { struct DeviceResources { - static int numShaves(const Platform& platform); - static int numSlices(const Platform& platform); + static int numShaves(const ncDevicePlatform_t& platform); + static int numSlices(const ncDevicePlatform_t& platform); static int numStreams(); }; struct DefaultAllocation { - static int numStreams(const Platform& platform, const CompilationConfig& configuration); - static int numSlices(const Platform& platform, int numStreams); - static int numShaves(const Platform& platform, int numStreams, int numSlices); + static int numStreams(const ncDevicePlatform_t& platform, const PluginConfiguration& configuration); + static int numSlices(const ncDevicePlatform_t& platform, int numStreams); + static int numShaves(const ncDevicePlatform_t& platform, int numStreams, int numSlices); static int tilingCMXLimit(int numSlices); }; struct CompileEnv final { public: - Platform platform; + ncDevicePlatform_t platform; Resources resources; - CompilationConfig config; + PluginConfiguration config; Logger::Ptr log; @@ -49,14 +50,14 @@ public: static const CompileEnv* getOrNull(); static void init( - Platform platform, - const CompilationConfig& config, - const Logger::Ptr& log); - static void updateConfig(const CompilationConfig& config); + ncDevicePlatform_t platform, + const PluginConfiguration& config, + const Logger::Ptr& log); + static void updateConfig(const PluginConfiguration& config); static void free(); private: - explicit CompileEnv(Platform platform); + explicit CompileEnv(ncDevicePlatform_t platform); }; } // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp index c0881b9b0c6..afe4974502c 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer.hpp @@ -21,108 +21,14 @@ #include #include #include +#include + +#include "mvnc.h" namespace vpu { namespace ie = InferenceEngine; -// -// CompilationConfig -// - -VPU_DECLARE_ENUM(Platform, - MYRIAD_2 = 2450, - MYRIAD_X = 2480, -) - -struct CompilationConfig final { - // - // Compilation options - // - - int numSHAVEs = -1; - int numCMXSlices = -1; - int numExecutors = -1; - int tilingCMXLimitKB = -1; - - bool hwOptimization = true; - bool hwExtraSplit = false; - - std::string irWithVpuScalesDir; - - std::string customLayers; - - bool detectBatch = true; - - Optional copyOptimization; - Optional injectSwOps; - Optional packDataInCmx; - bool mergeHwPoolToConv = true; - bool hwDilation = false; - bool forceDeprecatedCnnConversion = false; - bool enableEarlyEltwiseReLUFusion = true; - - std::map> ioStrides; - - // - // Debug options - // - - ie::details::caseless_set hwWhiteList; - ie::details::caseless_set hwBlackList; - - bool hwDisabled(const std::string& layerName) const { - if (!hwWhiteList.empty()) { - return hwWhiteList.count(layerName) == 0; - } - - if (!hwBlackList.empty()) { - return hwBlackList.count(layerName) != 0; - } - - return false; - } - - ie::details::caseless_set noneLayers; - - bool skipAllLayers() const { - if (noneLayers.size() == 1) { - const auto& val = *noneLayers.begin(); - return val == "*"; - } - return false; - } - - bool skipLayerType(const std::string& layerType) const { - return noneLayers.count(layerType) != 0; - } - bool ignoreUnknownLayers = false; - - std::string dumpInternalGraphFileName; - std::string dumpInternalGraphDirectory; - bool dumpAllPasses; - - bool disableReorder = false; // TODO: rename to enableReorder and switch logic. - bool disableConvertStages = false; - bool enablePermuteMerging = true; - bool enableReplWithSCRelu = false; - bool enableReplaceWithReduceMean = true; - bool enableTensorIteratorUnrolling = false; - bool forcePureTensorIterator = false; - bool enableMemoryTypesAnnotation = false; - bool enableWeightsAnalysis = true; - bool checkPreprocessingInsideModel = true; - bool enableCustomReshapeParam = false; - - // - // Deprecated options - // - - float inputScale = 1.0f; - float inputBias = 0.0f; -}; - - // // DataInfo // @@ -165,17 +71,17 @@ struct CompiledGraph final { // compileNetwork // -CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, Platform platform, const CompilationConfig& config, const Logger::Ptr& log, - const ie::ICore* core); +CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log, + const ie::ICore* core); -CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const CompilationConfig& subConfig, const ie::ICore* core); +CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const PluginConfiguration& subConfig, const ie::ICore* core); // // getSupportedLayers // -std::set getSupportedLayers(const ie::CNNNetwork& network, Platform platform, const CompilationConfig& config, const Logger::Ptr& log, - const ie::ICore* core); +std::set getSupportedLayers(const ie::CNNNetwork& network, ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log, + const ie::ICore* core); // // Blob version and checks diff --git a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp index 141512bd40c..99cddb1be79 100644 --- a/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp +++ b/inference-engine/src/vpu/graph_transformer/include/vpu/graph_transformer_internal.hpp @@ -12,8 +12,8 @@ namespace vpu { CompiledGraph::Ptr compileModel( const Model& model, - Platform platform, - const CompilationConfig& config, + ncDevicePlatform_t platform, + const PluginConfiguration& config, const Logger::Ptr& log); } // namespace vpu diff --git a/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp b/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp index fdb632993b6..27a9d40794e 100644 --- a/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/backend/backend.cpp @@ -85,12 +85,12 @@ void BackEnd::dumpModel( std::string fileName; - if (!env.config.dumpInternalGraphFileName.empty()) { - fileName = fileNameNoExt(env.config.dumpInternalGraphFileName); - } else if (!env.config.dumpInternalGraphDirectory.empty()) { + if (!env.config.compileConfig().dumpInternalGraphFileName.empty()) { + fileName = fileNameNoExt(env.config.compileConfig().dumpInternalGraphFileName); + } else if (!env.config.compileConfig().dumpInternalGraphDirectory.empty()) { fileName = formatString( "%s/vpu_graph_%f%f%i_%s", - env.config.dumpInternalGraphDirectory, + env.config.compileConfig().dumpInternalGraphDirectory, std::setw(2), std::setfill('0'), model->attrs().get("index"), replaceBadCharacters(model->name())); @@ -99,7 +99,7 @@ void BackEnd::dumpModel( } if (!postfix.empty()) { - if (!env.config.dumpAllPasses) { + if (!env.config.compileConfig().dumpAllPasses) { return; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp index 9e3a3f7eab5..48de8bb9f87 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/detect_network_batch.cpp @@ -29,7 +29,7 @@ void FrontEnd::detectNetworkBatch( using PrecisionsMap = std::map; const auto& env = CompileEnv::get(); - if (!env.config.detectBatch) { + if (!env.config.compileConfig().detectBatch) { // skip batch extraction step and go as is return; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp index 5ee49dd4ed2..c399cdc8d2d 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/frontend.cpp @@ -436,7 +436,7 @@ void FrontEnd::processTrivialCases(const Model& model) { void FrontEnd::defaultOnUnsupportedLayerCallback(const Model& model, const ie::CNNLayerPtr& layer, const DataVector& inputs, const DataVector& outputs, const std::string& extraMessage) { const auto& env = CompileEnv::get(); - VPU_THROW_UNSUPPORTED_UNLESS(env.config.ignoreUnknownLayers, "Failed to compile layer \"%v\": %v", layer->name, extraMessage); + VPU_THROW_UNSUPPORTED_LAYER_UNLESS(env.config.compileConfig().ignoreUnknownLayers, "Failed to compile layer \"%v\": %v", layer->name, extraMessage); _stageBuilder->addNoneStage(model, layer->name, layer, inputs, outputs); } @@ -466,15 +466,15 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, // Parse custom layers // - if (!env.config.customLayers.empty()) { - env.log->trace("Parse custom layers : %s", env.config.customLayers); + if (!env.config.compileConfig().customLayers.empty()) { + env.log->trace("Parse custom layers : %s", env.config.compileConfig().customLayers); VPU_LOGGER_SECTION(env.log); - if (env.platform != Platform::MYRIAD_X) { + if (env.platform != ncDevicePlatform_t::NC_MYRIAD_X) { VPU_THROW_FORMAT("Custom layers are not supported for %v platforms", env.platform); } - _customLayers = CustomLayer::loadFromFile(env.config.customLayers); + _customLayers = CustomLayer::loadFromFile(env.config.compileConfig().customLayers); } // @@ -494,7 +494,7 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, env.log->trace("Update IE Network"); VPU_LOGGER_SECTION(env.log); - if (network.getFunction() && env.config.forceDeprecatedCnnConversion) { + if (network.getFunction() && env.config.compileConfig().forceDeprecatedCnnConversion) { network = convertNetwork(network); } @@ -545,7 +545,7 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, processTrivialCases(model); - if (!CompileEnv::get().config.disableConvertStages) { + if (!CompileEnv::get().config.compileConfig().disableConvertStages) { addDataTypeConvertStages(model); } @@ -567,7 +567,7 @@ ModelPtr FrontEnd::runCommonPasses(ie::CNNNetwork network, getInputAndOutputData(model, layer, inputs, outputs); - if (env.config.skipAllLayers() || env.config.skipLayerType(layer->type)) { + if (env.config.compileConfig().skipAllLayers() || env.config.compileConfig().skipLayerType(layer->type)) { _stageBuilder->addNoneStage(model, layer->name, layer, inputs, outputs); supportedLayer(layer); continue; diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp index 6308504cfcc..159bd3430a4 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/in_out_convert.cpp @@ -22,7 +22,7 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { env.log->trace("Add Data type conversion stages"); VPU_LOGGER_SECTION(env.log); - const bool hasScaleBias = env.config.inputScale != 1.0f || env.config.inputBias != 0.0f; + const bool hasScaleBias = env.config.compileConfig().inputScale != 1.0f || env.config.compileConfig().inputBias != 0.0f; for (const auto& input : model->datas()) { if (input->usage() != DataUsage::Input) { @@ -38,11 +38,11 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { env.log->trace("Apply deprecated scale/bias parameters"); std::ostringstream postfix; - if (env.config.inputScale != 1.0f) { - postfix << "@SCALE=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.inputScale); + if (env.config.compileConfig().inputScale != 1.0f) { + postfix << "@SCALE=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.compileConfig().inputScale); } - if (env.config.inputBias != 0.0f) { - postfix << "@BIAS=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.inputBias); + if (env.config.compileConfig().inputBias != 0.0f) { + postfix << "@BIAS=" << InferenceEngine::CNNLayer::ie_serialize_float(env.config.compileConfig().inputBias); } const auto scaledInput = model->duplicateData( @@ -55,9 +55,9 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { model, scaledInput->name(), nullptr, - env.config.inputScale, + env.config.compileConfig().inputScale, 1.0f, - env.config.inputBias, + env.config.compileConfig().inputBias, input, scaledInput); } @@ -89,8 +89,8 @@ void FrontEnd::addDataTypeConvertStages(const Model& model) { inputFP16->name(), input, inputFP16, - env.config.inputScale, - env.config.inputBias); + env.config.compileConfig().inputScale, + env.config.compileConfig().inputBias); break; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp index 00ab7970060..392c0b86df8 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/parse_data.cpp @@ -25,8 +25,8 @@ void FrontEnd::parseInputAndOutputData(const Model& model) { VPU_LOGGER_SECTION(env.log); const auto parseIOStrides = [&env](const std::string& name, const Data& data) { - const auto& match = env.config.ioStrides.find(name); - if (match == env.config.ioStrides.end()) { + const auto& match = env.config.compileConfig().ioStrides.find(name); + if (match == env.config.compileConfig().ioStrides.end()) { return; } diff --git a/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp b/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp index 28386c243a2..34ca4835a92 100644 --- a/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/frontend/unroll_loops.cpp @@ -21,7 +21,7 @@ void FrontEnd::unrollLoops(ie::CNNNetwork& network) { env.log->trace("Unroll TensorIterator loops"); VPU_LOGGER_SECTION(env.log); - if (!env.config.irWithVpuScalesDir.empty()) { + if (!env.config.compileConfig().irWithVpuScalesDir.empty()) { // TODO: Scale dumps does not work with IR, which contain Tensor Iterator layers, because we cannot serialize them. #-23429 for (auto iterator = ie::details::CNNNetworkIterator(network); iterator != ie::details::CNNNetworkIterator(); ++iterator) { const auto& layer = *iterator; @@ -30,11 +30,11 @@ void FrontEnd::unrollLoops(ie::CNNNetwork& network) { } } - if (env.config.forcePureTensorIterator) { + if (env.config.compileConfig().forcePureTensorIterator) { return; } - if (env.config.enableTensorIteratorUnrolling) { + if (env.config.compileConfig().enableTensorIteratorUnrolling) { ie::NetPass::UnrollTI(network); } else { // Try to convert network to a RNN sequence due to performance reasons diff --git a/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp b/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp index 644529866ba..180632e2846 100644 --- a/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/graph_transformer.cpp @@ -42,6 +42,7 @@ #include #include #include +#include namespace vpu { @@ -55,7 +56,7 @@ thread_local CompileEnv* g_compileEnv = nullptr; } // namespace -CompileEnv::CompileEnv(Platform platform) : platform(platform) {} +CompileEnv::CompileEnv(ncDevicePlatform_t platform) : platform(platform) {} const CompileEnv& CompileEnv::get() { IE_ASSERT(g_compileEnv != nullptr); @@ -70,7 +71,7 @@ const CompileEnv* CompileEnv::getOrNull() { return g_compileEnv; } -void CompileEnv::init(Platform platform, const CompilationConfig& config, const Logger::Ptr& log) { +void CompileEnv::init(ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log) { g_compileEnv = new CompileEnv(platform); g_compileEnv->config = config; g_compileEnv->log = log; @@ -79,31 +80,37 @@ void CompileEnv::init(Platform platform, const CompilationConfig& config, const g_compileEnv->profile.setLogger(log); #endif - if (platform == Platform::MYRIAD_2) { - g_compileEnv->config.hwOptimization = false; + if (platform == ncDevicePlatform_t::NC_MYRIAD_2) { + g_compileEnv->config.compileConfig().hwOptimization = false; } - VPU_THROW_UNLESS(g_compileEnv->config.numSHAVEs <= g_compileEnv->config.numCMXSlices, + VPU_THROW_UNLESS(g_compileEnv->config.compileConfig().numSHAVEs <= g_compileEnv->config.compileConfig().numCMXSlices, R"(Value of configuration option ("{}") must be not greater than value of configuration option ("{}"), but {} > {} are provided)", - ie::MYRIAD_NUMBER_OF_SHAVES, ie::MYRIAD_NUMBER_OF_CMX_SLICES, config.numSHAVEs, config.numCMXSlices); + ie::MYRIAD_NUMBER_OF_SHAVES, ie::MYRIAD_NUMBER_OF_CMX_SLICES, config.compileConfig().numSHAVEs, config.compileConfig().numCMXSlices); - const auto numExecutors = config.numExecutors != -1 ? config.numExecutors : DefaultAllocation::numStreams(platform, config); + const auto numExecutors = config.compileConfig().numExecutors != -1 ? config.compileConfig().numExecutors : DefaultAllocation::numStreams(platform, config); VPU_THROW_UNLESS(numExecutors >= 1 && numExecutors <= DeviceResources::numStreams(), R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")", ie::MYRIAD_THROUGHPUT_STREAMS, 1, DeviceResources::numStreams(), numExecutors); - const auto numSlices = config.numCMXSlices != -1 ? config.numCMXSlices : DefaultAllocation::numSlices(platform, numExecutors); + const auto numSlices = config.compileConfig().numCMXSlices != -1 + ? config.compileConfig().numCMXSlices + : DefaultAllocation::numSlices(platform, numExecutors); VPU_THROW_UNLESS(numSlices >= 1 && numSlices <= DeviceResources::numSlices(platform), R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")", ie::MYRIAD_NUMBER_OF_CMX_SLICES, 1, DeviceResources::numSlices(platform), numSlices); int defaultCmxLimit = DefaultAllocation::tilingCMXLimit(numSlices); - const auto tilingCMXLimit = config.tilingCMXLimitKB != -1 ? std::min(config.tilingCMXLimitKB * 1024, defaultCmxLimit) : defaultCmxLimit; + const auto tilingCMXLimit = config.compileConfig().tilingCMXLimitKB != -1 + ? std::min(config.compileConfig().tilingCMXLimitKB * 1024, defaultCmxLimit) + : defaultCmxLimit; VPU_THROW_UNLESS(tilingCMXLimit >= 0, R"(Value of configuration option ("{}") must be greater than {}, actual is "{}")", ie::MYRIAD_TILING_CMX_LIMIT_KB, 0, tilingCMXLimit); - const auto numShaves = config.numSHAVEs != -1 ? config.numSHAVEs : DefaultAllocation::numShaves(platform, numExecutors, numSlices); + const auto numShaves = config.compileConfig().numSHAVEs != -1 + ? config.compileConfig().numSHAVEs + : DefaultAllocation::numShaves(platform, numExecutors, numSlices); VPU_THROW_UNLESS(numShaves >= 1 && numShaves <= DeviceResources::numShaves(platform), R"(Value of configuration option ("{}") must be in the range [{}, {}], actual is "{}")", ie::MYRIAD_NUMBER_OF_SHAVES, 1, DeviceResources::numShaves(platform), numShaves); @@ -123,7 +130,7 @@ void CompileEnv::init(Platform platform, const CompilationConfig& config, const g_compileEnv->initialized = true; } -void CompileEnv::updateConfig(const CompilationConfig& config) { +void CompileEnv::updateConfig(const PluginConfiguration& config) { IE_ASSERT(g_compileEnv != nullptr); IE_ASSERT(g_compileEnv->initialized); @@ -165,9 +172,9 @@ CompiledGraph::Ptr compileImpl(const ie::CNNNetwork& network, const ie::ICore* c middleEnd->run(model); - if (!env.config.irWithVpuScalesDir.empty()) { - network.serialize(env.config.irWithVpuScalesDir + "/" + network.getName() + "_scales.xml", - env.config.irWithVpuScalesDir + "/" + network.getName() + "_scales.bin"); + if (!env.config.compileConfig().irWithVpuScalesDir.empty()) { + network.serialize(env.config.compileConfig().irWithVpuScalesDir + "/" + network.getName() + "_scales.xml", + env.config.compileConfig().irWithVpuScalesDir + "/" + network.getName() + "_scales.bin"); } return backEnd->build(model, frontEnd->origLayers()); @@ -191,8 +198,8 @@ CompiledGraph::Ptr compileImpl(const Model& model) { } // namespace -CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, Platform platform, const CompilationConfig& config, const Logger::Ptr& log, - const ie::ICore* core) { +CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, ncDevicePlatform_t platform, const PluginConfiguration& config, const Logger::Ptr& log, + const ie::ICore* core) { CompileEnv::init(platform, config, log); AutoScope autoDeinit([] { CompileEnv::free(); @@ -205,8 +212,8 @@ CompiledGraph::Ptr compileNetwork(const ie::CNNNetwork& network, Platform platfo CompiledGraph::Ptr compileModel( const Model& model, - Platform platform, - const CompilationConfig& config, + ncDevicePlatform_t platform, + const PluginConfiguration& config, const Logger::Ptr& log) { CompileEnv::init(platform, config, log); AutoScope autoDeinit([] { @@ -218,7 +225,7 @@ CompiledGraph::Ptr compileModel( return compileImpl(model); } -CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const CompilationConfig& subConfig, const ie::ICore* core) { +CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const PluginConfiguration& subConfig, const ie::ICore* core) { VPU_PROFILE(compileSubNetwork); const auto& env = CompileEnv::get(); @@ -238,11 +245,11 @@ CompiledGraph::Ptr compileSubNetwork(const ie::CNNNetwork& network, const Compil // std::set getSupportedLayers( - const ie::CNNNetwork& network, - Platform platform, - const CompilationConfig& config, - const Logger::Ptr& log, - const ie::ICore* core) { + const ie::CNNNetwork& network, + ncDevicePlatform_t platform, + const PluginConfiguration& config, + const Logger::Ptr& log, + const ie::ICore* core) { CompileEnv::init(platform, config, log); AutoScope autoDeinit([] { CompileEnv::free(); @@ -255,28 +262,28 @@ std::set getSupportedLayers( return frontEnd->checkSupportedLayers(network); } -int DeviceResources::numShaves(const Platform& platform) { - return platform == Platform::MYRIAD_2 ? 12 : 16; +int DeviceResources::numShaves(const ncDevicePlatform_t& platform) { + return platform == ncDevicePlatform_t::NC_MYRIAD_2 ? 12 : 16; } -int DeviceResources::numSlices(const Platform& platform) { - return platform == Platform::MYRIAD_2 ? 12 : 19; +int DeviceResources::numSlices(const ncDevicePlatform_t& platform) { + return platform == ncDevicePlatform_t::NC_MYRIAD_2 ? 12 : 19; } int DeviceResources::numStreams() { return 3; } -int DefaultAllocation::numStreams(const Platform& platform, const CompilationConfig& configuration) { - return platform == Platform::MYRIAD_X && configuration.hwOptimization ? 2 : 1; +int DefaultAllocation::numStreams(const ncDevicePlatform_t& platform, const PluginConfiguration& configuration) { + return platform == ncDevicePlatform_t::NC_MYRIAD_X && configuration.compileConfig().hwOptimization ? 2 : 1; } -int DefaultAllocation::numSlices(const Platform& platform, int numStreams) { +int DefaultAllocation::numSlices(const ncDevicePlatform_t& platform, int numStreams) { const auto capabilities = DeviceResources::numSlices(platform); return capabilities / numStreams; } -int DefaultAllocation::numShaves(const Platform& platform, int numStreams, int numSlices) { +int DefaultAllocation::numShaves(const ncDevicePlatform_t& platform, int numStreams, int numSlices) { const auto numAvailableShaves = DeviceResources::numShaves(platform); if (numStreams == 1) { return numAvailableShaves; diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp index c40588acb93..f5e5d6ff2df 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/pass_manager.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace vpu { @@ -93,7 +94,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(convertShapeNotation); ADD_DUMP_PASS("convertShapeNotation"); - if (!env.config.disableReorder && !env.config.hwOptimization) { + if (!env.config.compileConfig().disableReorder && !env.config.compileConfig().hwOptimization) { ADD_PASS(reorderInputsToChannelMinor); ADD_DUMP_PASS("reorderInputsToChannelMinor"); } @@ -125,7 +126,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // To overcome fp16 limitations // - if (env.config.hwOptimization && env.config.enableWeightsAnalysis) { + if (env.config.compileConfig().hwOptimization && env.config.compileConfig().enableWeightsAnalysis) { ADD_PASS(analyzeWeightableLayers); ADD_DUMP_PASS("analyzeWeightableLayers"); } @@ -150,7 +151,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // Model HW-specific optimizations // - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(replaceFCbyConv); ADD_DUMP_PASS("replaceFCbyConv"); @@ -161,7 +162,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(replaceDeconvByConv); ADD_DUMP_PASS("replaceDeconvByConv"); - if (env.config.hwDilation) { + if (env.config.compileConfig().hwDilation) { ADD_PASS(reshapeDilationConv); ADD_DUMP_PASS("reshapeDilationConv"); } @@ -173,7 +174,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // Pass should be located before "adjustDataBatch" because "adjustDataBatch" specifies "origConvOutput" attribute // for convolution in order to provide that information to "hwConvTiling" pass. // Otherwise, "hwConvTiling" will see incorrect values in "origConvOutput" attribute. - if (env.config.enableCustomReshapeParam) { + if (env.config.compileConfig().enableCustomReshapeParam) { ADD_PASS(reshapeBeforeConvTiling); ADD_DUMP_PASS("reshapeBeforeConvTiling"); } @@ -197,7 +198,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(hwPadding); ADD_DUMP_PASS("hwPadding"); - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(splitLargeKernelConv); ADD_DUMP_PASS("splitLargeKernelConv"); } @@ -209,7 +210,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(adjustDataBatch); ADD_DUMP_PASS("adjustDataBatch"); - if (env.config.enableReplWithSCRelu) { + if (env.config.compileConfig().enableReplWithSCRelu) { ADD_PASS(replaceWithSCReLU); ADD_DUMP_PASS("replaceWithSCReLU"); } @@ -218,13 +219,13 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // HW stages tiling // - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(hwConvTiling); ADD_PASS(hwPoolTiling); ADD_PASS(hwFullyConnectedTiling); ADD_DUMP_PASS("hwTiling"); - if (env.config.hwExtraSplit) { + if (env.config.compileConfig().hwExtraSplit) { ADD_PASS(hwExtraSplit); ADD_DUMP_PASS("hwExtraSplit"); } @@ -242,7 +243,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // // this stage should be executed after "hwPoolTiling" // and before "swPoolAdaptation" - if (env.config.enableReplaceWithReduceMean) { + if (env.config.compileConfig().enableReplaceWithReduceMean) { ADD_PASS(replaceWithReduceMean); ADD_DUMP_PASS("replaceWithReduceMean"); } @@ -261,7 +262,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(mergeReLUAndBias); ADD_DUMP_PASS("mergeReLUAndBias"); - if (env.config.enableEarlyEltwiseReLUFusion) { + if (env.config.compileConfig().enableEarlyEltwiseReLUFusion) { ADD_PASS(mergeEltwiseAndReLUDynamic); ADD_DUMP_PASS("mergeEltwiseAndReLUDynamic"); } @@ -279,7 +280,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // TODO: mergePermute support for reorder stage too. // TODO: pass that will swap Permute and per-element operations. - if (env.config.enablePermuteMerging) { + if (env.config.compileConfig().enablePermuteMerging) { ADD_PASS(mergePermuteStages); ADD_DUMP_PASS("mergePermuteStages"); } @@ -326,7 +327,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // Model common optimizations // - if (env.config.copyOptimization.getOrDefault(true)) { + if (env.config.get()) { ADD_PASS(eliminateCopyStages); ADD_DUMP_PASS("eliminateCopyStages"); } @@ -334,7 +335,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // // HW/SW injection - if (env.config.hwOptimization && env.config.injectSwOps.getOrDefault(true)) { + if (env.config.compileConfig().hwOptimization && env.config.compileConfig().injectSwOps.getOrDefault(true)) { ADD_PASS(injectSw); ADD_DUMP_PASS("injectSw"); } @@ -350,7 +351,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { // HW stages finalization // - if (env.config.hwOptimization) { + if (env.config.compileConfig().hwOptimization) { ADD_PASS(finalizeHwOps); ADD_DUMP_PASS("hwFinalization"); } @@ -361,7 +362,7 @@ PassSet::Ptr PassManager::buildMiddleEnd() { ADD_PASS(markFastStages); ADD_DUMP_PASS("markFastStages"); - if (env.config.enableMemoryTypesAnnotation) { + if (env.config.compileConfig().enableMemoryTypesAnnotation) { ADD_PASS(annotateMemoryTypes); ADD_DUMP_PASS("annotateMemoryTypes"); } diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp index c734ef2a06b..4990b8153ca 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/adjust_data_location.cpp @@ -48,7 +48,7 @@ void PassImpl::run(const Model& model) { allocNonIntermediateData(model); adjustModelForMemReqs(model); copyHwMisalignedInput(model); - if (env.config.packDataInCmx.getOrDefault(true)) { + if (env.config.compileConfig().packDataInCmx.getOrDefault(true)) { packDataInCmx(model); } } @@ -147,7 +147,7 @@ void PassImpl::collectMemReqs(const Model& model) { } void PassImpl::resetStageOrder(const Model& model) { - if (!CompileEnv::get().config.hwOptimization) + if (!CompileEnv::get().config.compileConfig().hwOptimization) return; static const std::string s_expectCMXOutput {"expectCMXOutput"}; diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp index 74a42d8a13e..9d9bf482e75 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/eliminate_copy.cpp @@ -14,6 +14,7 @@ #include #include +#include namespace vpu { @@ -78,7 +79,7 @@ void PassImpl::run(const Model& model) { std::queue copyToRemove; - if (!env.config.copyOptimization.hasValue()) { + if (!env.config.get()) { int nCopyStages = 0; for (const auto& stage : model->getStages()) { if (stage->type() == StageType::Copy) { diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp index d8827d522d2..4fb8c5c0123 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/inject_sw.cpp @@ -68,7 +68,7 @@ void PassImpl::run(const Model& model) { // Collect HW and SW candidates // - if (!env.config.injectSwOps.hasValue() && + if (!env.config.compileConfig().injectSwOps.hasValue() && model->numStages() > nMaxStagesForInjectSw) { env.log->warning( "Pass [injectSw] SKIPPED : number of stages (%d) is larger than threshold %d", diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp index 4684cc50ee6..548557b594b 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_eltwise_and_relu.cpp @@ -30,7 +30,7 @@ private: }; void PassImpl::run(const Model& model) { - const bool enableEarlyEltwiseReLUFusion = CompileEnv::get().config.enableEarlyEltwiseReLUFusion; + const bool enableEarlyEltwiseReLUFusion = CompileEnv::get().config.compileConfig().enableEarlyEltwiseReLUFusion; if (enableEarlyEltwiseReLUFusion) { if (m_mode == MergeMode::DYNAMIC_NETWORK) { VPU_PROFILE(mergeEltwiseAndReLUDynamic); diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp index 5bade8b8bbc..5b83fd0e49b 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/merge_hw_stages.cpp @@ -170,7 +170,7 @@ void PassImpl::run(const Model& model) { // Try to merge next Pooling layer // - if (env.config.mergeHwPoolToConv) { + if (env.config.compileConfig().mergeHwPoolToConv) { if (stage->type() == StageType::StubConv) { if (auto nextPoolStage = getNextPoolStage(stage, output)) { output = nextPoolStage->output(0); diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp index beb1e55cbb8..4ca08a4f65f 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/replace_deconv_by_conv.cpp @@ -148,7 +148,7 @@ void PassImpl::run(const Model& model) { auto output = stage->output(0); const auto& env = CompileEnv::get(); - if (env.config.hwDisabled(stage->origLayer()->name)) { + if (env.config.compileConfig().hwDisabled(stage->origLayer()->name)) { continue; } diff --git a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp index 27e703ec4f5..24efadc7857 100644 --- a/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/middleend/passes/weights_analysis.cpp @@ -88,7 +88,7 @@ bool isScalable(const Stage& stage) { bool checkGrowingOutput(const Model& model) { const auto& env = CompileEnv::get(); - if (!env.config.checkPreprocessingInsideModel) { + if (!env.config.compileConfig().checkPreprocessingInsideModel) { return false; } @@ -258,7 +258,7 @@ void PassImpl::run(const Model& model) { scale = static_cast(1ULL << static_cast(shift)); } - if (!env.config.irWithVpuScalesDir.empty()) { + if (!env.config.compileConfig().irWithVpuScalesDir.empty()) { stage->origLayer()->params["vpu_scale"] = toString(scale); } } diff --git a/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp b/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp index 7323587ce9f..cad7da95ca8 100644 --- a/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/model/stage.cpp @@ -199,7 +199,7 @@ StageSHAVEsRequirements StageNode::getSHAVEsRequirements() const { // return max for Myriad2 const auto& compileEnv = CompileEnv::get(); - if (compileEnv.platform == Platform::MYRIAD_2) { + if (compileEnv.platform == ncDevicePlatform_t::NC_MYRIAD_2) { return StageSHAVEsRequirements::NeedMax; } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp index 04c4923fcae..7f666964414 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/activation.cpp @@ -24,7 +24,7 @@ void FrontEnd::parseActivation(const Model& model, const ie::CNNLayerPtr& layer, const auto type = layer->GetParamAsString("type"); const auto activationParserIt = activationParsers.find(type); - VPU_THROW_UNSUPPORTED_UNLESS(activationParserIt != activationParsers.end(), + VPU_THROW_UNSUPPORTED_LAYER_UNLESS(activationParserIt != activationParsers.end(), "Failed to compile layer \"%v\"(type = %v) ", layer->name, type); activationParserIt->second(model, layer, inputs, outputs); diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp index 529456f919e..695bd43f3c9 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/convolution.cpp @@ -163,9 +163,9 @@ void parseConv2D(const Model & model, kernelStrideY, dilationX, dilationY, - env.config.hwOptimization, - env.config.hwDilation, - env.config.hwDisabled(layer->name)); + env.config.compileConfig().hwOptimization, + env.config.compileConfig().hwDilation, + env.config.compileConfig().hwDisabled(layer->name)); // // Create const datas @@ -476,9 +476,9 @@ void parseConvND(const Model & model, strides[1], dilations[0], dilations[1], - env.config.hwOptimization, - env.config.hwDilation, - env.config.hwDisabled(layer->name)); + env.config.compileConfig().hwOptimization, + env.config.compileConfig().hwDilation, + env.config.compileConfig().hwDisabled(layer->name)); int try_hw = tryHW ? 1 : 0; diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp index c2994273ca7..96da14dc941 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/fc.cpp @@ -37,13 +37,13 @@ void FrontEnd::parseFullyConnected(const Model& model, const ie::CNNLayerPtr& _l // Check if HW is applicable // - auto tryHW = env.config.hwOptimization; + auto tryHW = env.config.compileConfig().hwOptimization; if (output->desc().dim(Dim::W, 1) != 1 || output->desc().dim(Dim::H, 1) != 1) { tryHW = false; } - if (env.config.hwDisabled(layer->name)) { + if (env.config.compileConfig().hwDisabled(layer->name)) { tryHW = false; } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp index 795b45c8a04..e9d6899f7ab 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/mtcnn.cpp @@ -162,7 +162,7 @@ void FrontEnd::parseMTCNN(const Model& model, const ie::CNNLayerPtr& layer, cons IE_ASSERT(inputs.size() == 1); IE_ASSERT(outputs.size() == 1); - if (!env.config.hwOptimization) { + if (!env.config.compileConfig().hwOptimization) { VPU_THROW_EXCEPTION << "MTCNN layer supports Myriad X with NCE only"; } diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp index 411cc2de0d7..071c2fb0328 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/permute.cpp @@ -124,7 +124,7 @@ Stage StageBuilder::addReorderStage( const Data& output) { const auto* env = CompileEnv::getOrNull(); VPU_THROW_UNLESS( - env == nullptr || !env->config.disableReorder, + env == nullptr || !env->config.compileConfig().disableReorder, "Tried to add Reorder Stage %v, while DISABLE_REORDER option was set", name); diff --git a/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp b/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp index 5551e72231b..2823d0c9165 100644 --- a/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp +++ b/inference-engine/src/vpu/graph_transformer/src/stages/pooling.cpp @@ -221,8 +221,8 @@ void parsePool2D(const Model & model, // const auto& env = CompileEnv::get(); - bool hwOptimization = env.config.hwOptimization; - bool hwDisabled = env.config.hwDisabled(layer->name); + bool hwOptimization = env.config.compileConfig().hwOptimization; + bool hwDisabled = env.config.compileConfig().hwDisabled(layer->name); int inputWidth = input->desc().dim(Dim::W); int inputHeight = input->desc().dim(Dim::H); @@ -480,8 +480,8 @@ void parsePoolND(const Model & model, // const auto& env = CompileEnv::get(); - bool hwOptimization = env.config.hwOptimization; - bool hwDisabled = env.config.hwDisabled(layer->name); + bool hwOptimization = env.config.compileConfig().hwOptimization; + bool hwDisabled = env.config.compileConfig().hwDisabled(layer->name); bool tryHW = canTryHW(poolLayer->_type, input_shape[0], diff --git a/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp new file mode 100644 index 00000000000..41a53f0619e --- /dev/null +++ b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "configuration/myriad_configuration.hpp" + +namespace vpu { + +MyriadConfiguration::MyriadConfiguration() {} + +void MyriadConfiguration::from(const std::map& configuration) { + std::map migratedOptions, notMigratedOptions; + for (const auto& entry : configuration) { + auto& destination = PluginConfiguration::supports(entry.first) ? migratedOptions : notMigratedOptions; + destination.emplace(entry); + } + PluginConfiguration::from(migratedOptions); + update(notMigratedOptions); +} + +void MyriadConfiguration::fromAtRuntime(const std::map& configuration) { + std::map migratedOptions, notMigratedOptions; + for (const auto& entry : configuration) { + auto& destination = PluginConfiguration::supports(entry.first) ? migratedOptions : notMigratedOptions; + destination.emplace(entry); + } + PluginConfiguration::fromAtRuntime(migratedOptions); + update(notMigratedOptions, ConfigMode::RunTime); +} + +} // namespace vpu diff --git a/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp new file mode 100644 index 00000000000..080d262c703 --- /dev/null +++ b/inference-engine/src/vpu/myriad_plugin/configuration/myriad_configuration.hpp @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "vpu/configuration/plugin_configuration.hpp" +#include "myriad_config.h" + +namespace vpu { + +class MyriadConfiguration final : public PluginConfiguration, public MyriadPlugin::MyriadConfig { +public: + MyriadConfiguration(); + + // TODO: remove once all options are migrated + void from(const std::map& configuration); + void fromAtRuntime(const std::map& configuration); +}; + +} // namespace vpu diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_config.h b/inference-engine/src/vpu/myriad_plugin/myriad_config.h index 176e677a9b6..5745516e179 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_config.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_config.h @@ -34,7 +34,7 @@ VPU_DECLARE_ENUM(MovidiusDdrType, MICRON_1GB = 4, ) -class MyriadConfig final : public ParsedConfig { +class MyriadConfig : public virtual ParsedConfig { public: const std::string& pluginLogFilePath() const { return _pluginLogFilePath; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp index 7a0a22499c1..f8806435188 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.cpp @@ -14,6 +14,7 @@ #include #include #include +#include using namespace InferenceEngine; @@ -25,23 +26,24 @@ namespace MyriadPlugin { ExecutableNetwork::ExecutableNetwork( std::shared_ptr mvnc, std::vector& devicePool, - const MyriadConfig& config, + const MyriadConfiguration& config, const ie::ICore* core) : _config(config), _core(core) { VPU_PROFILE(ExecutableNetwork); + const auto& logLevel = _config.get(); + _log = std::make_shared( "MyriadPlugin", - _config.logLevel(), + logLevel, defaultOutput(_config.pluginLogFilePath())); - _executor = std::make_shared(_config.forceReset(), std::move(mvnc), _config.logLevel(), _log); + _executor = std::make_shared(_config.forceReset(), std::move(mvnc), logLevel, _log); _device = _executor->openDevice(devicePool, _config); - const auto& compileConfig = config.compileConfig(); const auto& revision = _device->revision(); - _actualNumExecutors = compileConfig.numExecutors != -1 ? compileConfig.numExecutors : DefaultAllocation::numStreams(revision, compileConfig); + _actualNumExecutors = config.compileConfig().numExecutors != -1 ? config.compileConfig().numExecutors : DefaultAllocation::numStreams(revision, config); _supportedMetrics = { METRIC_KEY(NETWORK_NAME), @@ -56,22 +58,22 @@ ExecutableNetwork::ExecutableNetwork( const ie::CNNNetwork& network, std::shared_ptr mvnc, std::vector& devicePool, - const MyriadConfig& config, + const MyriadConfiguration& config, const ie::ICore* core) : ExecutableNetwork(std::move(mvnc), devicePool, config, core) { VPU_PROFILE(ExecutableNetwork); const auto compilerLog = std::make_shared( "GraphCompiler", - _config.logLevel(), + _config.get(), defaultOutput(_config.compilerLogFilePath())); if (_device == nullptr) IE_THROW() << "No device was detected"; auto compiledGraph = compileNetwork( network, - static_cast(_device->_platform), - _config.compileConfig(), + _device->_platform, + _config, compilerLog, _core); @@ -100,9 +102,7 @@ ExecutableNetwork::ExecutableNetwork( } } -void ExecutableNetwork::Import(std::istream& strm, - std::vector &devicePool, - const MyriadConfig& config) { +void ExecutableNetwork::Import(std::istream& strm, std::vector &devicePool, const MyriadConfiguration& configuration) { auto currentPos = strm.tellg(); strm.seekg(0, strm.end); auto blobSize = strm.tellg() - currentPos; @@ -147,11 +147,8 @@ void ExecutableNetwork::Import(std::istream& strm, } } -ExecutableNetwork::ExecutableNetwork(std::istream& strm, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core) : +ExecutableNetwork::ExecutableNetwork(std::istream& strm, std::shared_ptr mvnc, std::vector &devicePool, + const MyriadConfiguration& config, const ie::ICore* core) : ExecutableNetwork(std::move(mvnc), devicePool, config, core) { VPU_PROFILE(ExecutableNetwork); Import(strm, devicePool, config); @@ -161,7 +158,7 @@ ExecutableNetwork::ExecutableNetwork( const std::string& blobFilename, std::shared_ptr mvnc, std::vector& devicePool, - const MyriadConfig& config, + const MyriadConfiguration& config, const ie::ICore* core) : ExecutableNetwork(std::move(mvnc), devicePool, config, core) { VPU_PROFILE(ExecutableNetwork); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h index 22824ee5ec1..0b58bf2f480 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executable_network.h @@ -32,23 +32,14 @@ class ExecutableNetwork : public ie::ExecutableNetworkThreadSafeDefault { public: typedef std::shared_ptr Ptr; - explicit ExecutableNetwork(const ie::CNNNetwork& network, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(const InferenceEngine::CNNNetwork& network, std::shared_ptr mvnc, std::vector &devicePool, + const MyriadConfiguration& configuration, const ie::ICore* core); - explicit ExecutableNetwork(std::istream& strm, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(std::istream& strm, std::shared_ptr mvnc, std::vector &devicePool, const MyriadConfiguration& configuration, + const ie::ICore* core); - explicit ExecutableNetwork(const std::string &blobFilename, - std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(const std::string &blobFilename, std::shared_ptr mvnc, std::vector &devicePool, + const MyriadConfiguration& configuration, const ie::ICore* core); virtual ~ExecutableNetwork() { @@ -97,9 +88,7 @@ public: ie::CNNNetwork GetExecGraphInfo() override; - void Import(std::istream& strm, - std::vector &devicePool, - const MyriadConfig& config); + void Import(std::istream& strm, std::vector &devicePool, const MyriadConfiguration& configuration); private: Logger::Ptr _log; @@ -108,7 +97,7 @@ private: GraphDesc _graphDesc; DevicePtr _device; GraphMetaInfo _graphMetaData; - MyriadConfig _config; + MyriadConfiguration _config; const ie::ICore* _core = nullptr; int _actualNumExecutors = 0; std::vector _supportedMetrics; @@ -119,10 +108,7 @@ private: const size_t _maxTaskExecutorGetResultCount = 1; std::queue _taskExecutorGetResultIds; - ExecutableNetwork(std::shared_ptr mvnc, - std::vector &devicePool, - const MyriadConfig& config, - const ie::ICore* core); + ExecutableNetwork(std::shared_ptr mvnc, std::vector &devicePool, const MyriadConfiguration& config, const ie::ICore* core); ie::ITaskExecutor::Ptr getNextTaskExecutor() { std::string id = _taskExecutorGetResultIds.front(); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp index d92a948ce57..49cf63c4e63 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executor.cpp @@ -73,8 +73,7 @@ MyriadExecutor::MyriadExecutor(bool forceReset, std::shared_ptr mvnc, /* * @brief Boot available device */ -ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, - const MyriadConfig& config) { +ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, const MyriadConfiguration& config) { VPU_PROFILE(bootNextDevice); // #-17972, #-16790 #if defined(NO_BOOT) @@ -221,7 +220,7 @@ ncStatus_t MyriadExecutor::bootNextDevice(std::vector &devicePool, } DevicePtr MyriadExecutor::openDevice(std::vector& devicePool, - const MyriadConfig& config) { + const MyriadConfiguration& config) { VPU_PROFILE(openDevice); std::lock_guard lock(device_mutex); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_executor.h b/inference-engine/src/vpu/myriad_plugin/myriad_executor.h index e7c9c8614ee..d9883d8501e 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_executor.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_executor.h @@ -13,6 +13,7 @@ #include #include "myriad_mvnc_wrapper.h" +#include "configuration/myriad_configuration.hpp" #include @@ -63,9 +64,9 @@ struct DeviceDesc { ((config.protocol() == NC_ANY_PROTOCOL) || (_protocol == config.protocol())); } - Platform revision() const { + ncDevicePlatform_t revision() const { VPU_THROW_UNLESS(_platform != NC_ANY_PLATFORM, "Cannot get a revision from not booted device"); - return _platform == NC_MYRIAD_2 ? Platform::MYRIAD_2 : Platform::MYRIAD_X; + return _platform; } }; @@ -86,7 +87,7 @@ public: * @brief Get myriad device * @return Already booted and empty device or new booted device */ - DevicePtr openDevice(std::vector &devicePool, const MyriadConfig& config); + DevicePtr openDevice(std::vector &devicePool, const MyriadConfiguration& config); static void closeDevices(std::vector &devicePool, std::shared_ptr mvnc); @@ -134,8 +135,7 @@ private: * @param configPlatform Boot the selected platform * @param configProtocol Boot device with selected protocol */ - ncStatus_t bootNextDevice(std::vector &devicePool, - const MyriadConfig& config); + ncStatus_t bootNextDevice(std::vector &devicePool, const MyriadConfiguration& config); }; typedef std::shared_ptr MyriadExecutorPtr; diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h index 667b93b6aae..9373f771fb9 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h @@ -14,6 +14,7 @@ #include #include +#include #include "myriad_executor.h" #include "myriad_config.h" diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp index fc022ff4184..e91ef8333fe 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_metrics.cpp @@ -31,6 +31,7 @@ MyriadMetrics::MyriadMetrics() { }; IE_SUPPRESS_DEPRECATED_START + // TODO: remove once all options are migrated _supportedConfigKeys = { MYRIAD_ENABLE_HW_ACCELERATION, MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, @@ -45,7 +46,6 @@ IE_SUPPRESS_DEPRECATED_START KEY_VPU_MYRIAD_FORCE_RESET, KEY_VPU_MYRIAD_PLATFORM, - CONFIG_KEY(LOG_LEVEL), CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS), CONFIG_KEY(PERF_COUNT), CONFIG_KEY(CONFIG_FILE), diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp index 75e7ef395d9..7771cc8bfbf 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp @@ -18,8 +18,9 @@ #include #include #include -#include -#include + +#include +#include #include "myriad_plugin.h" @@ -34,31 +35,40 @@ IExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl( const std::map& config) { VPU_PROFILE(LoadExeNetworkImpl); - auto parsedConfigCopy = _parsedConfig; - parsedConfigCopy.update(config); + auto executableNetworkConfiguration = _parsedConfig; + executableNetworkConfiguration.from(config); + executableNetworkConfiguration.validate(); - return std::make_shared(network, _mvnc, _devicePool, parsedConfigCopy, GetCore()); + return std::make_shared(network, _mvnc, _devicePool, executableNetworkConfiguration, GetCore()); } void Engine::SetConfig(const std::map &config) { - _parsedConfig.update(config); + _parsedConfig.from(config); + // TODO: remove once all options are migrated for (const auto& entry : config) { _config[entry.first] = entry.second; } + +#ifndef NDEBUG + if (const auto envVar = std::getenv("IE_VPU_LOG_LEVEL")) { + _parsedConfig.set(LogLevelOption::key(), envVar); + } +#endif } Parameter Engine::GetConfig(const std::string& name, const std::map& options) const { - auto supported_keys = _metrics->SupportedConfigKeys(); - if (std::find(supported_keys.begin(), - supported_keys.end(), name) == supported_keys.end()) { - IE_THROW() << "Unsupported config key : " << name; - } + // TODO: remove once all options are migrated + const auto& supportedKeys = _metrics->SupportedConfigKeys(); + VPU_THROW_UNSUPPORTED_OPTION_UNLESS(supportedKeys.count(name) == 1 || _parsedConfig.supports(name), "Unsupported configuration key: {}", name); Parameter result; - auto option = _config.find(name); - if (option != _config.end()) - result = option->second; + if (_parsedConfig.supports(name)) { + result = _parsedConfig.asParameter(name); + } else if (_config.count(name)) { + // TODO: remove once all options are migrated + result = _config.at(name); + } return result; } @@ -70,7 +80,7 @@ QueryNetworkResult Engine::QueryNetwork( QueryNetworkResult res; auto parsedConfigCopy = _parsedConfig; - parsedConfigCopy.update(config); + parsedConfigCopy.from(config); const auto deviceName = parsedConfigCopy.deviceName(); if (!deviceName.empty()) { @@ -80,13 +90,13 @@ QueryNetworkResult Engine::QueryNetwork( const auto log = std::make_shared( "GraphCompiler", - parsedConfigCopy.logLevel(), + _parsedConfig.get(), defaultOutput(parsedConfigCopy.compilerLogFilePath())); const auto supportedLayers = getSupportedLayers( network, - static_cast(parsedConfigCopy.platform()), - parsedConfigCopy.compileConfig(), + parsedConfigCopy.platform(), + parsedConfigCopy, log, GetCore()); @@ -111,6 +121,7 @@ Engine::Engine(std::shared_ptr mvnc) : _pluginName = "MYRIAD"; + // TODO: remove once all options are migrated IE_SUPPRESS_DEPRECATED_START _config = { { MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES) }, @@ -126,13 +137,19 @@ IE_SUPPRESS_DEPRECATED_START { KEY_VPU_MYRIAD_FORCE_RESET, CONFIG_VALUE(NO) }, { KEY_VPU_MYRIAD_PLATFORM, "" }, - { KEY_LOG_LEVEL, CONFIG_VALUE(LOG_NONE) }, { KEY_EXCLUSIVE_ASYNC_REQUESTS, CONFIG_VALUE(NO) }, { KEY_PERF_COUNT, CONFIG_VALUE(NO) }, { KEY_CONFIG_FILE, "" }, { KEY_DEVICE_ID, "" }, }; IE_SUPPRESS_DEPRECATED_END + + _parsedConfig.registerOption(); + _parsedConfig.registerOption(); + +IE_SUPPRESS_DEPRECATED_START + _parsedConfig.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END } InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork( @@ -140,14 +157,12 @@ InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetwork( const std::map& config) { VPU_PROFILE(ImportNetwork); - auto parsedConfigCopy = _parsedConfig; - parsedConfigCopy.update(config, ConfigMode::RunTime); + auto executableNetworkConfiguration = _parsedConfig; + executableNetworkConfiguration.fromAtRuntime(config); + executableNetworkConfiguration.validate(); - const auto executableNetwork = - std::make_shared( - model, _mvnc, _devicePool, parsedConfigCopy, GetCore()); + const auto executableNetwork = std::make_shared(model, _mvnc, _devicePool, executableNetworkConfiguration, GetCore()); executableNetwork->SetPointerToPlugin(shared_from_this()); - return executableNetwork; } @@ -186,7 +201,10 @@ InferenceEngine::Parameter Engine::GetMetric(const std::string& name, const auto& supportedMetrics = _metrics->SupportedMetrics(); IE_SET_METRIC_RETURN(SUPPORTED_METRICS, std::vector{supportedMetrics.cbegin(), supportedMetrics.cend()}); } else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) { - const auto& supportedConfigKeys = _metrics->SupportedConfigKeys(); + // TODO: remove once all options are migrated + auto supportedConfigKeys = _metrics->SupportedConfigKeys(); + const auto& publicKeys = _parsedConfig.getPublicKeys(); + supportedConfigKeys.insert(publicKeys.cbegin(), publicKeys.cend()); IE_SET_METRIC_RETURN(SUPPORTED_CONFIG_KEYS, std::vector{supportedConfigKeys.cbegin(), supportedConfigKeys.cend()}); } else if (name == METRIC_KEY(OPTIMIZATION_CAPABILITIES)) { const auto& optimizationCapabilities = _metrics->OptimizationCapabilities(); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h index 9fb074b5ac1..1d7536600c2 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h @@ -8,6 +8,7 @@ #include "myriad_executable_network.h" #include "myriad_mvnc_wrapper.h" #include "myriad_metrics.h" +#include "configuration/myriad_configuration.hpp" #include #include #include @@ -50,7 +51,7 @@ public: const std::map& options) const override; private: - MyriadConfig _parsedConfig; + MyriadConfiguration _parsedConfig; std::vector _devicePool; std::shared_ptr _mvnc; std::shared_ptr _metrics; diff --git a/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp b/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp index cc5cc1fe4eb..6393aa69d16 100644 --- a/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp +++ b/inference-engine/tests/functional/inference_engine/async_infer_request_test.cpp @@ -5,26 +5,12 @@ #include #include -#include "unit_test_utils/mocks/mock_iinfer_request.hpp" using namespace ::testing; using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -IE_SUPPRESS_DEPRECATED_START - -TEST(InferRequestCPPTests, throwsOnUninitialized) { - std::shared_ptr ptr; - ASSERT_THROW(InferRequest req(ptr), InferenceEngine::NotAllocated); -} - -TEST(InferRequestCPPTests, nothrowOnInitialized) { - std::shared_ptr ptr = std::make_shared(); - ASSERT_NO_THROW(InferRequest req(ptr)); -} - -IE_SUPPRESS_DEPRECATED_END TEST(InferRequestCPPTests, throwsOnUninitializedSetBlob) { InferRequest req; diff --git a/inference-engine/tests/functional/inference_engine/executable_network.cpp b/inference-engine/tests/functional/inference_engine/executable_network.cpp index 8db2bf40ed2..89653bdc5ee 100644 --- a/inference-engine/tests/functional/inference_engine/executable_network.cpp +++ b/inference-engine/tests/functional/inference_engine/executable_network.cpp @@ -4,75 +4,60 @@ #include #include -#include "unit_test_utils/mocks/mock_iexecutable_network.hpp" using namespace ::testing; using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -IE_SUPPRESS_DEPRECATED_START - -TEST(ExecutableNetworkTests, throwsOnUninitialized) { - std::shared_ptr ptr; - ASSERT_THROW(ExecutableNetwork req(ptr), InferenceEngine::NotAllocated); -} - -TEST(ExecutableNetworkTests, nothrowOnInitialized) { - std::shared_ptr ptr = std::make_shared(); - ASSERT_NO_THROW(ExecutableNetwork req(ptr)); -} - -IE_SUPPRESS_DEPRECATED_END - TEST(ExecutableNetworkTests, throwsOnUninitializedGetOutputsInfo) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetOutputsInfo(), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetInputsInfo) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetInputsInfo(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetInputsInfo(), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedExport) { ExecutableNetwork exec; - ASSERT_THROW(exec.Export(std::string()), InferenceEngine::Exception); + ASSERT_THROW(exec.Export(std::string()), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedExportStream) { ExecutableNetwork exec; - ASSERT_THROW(exec.Export(std::cout), InferenceEngine::Exception); + ASSERT_THROW(exec.Export(std::cout), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetExecGraphInfo) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetExecGraphInfo(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetExecGraphInfo(), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedQueryState) { IE_SUPPRESS_DEPRECATED_START ExecutableNetwork exec; - ASSERT_THROW(exec.QueryState(), InferenceEngine::Exception); + ASSERT_THROW(exec.QueryState(), InferenceEngine::NotAllocated); IE_SUPPRESS_DEPRECATED_END } TEST(ExecutableNetworkTests, throwsOnUninitializedSetConfig) { ExecutableNetwork exec; - ASSERT_THROW(exec.SetConfig({{}}), InferenceEngine::Exception); + ASSERT_THROW(exec.SetConfig({{}}), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetConfig) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetConfig({}), InferenceEngine::Exception); + ASSERT_THROW(exec.GetConfig({}), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetMetric) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetMetric({}), InferenceEngine::Exception); + ASSERT_THROW(exec.GetMetric({}), InferenceEngine::NotAllocated); } TEST(ExecutableNetworkTests, throwsOnUninitializedGetContext) { ExecutableNetwork exec; - ASSERT_THROW(exec.GetContext(), InferenceEngine::Exception); + ASSERT_THROW(exec.GetContext(), InferenceEngine::NotAllocated); } \ No newline at end of file diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp index 8e89b952526..10ba4513f20 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp @@ -116,6 +116,7 @@ public: SimpleLowPrecisionTransformer transform; transform.add(testValues.params); transform.transform(actualFunction); + std::shared_ptr refWeights = pass::low_precision::fold( testValues.expected.weights, opset1::Constant::create( @@ -202,6 +203,26 @@ const std::vector testValues = true } }, + // with zero point + { + LayerTransformation::createParamsU8I8(), + // ActualValues + { + ngraph::element::u8, + {{ngraph::element::f32}, { 128.f }, { 0.02f }}, + { 255ul, Shape({}), { 0.f }, { 254.f }, { -1.27f }, { 1.27f } }, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }) + }, + // ExpectedValues + { + ngraph::element::u8, + {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, + {}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), + true + } + }, // updatePrecisions = false { LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), @@ -262,6 +283,26 @@ const std::vector testValues = true } }, + // without zero point + { + LayerTransformation::createParamsU8I8(), + // ActualValues + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, { 0.02f }}, + { 255ul, Shape({}), { 0.f }, { 254.f }, { -1.27f }, { 1.27f } }, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }) + }, + // ExpectedValues + { + ngraph::element::u8, + {}, + {}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), + true + } + }, // QDq version { LayerTransformation::createParamsU8I8(), diff --git a/inference-engine/tests/functional/inference_engine/parameter_tests.cpp b/inference-engine/tests/functional/inference_engine/parameter_tests.cpp index 85496e91707..49c72cad916 100644 --- a/inference-engine/tests/functional/inference_engine/parameter_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/parameter_tests.cpp @@ -246,6 +246,18 @@ TEST_F(ParameterTests, ParametersCStringEqual) { ASSERT_FALSE(p1 != p2); } +TEST_F(ParameterTests, MapOfParametersEqual) { + std::map map0; + map0["testParamInt"] = 4; + map0["testParamString"] = "test"; + const auto map1 = map0; + + Parameter p0 = map0; + Parameter p1 = map1; + ASSERT_TRUE(p0 == p1); + ASSERT_FALSE(p0 != p1); +} + TEST_F(ParameterTests, CompareParametersWithoutEqualOperator) { class TestClass { public: @@ -312,4 +324,95 @@ TEST_F(ParameterTests, ParameterRemovedRealObjectPointerWithDuplication) { } ASSERT_EQ(1, DestructorTest::constructorCount); ASSERT_EQ(1, DestructorTest::destructorCount); -} \ No newline at end of file +} + +TEST_F(ParameterTests, PrintToEmptyParameterDoesNothing) { + Parameter p; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToIntParameter) { + int value = -5; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::to_string(value)); +} + +TEST_F(ParameterTests, PrintToUIntParameter) { + unsigned int value = 5; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::to_string(value)); +} + +TEST_F(ParameterTests, PrintToSize_tParameter) { + std::size_t value = 5; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::to_string(value)); +} + +TEST_F(ParameterTests, PrintToFloatParameter) { + Parameter p = 5.5f; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{"5.5"}); +} + +TEST_F(ParameterTests, PrintToStringParameter) { + std::string value = "some text"; + Parameter p = value; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), value); +} + +TEST_F(ParameterTests, PrintToVectorOfIntsParameterDoesNothing) { + Parameter p = std::vector{-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfUIntsParameterDoesNothing) { + Parameter p = std::vector{0, 1, 2, 3, 4, 5}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfSize_tParameterDoesNothing) { + Parameter p = std::vector{0, 1, 2, 3, 4, 5}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfFloatsParameterDoesNothing) { + Parameter p = std::vector{0.0f, 1.1f, 2.2f, 3.3f, 4.4f, 5.5f}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToVectorOfStringsParameterDoesNothing) { + Parameter p = std::vector{"zero", "one", "two", "three", "four", "five"}; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} + +TEST_F(ParameterTests, PrintToMapOfParametersDoesNothing) { + std::map refMap; + refMap["testParamInt"] = 4; + refMap["testParamString"] = "test"; + Parameter p = refMap; + std::stringstream stream; + ASSERT_NO_THROW(PrintTo(p, &stream)); + ASSERT_EQ(stream.str(), std::string{}); +} diff --git a/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp index 2d1594d3841..6e151972e47 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/low_latency_test.cpp @@ -25,12 +25,18 @@ TEST(TransformationTests, LowLatencyLSTM) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto X = std::make_shared(element::f32, Shape{1, 1, 16}); + X->set_friendly_name("X"); auto H_init = std::make_shared(element::f32, Shape{1, 128}); + H_init->set_friendly_name("H_init"); auto C_init = std::make_shared(element::f32, Shape{1, 128}); + C_init->set_friendly_name("C_init"); auto Xi = std::make_shared(element::f32, Shape{1, 1, 16}); + Xi->set_friendly_name("Xi"); auto H_t = std::make_shared(element::f32, Shape{1, 128}); + H_t->set_friendly_name("H_t"); auto C_t = std::make_shared(element::f32, Shape{1, 128}); + C_t->set_friendly_name("C_t"); // Body auto axis = ngraph::opset6::Constant::create(ngraph::element::i64, ngraph::Shape{}, {0}); @@ -79,8 +85,8 @@ TEST(TransformationTests, LowLatencyLSTM) { auto H_t = std::make_shared(element::f32, Shape{1, 128}); auto C_t = std::make_shared(element::f32, Shape{1, 128}); - const std::string variable_name_H("LSTMTensorIterator/variable0"); - const std::string variable_name_C("LSTMTensorIterator/variable1"); + const std::string variable_name_H("LSTMTensorIterator/H_t/variable_2"); + const std::string variable_name_C("LSTMTensorIterator/C_t/variable_0"); auto variable_H = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_H}); auto variable_C = std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, variable_name_C}); auto read_value_H = std::make_shared(H_t, variable_H); @@ -107,7 +113,7 @@ TEST(TransformationTests, LowLatencyLSTM) { assign_H->add_control_dependency(read_value_H); assign_C->add_control_dependency(read_value_C); } - auto res = compare_functions(f, f_ref); + auto res = compare_functions(f, f_ref, true, false, false, true, true); ASSERT_TRUE(res.first) << res.second; } diff --git a/inference-engine/tests/functional/inference_engine/variable_state.cpp b/inference-engine/tests/functional/inference_engine/variable_state.cpp index 5073a155fca..f17bd599bb6 100644 --- a/inference-engine/tests/functional/inference_engine/variable_state.cpp +++ b/inference-engine/tests/functional/inference_engine/variable_state.cpp @@ -5,32 +5,12 @@ #include #include -#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp" using namespace ::testing; using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -IE_SUPPRESS_DEPRECATED_START - -TEST(VariableStateCPPTests, throwsOnUninitialized) { - std::shared_ptr ptr; - ASSERT_THROW(VariableState var(ptr), InferenceEngine::NotAllocated); -} - -TEST(VariableStateCPPTests, nothrowOnInitialized) { - std::shared_ptr ptr = std::make_shared(); - ASSERT_NO_THROW(VariableState var(ptr)); -} - -TEST(VariableStateCPPTests, throwsOnUninitializedGetLastState) { - VariableState req; - ASSERT_THROW(req.GetLastState(), InferenceEngine::NotAllocated); -} - -IE_SUPPRESS_DEPRECATED_END - TEST(VariableStateCPPTests, throwsOnUninitializedReset) { VariableState req; ASSERT_THROW(req.Reset(), InferenceEngine::NotAllocated); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index a6e2e93a37e..223f9743a61 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -27,6 +27,13 @@ const std::vector params "Convolution", "U8" }, + { + { 256ul, ngraph::Shape {}, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + false, + { 255ul, ngraph::Shape {}, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, + false, + "Convolution", + "U8" + }, { { 16ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, false, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp index 6e762ed562c..510e4039e2b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/activation.cpp @@ -64,6 +64,7 @@ const std::map>> activationTypes // List of operations that should be tested also with integer precision const std::map>> intActivationTypes = { + {Ceiling, {}}, {Sqrt, {}}, {Tanh, {}}, }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index 3d4678bf589..aa4c6dafb02 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -33,8 +33,6 @@ std::vector disabledTestPatterns() { // TODO: Issue: 34055 R"(.*ShapeOfLayerTest.*)", R"(.*ReluShapeOfSubgraphTest.*)", - // TODO: Issue: 34805 - R"(.*ActivationLayerTest.*Ceiling.*)", // TODO: Issue: 43314 R"(.*Broadcast.*mode=BIDIRECTIONAL.*inNPrec=BOOL.*)", // TODO: Issue 43417 sporadic issue, looks like an issue in test, reproducible only on Windows platform diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp index e25236aafab..aa4975e602f 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/convolution_negative.cpp @@ -24,7 +24,7 @@ const std::vector> kernels2D = { {3, 3}, }; -const std::vector> InvalidKernels2D = { +const std::vector> kernels2DInvalid = { {1, 4}, {2, 3}, {3, 2}, @@ -50,8 +50,8 @@ const std::vector> dilations2D = { {1, 1}, }; const std::vector> dilations2DInvalid = { {2, 2}, }; -const std::vector numOutCannels2D = { 32 }; -const std::vector numOutCannels2DInvalid = { 1, 7, 9, 400 }; +const std::vector numOutChannels2D = { 32 }; +const std::vector numOutChannels2DInvalid = { 1, 7, 9, 400 }; const std::vector> input2DNCHWFine = { { 1, 8, 20, 16 } }; @@ -68,16 +68,16 @@ const auto conv2DParametersFine = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidKernel = ::testing::Combine( - ::testing::ValuesIn(InvalidKernels2D), + ::testing::ValuesIn(kernels2DInvalid), ::testing::ValuesIn(strides2D), ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidFilterNumber = ::testing::Combine( @@ -86,7 +86,7 @@ const auto conv2DParametersInvalidFilterNumber = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2DInvalid), + ::testing::ValuesIn(numOutChannels2DInvalid), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidPadding = ::testing::Combine( @@ -95,7 +95,7 @@ const auto conv2DParametersInvalidPadding = ::testing::Combine( ::testing::ValuesIn(padBegins2DInvalid), ::testing::ValuesIn(padEnds2DInvalid), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidStride = ::testing::Combine( @@ -104,7 +104,7 @@ const auto conv2DParametersInvalidStride = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2D), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); const auto conv2DParametersInvalidDilation = ::testing::Combine( @@ -113,7 +113,7 @@ const auto conv2DParametersInvalidDilation = ::testing::Combine( ::testing::ValuesIn(padBegins2D), ::testing::ValuesIn(padEnds2D), ::testing::ValuesIn(dilations2DInvalid), - ::testing::ValuesIn(numOutCannels2D), + ::testing::ValuesIn(numOutChannels2D), ::testing::Values(ngraph::op::PadType::EXPLICIT) ); @@ -142,7 +142,7 @@ protected: } }; -#define GNA_NEG_INSTANTIATE(whats_wrong, sufix_params, sufix_input, error_message) \ +#define GNA_NEG_INSTANTIATE(whats_wrong, suffix_params, suffix_input, error_message) \ struct GnaConv2DNegativeTest##whats_wrong : GnaConv2DNegativeTest { \ std::string expectedSubstring() override { \ return error_message; \ @@ -153,13 +153,13 @@ TEST_P(GnaConv2DNegativeTest##whats_wrong, ThrowAsNotSupported) { } \ INSTANTIATE_TEST_CASE_P(smoke_GnaConv2DNegativeTestInvalid##whats_wrong, GnaConv2DNegativeTest##whats_wrong, \ ::testing::Combine( \ - conv2DParameters##sufix_params, \ + conv2DParameters##suffix_params, \ ::testing::ValuesIn(netPrecisions), \ ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), \ ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), \ ::testing::Values(InferenceEngine::Layout::ANY), \ ::testing::Values(InferenceEngine::Layout::ANY), \ - ::testing::ValuesIn(input2DNCHW##sufix_input), \ + ::testing::ValuesIn(input2DNCHW##suffix_input), \ ::testing::Values(CommonTestUtils::DEVICE_GNA)), \ GnaConv2DNegativeTest##whats_wrong::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp index 2cf625b5862..697059e3ce2 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_backprop_data_transformation.cpp @@ -28,6 +28,13 @@ const std::vector params "Convolution", "U8" }, + { + { 256ul, ngraph::Shape {}, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + false, + { 255ul, ngraph::Shape {}, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, + false, + "Convolution", + "U8" + }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.75f }, { 6.375f } }, true, diff --git a/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt b/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt index 6a5b0f90e90..14f387fa7ba 100644 --- a/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt +++ b/inference-engine/tests/functional/plugin/myriad/CMakeLists.txt @@ -4,19 +4,32 @@ set(TARGET_NAME myriadFuncTests) +disable_deprecated_warnings() + +include(${XLINK_DIR}/XLink.cmake) + addIeTargetTest( NAME ${TARGET_NAME} ROOT ${CMAKE_CURRENT_SOURCE_DIR} INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${IE_MAIN_SOURCE_DIR}/src/vpu/graph_transformer/include + ${IE_MAIN_SOURCE_DIR}/tests_deprecated/behavior/vpu/myriad_tests/helpers + ${XLINK_INCLUDE} + ${XLINK_PLATFORM_INCLUDE} DEPENDENCIES myriadPlugin LINK_LIBRARIES vpu_common_lib vpu_graph_transformer funcSharedTests + mvnc ADD_CPPLINT + DEFINES + __PC__ + OBJECT_FILES + ${IE_MAIN_SOURCE_DIR}/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp + ${IE_MAIN_SOURCE_DIR}/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp LABELS VPU MYRIAD diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp index 8198792fd83..773419d78f1 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/config.cpp @@ -5,209 +5,353 @@ #include "vpu/vpu_plugin_config.hpp" #include "vpu/private_plugin_config.hpp" #include "behavior/config.hpp" +#include "myriad_devices.hpp" IE_SUPPRESS_DEPRECATED_START -using namespace BehaviorTestsDefinitions; namespace { - const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 + +using namespace BehaviorTestsDefinitions; +using namespace InferenceEngine::PluginConfigParams; + +const std::vector& getPrecisions() { + static const std::vector precisions = { + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP16, + }; + return precisions; +} + +std::vector> getCorrectConfigs() { + std::vector> correctConfigs = { + {{KEY_LOG_LEVEL, LOG_NONE}}, + {{KEY_LOG_LEVEL, LOG_ERROR}}, + {{KEY_LOG_LEVEL, LOG_WARNING}}, + {{KEY_LOG_LEVEL, LOG_INFO}}, + {{KEY_LOG_LEVEL, LOG_DEBUG}}, + {{KEY_LOG_LEVEL, LOG_TRACE}}, + + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(NO)}}, + + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(NO)}}, + + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-1"}}, + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "0"}}, + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}}, + + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(NO)}}, + + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}}, + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "2"}}, + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "3"}}, + + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(YES)}}, + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(NO)}}, + + // Deprecated + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_NONE}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_ERROR}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_WARNING}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_INFO}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_DEBUG}}, + {{VPU_CONFIG_KEY(LOG_LEVEL), LOG_TRACE}}, + + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(YES)}}, + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(NO)}}, + + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}}, + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(NO)}}, + + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(YES)}}, + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(NO)}}, + + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), VPU_MYRIAD_CONFIG_VALUE(2480)}}, + + { + {KEY_LOG_LEVEL, LOG_INFO}, + {InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::NO}, + {InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}, + {InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}, + {InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(YES)}, + }, }; - const std::vector> Configs = { - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, CONFIG_VALUE(NO)}}, + MyriadDevicesInfo info; + if (info.getAmountOfDevices(ncDeviceProtocol_t::NC_PCIE) > 0) { + correctConfigs.emplace_back(std::map{{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(PCIE)}}); + correctConfigs.emplace_back(std::map{{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_PCIE}}); + } - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_NONE)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_ERROR)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_WARNING)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_INFO)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_DEBUG)}}, - {{CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_TRACE)}}, + if (info.getAmountOfDevices(ncDeviceProtocol_t::NC_USB) > 0) { + correctConfigs.emplace_back(std::map{{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(USB)}}); + correctConfigs.emplace_back(std::map{{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_USB}}); + } - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(NO)}}, + return correctConfigs; +} - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-1"}}, - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "0"}}, - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}}, +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getCorrectConfigs())), + CorrectConfigTests::getTestCaseName); - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, CONFIG_VALUE(NO)}}, - {{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_USB}}, - {{InferenceEngine::MYRIAD_PROTOCOL, InferenceEngine::MYRIAD_PCIE}}, +const std::vector>& getCorrectMultiConfigs() { + static const std::vector> correctMultiConfigs = { + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {KEY_LOG_LEVEL, LOG_DEBUG}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::NO}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, YES}, + }, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}}, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "2"}}, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "3"}}, - - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(YES)}}, - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, CONFIG_VALUE(NO)}}, - - // Deprecated - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(YES)}}, - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), CONFIG_VALUE(NO)}}, - - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}}, - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(NO)}}, - - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(YES)}}, - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), CONFIG_VALUE(NO)}}, - - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(USB)}}, - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), VPU_MYRIAD_CONFIG_VALUE(PCIE)}}, - - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), VPU_MYRIAD_CONFIG_VALUE(2450)}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), VPU_MYRIAD_CONFIG_VALUE(2480)}} + // Deprecated + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(LOG_LEVEL), LOG_DEBUG}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}, + }, }; + return correctMultiConfigs; +} - const std::vector> MultiConfigs = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {CONFIG_KEY(LOG_LEVEL), CONFIG_VALUE(LOG_DEBUG)}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}}, +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getCorrectMultiConfigs())), + CorrectConfigTests::getTestCaseName); - // Deprecated - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), CONFIG_VALUE(YES)}} +const std::vector>& getDefaultEntries() { + static const std::vector> defaultEntries = { + {KEY_LOG_LEVEL, {LOG_NONE}}, }; + return defaultEntries; +} - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(Configs)), - CorrectConfigTests::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectSingleOptionDefaultValueConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getDefaultEntries()))); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(MultiConfigs)), - CorrectConfigTests::getTestCaseName); +const std::vector>& getCustomEntries() { + static const std::vector> customEntries = { + std::make_tuple(KEY_LOG_LEVEL, LOG_NONE, InferenceEngine::Parameter{LOG_NONE}), + std::make_tuple(KEY_LOG_LEVEL, LOG_ERROR, InferenceEngine::Parameter{LOG_ERROR}), + std::make_tuple(KEY_LOG_LEVEL, LOG_WARNING, InferenceEngine::Parameter{LOG_WARNING}), + std::make_tuple(KEY_LOG_LEVEL, LOG_INFO, InferenceEngine::Parameter{LOG_INFO}), + std::make_tuple(KEY_LOG_LEVEL, LOG_DEBUG, InferenceEngine::Parameter{LOG_DEBUG}), + std::make_tuple(KEY_LOG_LEVEL, LOG_TRACE, InferenceEngine::Parameter{LOG_TRACE}), - const std::vector> inconfigs = { - {{InferenceEngine::MYRIAD_PROTOCOL, "BLUETOOTH"}}, - {{InferenceEngine::MYRIAD_PROTOCOL, "LAN"}}, + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_NONE, InferenceEngine::Parameter{LOG_NONE}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_ERROR, InferenceEngine::Parameter{LOG_ERROR}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_WARNING, InferenceEngine::Parameter{LOG_WARNING}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_INFO, InferenceEngine::Parameter{LOG_INFO}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_DEBUG, InferenceEngine::Parameter{LOG_DEBUG}), + std::make_tuple(VPU_CONFIG_KEY(LOG_LEVEL), LOG_TRACE, InferenceEngine::Parameter{LOG_TRACE}), - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "OFF"}}, - - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "OFF"}}, - - {{CONFIG_KEY(LOG_LEVEL), "VERBOSE"}}, - - {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-10"}}, - - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "OFF"}}, - - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "Two"}}, - {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "SINGLE"}}, - - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "ON"}}, - {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "OFF"}}, - - // Deprecated - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "BLUETOOTH"}}, - {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "LAN"}}, - - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}}, - {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "OFF"}}, - - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "ON"}}, - {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "OFF"}}, - - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "ON"}}, - {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "OFF"}}, - - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}}, - {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}}, + std::make_tuple(InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::YES, InferenceEngine::Parameter{true}), + std::make_tuple(InferenceEngine::MYRIAD_COPY_OPTIMIZATION, InferenceEngine::PluginConfigParams::NO, InferenceEngine::Parameter{false}), }; + return customEntries; +} - const std::vector> multiinconfigs = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {CONFIG_KEY(LOG_LEVEL), "VERBOSE"}}, +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectSingleOptionCustomValueConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getCustomEntries()))); - // Deprecated - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}}, - - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}}, - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, - {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}}, +const std::vector& getPublicOptions() { + static const std::vector publicOptions = { + KEY_LOG_LEVEL, + VPU_CONFIG_KEY(LOG_LEVEL), }; + return publicOptions; +} - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(inconfigs)), - IncorrectConfigTests::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigPublicOptionsTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getPublicOptions()))); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(multiinconfigs)), - IncorrectConfigTests::getTestCaseName); - - - - const std::vector> Inconf = { - {{"some_nonexistent_key", "some_unknown_value"}} +const std::vector& getPrivateOptions() { + static const std::vector privateOptions = { + InferenceEngine::MYRIAD_COPY_OPTIMIZATION, }; + return privateOptions; +} - const std::vector> multiInconf = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_MYRIAD}, - {"some_nonexistent_key", "some_unknown_value"}} +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigPrivateOptionsTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getPrivateOptions()))); + +const std::vector>& getIncorrectConfigs() { + static const std::vector> incorrectConfigs = { + {{KEY_LOG_LEVEL, "INCORRECT_LOG_LEVEL"}}, + + {{InferenceEngine::MYRIAD_COPY_OPTIMIZATION, "ON"}}, + {{InferenceEngine::MYRIAD_COPY_OPTIMIZATION, "OFF"}}, + + {{InferenceEngine::MYRIAD_PROTOCOL, "BLUETOOTH"}}, + {{InferenceEngine::MYRIAD_PROTOCOL, "LAN"}}, + + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "OFF"}}, + + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "OFF"}}, + + {{InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "-10"}}, + + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_RECEIVING_TENSOR_TIME, "OFF"}}, + + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "Two"}}, + {{InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "SINGLE"}}, + + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "ON"}}, + {{InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "OFF"}}, + + // Deprecated + {{VPU_CONFIG_KEY(LOG_LEVEL), "INCORRECT_LOG_LEVEL"}}, + + {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "BLUETOOTH"}}, + {{VPU_MYRIAD_CONFIG_KEY(PROTOCOL), "LAN"}}, + + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}}, + {{VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "OFF"}}, + + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "ON"}}, + {{VPU_MYRIAD_CONFIG_KEY(FORCE_RESET), "OFF"}}, + + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "ON"}}, + {{VPU_CONFIG_KEY(PRINT_RECEIVE_TENSOR_TIME), "OFF"}}, + + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}}, + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}}, + {{VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}}, + + { + {KEY_LOG_LEVEL, LOG_INFO}, + {InferenceEngine::MYRIAD_COPY_OPTIMIZATION, "ON"}, + {InferenceEngine::MYRIAD_PROTOCOL, "BLUETOOTH"}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, CONFIG_VALUE(YES)}, + {InferenceEngine::MYRIAD_ENABLE_FORCE_RESET, "ON"}, + {InferenceEngine::MYRIAD_TILING_CMX_LIMIT_KB, "10"}, + {InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "OFF"}, + {InferenceEngine::MYRIAD_THROUGHPUT_STREAMS, "1"}, + {InferenceEngine::MYRIAD_ENABLE_WEIGHTS_ANALYSIS, "ON"}, + }, }; + return incorrectConfigs; +} +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::ValuesIn(getIncorrectConfigs())), + IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(Inconf)), - IncorrectConfigAPITests::getTestCaseName); +const std::vector>& getIncorrectMultiConfigs() { + static const std::vector> incorrectMultiConfigs = { + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {KEY_LOG_LEVEL, "INCORRECT_LOG_LEVEL"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {InferenceEngine::MYRIAD_ENABLE_HW_ACCELERATION, "ON"}, + }, - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(multiInconf)), - IncorrectConfigAPITests::getTestCaseName); - - - - - const std::vector> conf = { - {} + // Deprecated + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(LOG_LEVEL), "INCORRECT_LOG_LEVEL"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_CONFIG_KEY(HW_STAGES_OPTIMIZATION), "ON"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "-1"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "0"}, + }, + { + {InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES, CommonTestUtils::DEVICE_MYRIAD}, + {VPU_MYRIAD_CONFIG_KEY(PLATFORM), "1"}, + }, }; + return incorrectMultiConfigs; +} - const std::vector> multiconf = { - {{InferenceEngine::MultiDeviceConfigParams::KEY_MULTI_DEVICE_PRIORITIES , CommonTestUtils::DEVICE_MYRIAD}} - }; +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getIncorrectMultiConfigs())), + IncorrectConfigTests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), - ::testing::ValuesIn(conf)), - CorrectConfigAPITests::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigSingleOptionTests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values("INCORRECT_KEY"))); + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, CorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values(std::map{})), + CorrectConfigAPITests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getCorrectMultiConfigs())), + CorrectConfigAPITests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_BehaviorTests, IncorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values(std::map{{"INCORRECT_KEY", "INCORRECT_VALUE"}})), + IncorrectConfigAPITests::getTestCaseName); + +INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, IncorrectConfigAPITests, + ::testing::Combine( + ::testing::ValuesIn(getPrecisions()), + ::testing::Values(CommonTestUtils::DEVICE_MULTI), + ::testing::ValuesIn(getIncorrectMultiConfigs())), + IncorrectConfigAPITests::getTestCaseName); - INSTANTIATE_TEST_CASE_P(smoke_Multi_BehaviorTests, CorrectConfigAPITests, - ::testing::Combine( - ::testing::ValuesIn(netPrecisions), - ::testing::Values(CommonTestUtils::DEVICE_MULTI), - ::testing::ValuesIn(multiconf)), - CorrectConfigAPITests::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp b/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp index e21eb11624b..5705bdc8ae3 100644 --- a/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/base/behavior_test_utils.hpp @@ -27,11 +27,45 @@ #include "ngraph_functions/pass/convert_prc.hpp" namespace BehaviorTestsUtils { - typedef std::tuple< - InferenceEngine::Precision, // Network precision - std::string, // Device name - std::map // Config - > BehaviorParams; + +using BehaviorParamsEmptyConfig = std::tuple< + InferenceEngine::Precision, // Network precision + std::string // Device name +>; + +class BehaviorTestsEmptyConfig : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj) { + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::tie(netPrecision, targetDevice) = obj.param; + std::ostringstream result; + result << "netPRC=" << netPrecision.name() << "_"; + result << "targetDevice=" << targetDevice; + return result.str(); + } + + void SetUp() override { + std::tie(netPrecision, targetDevice) = this->GetParam(); + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; +}; + +typedef std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::map // Config +> BehaviorParams; class BehaviorTestsBasic : public testing::WithParamInterface, public CommonTestUtils::TestsCommon { @@ -71,4 +105,86 @@ public: std::map configuration; }; +using BehaviorParamsSingleOption = std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::string // Key +>; + +class BehaviorTestsSingleOption : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + void SetUp() override { + std::tie(netPrecision, targetDevice, key) = this->GetParam(); + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::string key; +}; + +using BehaviorParamsSingleOptionDefault = std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::pair // Configuration key and its default value +>; + +class BehaviorTestsSingleOptionDefault : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + void SetUp() override { + std::pair entry; + std::tie(netPrecision, targetDevice, entry) = this->GetParam(); + std::tie(key, value) = entry; + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::string key; + InferenceEngine::Parameter value; +}; + +using BehaviorParamsSingleOptionCustom = std::tuple< + InferenceEngine::Precision, // Network precision + std::string, // Device name + std::tuple // Configuration key, value and reference +>; + +class BehaviorTestsSingleOptionCustom : public testing::WithParamInterface, + public CommonTestUtils::TestsCommon { +public: + void SetUp() override { + std::tuple entry; + std::tie(netPrecision, targetDevice, entry) = this->GetParam(); + std::tie(key, value, reference) = entry; + function = ngraph::builder::subgraph::makeConvPoolRelu(); + } + + void TearDown() override { + function.reset(); + } + + std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr function; + InferenceEngine::Precision netPrecision; + std::string targetDevice; + std::string key; + std::string value; + InferenceEngine::Parameter reference; +}; + } // namespace BehaviorTestsUtils diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp index e13fe679b2a..efdd24187ae 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/config.hpp @@ -27,9 +27,11 @@ #include "ngraph_functions/subgraph_builders.hpp" namespace BehaviorTestsDefinitions { - using CorrectConfigTests = BehaviorTestsUtils::BehaviorTestsBasic; + + using EmptyConfigTests = BehaviorTestsUtils::BehaviorTestsEmptyConfig; + // Setting empty config doesn't throw - TEST_P(CorrectConfigTests, SetEmptyConfig) { + TEST_P(EmptyConfigTests, SetEmptyConfig) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -39,6 +41,29 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(config, targetDevice)); } + TEST_P(EmptyConfigTests, CanLoadNetworkWithEmptyConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + std::map config; + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + ASSERT_NO_THROW(ie->LoadNetwork(cnnNet, targetDevice, config)); + } + + using CorrectSingleOptionDefaultValueConfigTests = BehaviorTestsUtils::BehaviorTestsSingleOptionDefault; + + TEST_P(CorrectSingleOptionDefaultValueConfigTests, CheckDefaultValueOfConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + ASSERT_EQ(ie->GetConfig(targetDevice, key), value); + } + + using CorrectConfigTests = BehaviorTestsUtils::BehaviorTestsBasic; + // Setting correct config doesn't throw TEST_P(CorrectConfigTests, SetCorrectConfig) { // Skip test according to plugin specific disabledTestPatterns() (if any) @@ -49,6 +74,53 @@ namespace BehaviorTestsDefinitions { ASSERT_NO_THROW(ie->SetConfig(configuration, targetDevice)); } + TEST_P(CorrectConfigTests, CanLoadNetworkWithCorrectConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->LoadNetwork(cnnNet, targetDevice, configuration)); + } + + using CorrectSingleOptionCustomValueConfigTests = BehaviorTestsUtils::BehaviorTestsSingleOptionCustom; + + TEST_P(CorrectSingleOptionCustomValueConfigTests, CheckCustomValueOfConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + std::map configuration = {{key, value}}; + ASSERT_NO_THROW(ie->SetConfig(configuration, targetDevice)); + ASSERT_EQ(ie->GetConfig(targetDevice, key), reference); + } + + using CorrectConfigPublicOptionsTests = BehaviorTestsUtils::BehaviorTestsSingleOption; + + TEST_P(CorrectConfigPublicOptionsTests, CanSeePublicOption) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + InferenceEngine::Parameter metric; + ASSERT_NO_THROW(metric = ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + const auto& supportedOptions = metric.as>(); + ASSERT_NE(std::find(supportedOptions.cbegin(), supportedOptions.cend(), key), supportedOptions.cend()); + } + + using CorrectConfigPrivateOptionsTests = BehaviorTestsUtils::BehaviorTestsSingleOption; + + TEST_P(CorrectConfigPrivateOptionsTests, CanNotSeePrivateOption) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + InferenceEngine::Parameter metric; + ASSERT_NO_THROW(metric = ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + const auto& supportedOptions = metric.as>(); + ASSERT_EQ(std::find(supportedOptions.cbegin(), supportedOptions.cend(), key), supportedOptions.cend()); + } + using IncorrectConfigTests = BehaviorTestsUtils::BehaviorTestsBasic; TEST_P(IncorrectConfigTests, SetConfigWithIncorrectKey) { @@ -67,7 +139,7 @@ namespace BehaviorTestsDefinitions { } } - TEST_P(IncorrectConfigTests, canNotLoadNetworkWithIncorrectConfig) { + TEST_P(IncorrectConfigTests, CanNotLoadNetworkWithIncorrectConfig) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -80,6 +152,17 @@ namespace BehaviorTestsDefinitions { } } + using IncorrectConfigSingleOptionTests = BehaviorTestsUtils::BehaviorTestsSingleOption; + + TEST_P(IncorrectConfigSingleOptionTests, CanNotGetConfigWithIncorrectConfig) { + // Skip test according to plugin specific disabledTestPatterns() (if any) + SKIP_IF_CURRENT_TEST_IS_DISABLED() + // Create CNNNetwork from ngrpah::Function + InferenceEngine::CNNNetwork cnnNet(function); + ASSERT_NO_THROW(ie->GetMetric(targetDevice, METRIC_KEY(SUPPORTED_CONFIG_KEYS))); + ASSERT_THROW(ie->GetConfig(targetDevice, key), InferenceEngine::Exception); + } + using IncorrectConfigAPITests = BehaviorTestsUtils::BehaviorTestsBasic; TEST_P(IncorrectConfigAPITests, SetConfigWithNoExistingKey) { @@ -99,7 +182,7 @@ namespace BehaviorTestsDefinitions { using CorrectConfigAPITests = BehaviorTestsUtils::BehaviorTestsBasic; - TEST_P(CorrectConfigAPITests, canSetExclusiveAsyncRequests) { + TEST_P(CorrectConfigAPITests, CanSetExclusiveAsyncRequests) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -130,7 +213,7 @@ namespace BehaviorTestsDefinitions { } } - TEST_P(CorrectConfigAPITests, withoutExclusiveAsyncRequests) { + TEST_P(CorrectConfigAPITests, WithoutExclusiveAsyncRequests) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() // Create CNNNetwork from ngrpah::Function @@ -159,7 +242,7 @@ namespace BehaviorTestsDefinitions { } } - TEST_P(CorrectConfigAPITests, reusableCPUStreamsExecutor) { + TEST_P(CorrectConfigAPITests, ReusableCPUStreamsExecutor) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getExecutorsNumber()); @@ -200,4 +283,4 @@ namespace BehaviorTestsDefinitions { ASSERT_EQ(0u, InferenceEngine::ExecutorManager::getInstance()->getIdleCPUStreamsExecutorsNumber()); } } -} // namespace BehaviorTestsDefinitions \ No newline at end of file +} // namespace BehaviorTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp index b02dc5b86b7..729dfdb4e50 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/concat_quantization_during_memory_requantization.cpp @@ -104,11 +104,11 @@ namespace SubgraphTestsDefinitions { for (auto& state : states) { auto name = state.GetName(); if (name == "memory_1") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), memory_1_init.data(), memory_1_init.size()); state.SetState(blob); } else if (name == "memory_2") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), memory_2_init.data(), memory_2_init.size()); state.SetState(blob); } else { diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp index bac0c293add..29177461671 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/memory_LSTMCell.cpp @@ -280,11 +280,11 @@ namespace SubgraphTestsDefinitions { for (auto& state : states) { auto name = state.GetName(); if (name.find("cell_state_1") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), cell_memory_init.data(), cell_memory_init.size()); state.SetState(blob); } else if (name.find("hidden_state_1") != std::string::npos) { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), hidden_memory_init.data(), hidden_memory_init.size()); state.SetState(blob); } else { diff --git a/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp b/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp index c11eff780f7..9375b7b6baf 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/subgraph/negative_memory_layer_offset.cpp @@ -77,7 +77,7 @@ namespace SubgraphTestsDefinitions { for (auto& state : states) { auto name = state.GetName(); if (name == "memory") { - auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetLastState()->getTensorDesc(), + auto blob = FuncTestUtils::createAndFillBlobWithFloatArray(state.GetState()->getTensorDesc(), memory_init.data(), memory_init.size()); state.SetState(blob); } else { diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp b/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp index 68d3af73a39..dbd552d6da8 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/data_utils.cpp @@ -9,6 +9,8 @@ #include #include +using namespace InferenceEngine::details; + namespace CommonTestUtils { bool isDenseBlob(const InferenceEngine::Blob::Ptr& blob) { @@ -69,8 +71,8 @@ void fill_data_with_broadcast(InferenceEngine::Blob::Ptr& blob, InferenceEngine: if (src_dims[i] != dst_dims[i] && src_dims[i] != 1) compatible = false; } - IE_ASSERT(compatible) << "fill_data_with_broadcast error: Tensor shape " << values_dims - << " can not be broadcasted to shape " << blob_dims; + + IE_ASSERT(compatible); auto fill_strides_like_plain = [] (SizeVector dims) { SizeVector str(dims.size()); diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp index eee6e9613c8..3d0ec47531d 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp @@ -803,6 +803,8 @@ void ReadAndStoreAttributes::on_adapter(const std::string& name, ngraph::ValueAc insert(name, storage::MemoryChunk{storage::MemoryChunk::Data(beg, end)}); } else if (auto framework_node_attr = ngraph::as_type>(&adapter)) { insert(name, framework_node_attr->get()); + } else if (auto variable_ptr = ngraph::as_type>>(&adapter)) { + insert(name, variable_ptr->get()); } else { m_read_result += "store attr [ ERR ]: " + name + " [drop `void` comparison which is '" + adapter.get_type_info().name + @@ -882,6 +884,8 @@ void ReadAndCompareAttributes::verify_others(const std::string &name, ngraph::Va verify_mem_buf(name, a->get()); } else if (auto attrs = ngraph::as_type>(&adapter)) { verify(name, attrs->get()); + } else if (auto variable_ptr = ngraph::as_type>>(&adapter)) { + verify(name, variable_ptr->get()); } else { m_cmp_result += "compare attr [ ERR ]: " + name + " [drop `void` comparison which is '" + adapter.get_type_info().name + diff --git a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp index 5e7220b7872..ab636060af1 100644 --- a/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp +++ b/inference-engine/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp @@ -322,7 +322,8 @@ class Storage : private AttributeStorage, private AttributeStorage>, private AttributeStorage, private AttributeStorage, - private AttributeStorage { + private AttributeStorage, + private AttributeStorage> { public: template const AttributeStorage& storage() const { @@ -361,7 +362,8 @@ public: storage>().get_attributes_number() + storage().get_attributes_number() + storage().get_attributes_number() + - storage().get_attributes_number(); + storage().get_attributes_number() + + storage>().get_attributes_number(); } }; @@ -562,6 +564,14 @@ struct Equal { } }; +template <> +struct Equal> { + static bool equal_value( + const std::shared_ptr& lhs, const std::shared_ptr& rhs) { + return lhs->get_info() == rhs->get_info(); + } +}; + template <> struct Equal { static constexpr uint8_t BITS_IN_BYTE_COUNT = 8; @@ -705,6 +715,19 @@ struct Get { } }; +template <> +struct Get, void> { + static std::string value(const std::shared_ptr& variable) { + std::stringstream oss; + const auto variable_info = variable->get_info(); + oss << "["; + oss << "data_shape=" << variable_info.data_shape << ", "; + oss << "data_type=" << variable_info.data_type << ", "; + oss << "variable_id=" << variable_info.variable_id; + oss << "]"; + return oss.str(); + } +}; } // namespace str diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 8309b0e8593..7db26eb2895 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -13,6 +13,7 @@ VERIFIED_OP_REFERENCES = [ 'Broadcast-1', 'Broadcast-3', 'Bucketize-3', + 'Ceiling-1', 'CTCGreedyDecoder-1', 'CTCGreedyDecoderSeqLen-6', 'Concat-1', @@ -94,5 +95,6 @@ VERIFIED_OP_REFERENCES = [ 'TopK-1', 'TopK-3', 'Transpose-1', - 'Unsqueeze-1' + 'Unsqueeze-1', + 'VariadicSplit-1', ] diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp index 676bf59b340..980044f8d02 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp @@ -4,7 +4,6 @@ #include "unit_test_utils/mocks/mock_allocator.hpp" #include "unit_test_utils/mocks/mock_icnn_network.hpp" -#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp" #include "unit_test_utils/mocks/mock_iexecutable_network.hpp" #include "unit_test_utils/mocks/mock_iinfer_request.hpp" #include "unit_test_utils/mocks/mock_not_empty_icnn_network.hpp" diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp deleted file mode 100644 index eac6fcbfa3f..00000000000 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_ie_ivariable_state.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ie_imemory_state.hpp" - -using namespace InferenceEngine; - -IE_SUPPRESS_DEPRECATED_START - -class MockIVariableState : public InferenceEngine::IVariableState { -public: - MOCK_QUALIFIED_METHOD3(GetName, const noexcept, StatusCode(char * , size_t, ResponseDesc *)); - MOCK_QUALIFIED_METHOD1(Reset, noexcept, StatusCode(ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(SetState, noexcept, StatusCode(Blob::Ptr, ResponseDesc *)); - MOCK_QUALIFIED_METHOD2(GetState, const noexcept, StatusCode(Blob::CPtr &, ResponseDesc *)); -}; - -IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp index 147ee892a8f..a5187953206 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iexecutable_network.hpp @@ -32,7 +32,6 @@ public: MOCK_QUALIFIED_METHOD3(GetConfig, const noexcept, StatusCode(const std::string &name, Parameter &result, ResponseDesc *resp)); MOCK_QUALIFIED_METHOD3(GetMetric, const noexcept, StatusCode(const std::string &name, Parameter &result, ResponseDesc *resp)); MOCK_QUALIFIED_METHOD2(GetContext, const noexcept, StatusCode(RemoteContext::Ptr &pContext, ResponseDesc *resp)); - MOCK_QUALIFIED_METHOD3(QueryState, noexcept, StatusCode(IVariableState::Ptr &, size_t, ResponseDesc *)); }; IE_SUPPRESS_DEPRECATED_END diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp index a56ad790a97..bac5fc7773e 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_iinfer_request.hpp @@ -35,7 +35,6 @@ public: MOCK_QUALIFIED_METHOD3(SetBlob, noexcept, StatusCode(const char*, const Blob::Ptr&, ResponseDesc*)); MOCK_QUALIFIED_METHOD4(SetBlob, noexcept, StatusCode(const char*, const Blob::Ptr&, const PreProcessInfo&, ResponseDesc*)); MOCK_QUALIFIED_METHOD2(SetBatch, noexcept, StatusCode(int batch, ResponseDesc*)); - MOCK_QUALIFIED_METHOD3(QueryState, noexcept, StatusCode(IVariableState::Ptr &, size_t, ResponseDesc *)); MOCK_QUALIFIED_METHOD1(Cancel, noexcept, InferenceEngine::StatusCode(ResponseDesc*)); }; diff --git a/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp b/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp index bdfd50ba037..7fa12a42825 100644 --- a/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp +++ b/inference-engine/tests/unit/gna/gna_plugin_config_test.cpp @@ -107,6 +107,11 @@ TEST_F(GNAPluginConfigTest, GnaConfigDeviceModeTest) { #else EXPECT_EQ(config.pluginGna2AccMode, Gna2AccelerationModeHardware); EXPECT_EQ(config.swExactMode, false); +#endif +#if GNA_LIB_VER == 2 + SetAndCompare(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_HW_WITH_SW_FBACK); + EXPECT_EQ(config.pluginGna2AccMode, Gna2AccelerationModeHardwareWithSoftwareFallback); + EXPECT_EQ(config.swExactMode, false); #endif SetAndCompare(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_SW); #if GNA_LIB_VER == 1 diff --git a/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp b/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp index 2c35e8652df..998620c026d 100644 --- a/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp +++ b/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp @@ -13,7 +13,6 @@ #include "unit_test_utils/mocks/mock_iexecutable_network.hpp" #include "unit_test_utils/mocks/mock_iinfer_request.hpp" -#include "unit_test_utils/mocks/mock_ie_ivariable_state.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" diff --git a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp index 5f018914a5e..52ff0425928 100644 --- a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp +++ b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.cpp @@ -6,6 +6,9 @@ #include +#include +#include + #include #include @@ -287,6 +290,8 @@ void GraphTransformerTest::SetUp() { frontEnd = std::make_shared(stageBuilder, &_mockCore); backEnd = std::make_shared(); passManager = std::make_shared(stageBuilder, backEnd); + + config = createConfiguration(); } void GraphTransformerTest::TearDown() { @@ -301,13 +306,13 @@ void GraphTransformerTest::TearDown() { void GraphTransformerTest::InitCompileEnv() { if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_FILE_NAME")) { - config.dumpInternalGraphFileName = envVar; + config.compileConfig().dumpInternalGraphFileName = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_DIRECTORY")) { - config.dumpInternalGraphDirectory = envVar; + config.compileConfig().dumpInternalGraphDirectory = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_ALL_PASSES")) { - config.dumpAllPasses = std::stoi(envVar) != 0; + config.compileConfig().dumpAllPasses = std::stoi(envVar) != 0; } CompileEnv::init(platform, config, _log); @@ -342,4 +347,16 @@ TestModel GraphTransformerTest::CreateTestModel() { return TestModel(CreateModel()); } +PluginConfiguration createConfiguration() { + PluginConfiguration configuration; + configuration.registerOption(); + configuration.registerOption(); + +IE_SUPPRESS_DEPRECATED_START + configuration.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END + + return configuration; +} + } // namespace vpu diff --git a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp index ea2fa0de07b..fd007cca4f4 100644 --- a/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp +++ b/inference-engine/tests/unit/vpu/base/graph_transformer_tests.hpp @@ -130,10 +130,12 @@ void checkStageTestInds(const StageRange& stageRange, std::initializer_list bool checkExecutionOrder(const Model& model, const std::vector& execOrder); +PluginConfiguration createConfiguration(); + class GraphTransformerTest : public ::testing::Test { public: - Platform platform = Platform::MYRIAD_X; - CompilationConfig config; + ncDevicePlatform_t platform = ncDevicePlatform_t::NC_MYRIAD_X; + PluginConfiguration config; StageBuilder::Ptr stageBuilder; FrontEnd::Ptr frontEnd; diff --git a/inference-engine/tests/unit/vpu/blob_reader_tests.cpp b/inference-engine/tests/unit/vpu/blob_reader_tests.cpp index 91115fc522a..0092c540885 100644 --- a/inference-engine/tests/unit/vpu/blob_reader_tests.cpp +++ b/inference-engine/tests/unit/vpu/blob_reader_tests.cpp @@ -12,6 +12,8 @@ #include #include +#include "graph_transformer_tests.hpp" + #include #include @@ -48,9 +50,8 @@ public: auto fn_ptr = ngraph::builder::subgraph::makeSplitConvConcat(); ASSERT_NO_THROW(_network = InferenceEngine::CNNNetwork(fn_ptr)); - CompilationConfig compileConfig; auto log = std::make_shared("GraphCompiler", LogLevel::None, consoleOutput()); - _compiledGraph = compileNetwork(_network, Platform::MYRIAD_X, compileConfig, log, &_mockCore); + _compiledGraph = compileNetwork(_network, ncDevicePlatform_t::NC_MYRIAD_X, createConfiguration(), log, &_mockCore); } CNNNetwork _network; diff --git a/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp b/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp index f1f841101c5..14e73c28cc7 100644 --- a/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp +++ b/inference-engine/tests/unit/vpu/middleend_tests/passes_tests/annotate_memory_types.cpp @@ -24,7 +24,7 @@ class AnnotateMemoryTypes : public GraphTransformerTest, public testing::WithPar protected: void SetUp() override { ASSERT_NO_FATAL_FAILURE(GraphTransformerTest::SetUp()); - config.enableMemoryTypesAnnotation = true; + config.compileConfig().enableMemoryTypesAnnotation = true; ASSERT_NO_FATAL_FAILURE(InitCompileEnv()); ASSERT_NO_FATAL_FAILURE(InitPipeline()); diff --git a/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h b/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h index ef1b9e30811..e5c4c17679e 100644 --- a/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h +++ b/inference-engine/tests_deprecated/behavior/shared_tests/plugin_tests/behavior_test_plugin.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -111,4 +110,4 @@ const TestModel convReluNormPoolFcModelQ78 = getConvReluNormPoolFcModel(Inferenc class FPGAHangingTest : public BehaviorPluginTest { }; -#endif \ No newline at end of file +#endif diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp index d5adac10397..5016a4a3b9d 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.cpp @@ -30,7 +30,6 @@ std::vector MyriadDevicesInfo::getDevicesList( const ncDeviceProtocol_t deviceProtocol, const ncDevicePlatform_t devicePlatform, const XLinkDeviceState_t state) { - deviceDesc_t req_deviceDesc = {}; req_deviceDesc.protocol = convertProtocolToXlink(deviceProtocol); req_deviceDesc.platform = convertPlatformToXlink(devicePlatform); diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp index a5628fcd0e6..ed9265f868c 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_devices.hpp @@ -30,8 +30,7 @@ public: std::vector getDevicesList( const ncDeviceProtocol_t deviceProtocol = NC_ANY_PROTOCOL, const ncDevicePlatform_t devicePlatform = NC_ANY_PLATFORM, - const XLinkDeviceState_t state = X_LINK_ANY_STATE - ); + const XLinkDeviceState_t state = X_LINK_ANY_STATE); inline bool isMyriadXDevice(const std::string &device_name); inline bool isMyriad2Device(const std::string &device_name); @@ -77,4 +76,4 @@ long MyriadDevicesInfo::getAmountOfUnbootedDevices(const ncDeviceProtocol_t devi long MyriadDevicesInfo::getAmountOfBootedDevices(const ncDeviceProtocol_t deviceProtocol) { return getAmountOfDevices(deviceProtocol, NC_ANY_PLATFORM, X_LINK_BOOTED); -} \ No newline at end of file +} diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp index 48c8a413b84..a6b77a6b523 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/helpers/myriad_protocol_case.cpp @@ -4,6 +4,7 @@ #include "myriad_protocol_case.hpp" #include "mvnc_ext.h" +#include "vpu/myriad_config.hpp" void MyriadProtocolTests::SetUp() { protocol = GetParam(); diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp index c2ecf468b46..f55dd044735 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp @@ -15,6 +15,7 @@ #include "helpers/myriad_devices.hpp" #include +#include using namespace std; using namespace ::testing; diff --git a/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp b/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp index b1bb32646b6..6a1ab38d36a 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp +++ b/inference-engine/tests_deprecated/behavior/vpu/shared_tests_instances/plugin_tests/vpu_test_data.hpp @@ -3,6 +3,7 @@ // #include "behavior_test_plugin.h" +#include "vpu/myriad_config.hpp" // correct params #define BEH_MYRIAD BehTestParams("MYRIAD", \ diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp index fc210dee5b7..7a2c027be03 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_blob_test.cpp @@ -169,10 +169,15 @@ TEST_F(myriadConfigsWithBlobImportTests_smoke, TryingToSetCompileOptionPrintsWar std::string content = redirectCoutStream.str(); for (auto &&elem : config) { + // TODO: remove once all options are migrated + std::stringstream deprecatedExpectedMsgStream; + deprecatedExpectedMsgStream << "[Warning][VPU][Config] " << elem.first; + const auto& deprecatedMsg = deprecatedExpectedMsgStream.str(); + std::stringstream expectedMsgStream; - expectedMsgStream << "[Warning][VPU][Config] " << elem.first; - std::string msg = expectedMsgStream.str(); - ASSERT_TRUE(content.find(msg) != std::string::npos) << msg; + expectedMsgStream << "[Warning][VPU][Configuration] Configuration option \"" << elem.first; + const auto& msg = expectedMsgStream.str(); + ASSERT_TRUE(content.find(msg) != std::string::npos || content.find(deprecatedMsg) != std::string::npos) << msg; } } diff --git a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp index 775708c6389..5d6074334f8 100644 --- a/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/common/layers/myriad_layers_concat_test.hpp @@ -5,6 +5,7 @@ #include "myriad_layers_tests.hpp" using namespace InferenceEngine; +using namespace InferenceEngine::details; using myriadConcatTestParams = std::tuple; typedef myriadLayerTestBaseWithParam myriadLayersTestsConcat_smoke; diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp index b5c98e0b368..ca07c26f03a 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include using namespace InferenceEngine; using namespace vpu; @@ -19,12 +21,12 @@ void graphTransformerFunctionalTests::SetUp() { vpuLayersTests::SetUp(); _stageBuilder = std::make_shared(); - _platform = CheckMyriadX() ? Platform::MYRIAD_X : Platform::MYRIAD_2; + _platform = CheckMyriadX() ? ncDevicePlatform_t::NC_MYRIAD_X : ncDevicePlatform_t::NC_MYRIAD_2; } void graphTransformerFunctionalTests::CreateModel() { const auto compilerLog = std::make_shared("Test", LogLevel::Info, consoleOutput()); - CompileEnv::init(_platform, _compilationConfig, compilerLog); + CompileEnv::init(_platform, _configuration, compilerLog); AutoScope autoDeinit([] { CompileEnv::free(); }); @@ -43,7 +45,13 @@ void graphTransformerFunctionalTests::CreateModel() { void graphTransformerFunctionalTests::PrepareGraphCompilation() { SetSeed(DEFAULT_SEED_VALUE); - _compilationConfig = CompilationConfig(); + + _configuration.registerOption(); + _configuration.registerOption(); +IE_SUPPRESS_DEPRECATED_START + _configuration.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END + _inputsInfo.clear(); _outputsInfo.clear(); _inputMap.clear(); @@ -87,7 +95,7 @@ int64_t graphTransformerFunctionalTests::CompileAndInfer(Blob::Ptr& inputBlob, B auto compiledGraph = compileModel( _gtModel, _platform, - _compilationConfig, + _configuration, compilerLog); std::istringstream instream(std::string(compiledGraph->blob.data(), compiledGraph->blob.size())); diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp index 155b9f21ea3..ff3063b217f 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/gt_functional_tests.hpp @@ -25,12 +25,12 @@ protected: bool lockLayout = false); protected: - vpu::ModelPtr _gtModel; - vpu::CompilationConfig _compilationConfig; - vpu::StageBuilder::Ptr _stageBuilder; - vpu::Data _dataIntermediate; + vpu::ModelPtr _gtModel; + vpu::PluginConfiguration _configuration; + vpu::StageBuilder::Ptr _stageBuilder; + vpu::Data _dataIntermediate; private: - vpu::Platform _platform = vpu::Platform::MYRIAD_X; + ncDevicePlatform_t _platform = ncDevicePlatform_t::NC_MYRIAD_X; InferenceEngine::ExecutableNetwork _executableNetwork; }; diff --git a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp index abcf7b062c6..ec6332dcc98 100644 --- a/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp +++ b/inference-engine/tests_deprecated/functional/vpu/graph_transformer/merge_permute_and_reorder_test.cpp @@ -62,8 +62,8 @@ protected: const bool usePermuteMerging, Blob::Ptr& outputBlob) { PrepareGraphCompilation(); - _compilationConfig.detectBatch = false; - _compilationConfig.enablePermuteMerging = usePermuteMerging; + _configuration.compileConfig().detectBatch = false; + _configuration.compileConfig().enablePermuteMerging = usePermuteMerging; IE_ASSERT(permutationVectors.size() >= 2); diff --git a/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp b/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp index 12417a62a00..5cfc76f825b 100644 --- a/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp +++ b/inference-engine/tests_deprecated/helpers/tests_vpu_common.hpp @@ -13,7 +13,7 @@ #include "single_layer_common.hpp" #include "vpu/vpu_plugin_config.hpp" -#include +#include using config_t = std::map; diff --git a/inference-engine/tests_deprecated/unit/CMakeLists.txt b/inference-engine/tests_deprecated/unit/CMakeLists.txt index 18d7724add5..c222e01f2b3 100644 --- a/inference-engine/tests_deprecated/unit/CMakeLists.txt +++ b/inference-engine/tests_deprecated/unit/CMakeLists.txt @@ -63,6 +63,7 @@ if (ENABLE_MYRIAD) engines/vpu/myriad_tests/helpers/*cpp engines/vpu/myriad_tests/helpers/*h ${IE_MAIN_SOURCE_DIR}/src/vpu/myriad_plugin/*.cpp + ${IE_MAIN_SOURCE_DIR}/src/vpu/myriad_plugin/configuration/*.cpp ) include_directories( engines/vpu/myriad_tests/helpers diff --git a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp index ee3b84c8c83..603efb6578e 100644 --- a/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp +++ b/inference-engine/tests_deprecated/unit/engines/gna/layers/gna_squeeze_test.cpp @@ -12,6 +12,8 @@ #include #include "../gna_matcher.hpp" +using namespace InferenceEngine::details; + typedef struct { std::vector input_shape; std::vector squeeze_indices; diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp index 5e5ebf29082..77ce658129f 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/adjust_data_location_tests.cpp @@ -25,8 +25,8 @@ using VPU_AdjustDataLocationTest = GraphTransformerTest; // TEST_F(VPU_AdjustDataLocationTest, FlushCMX_TwoSpecialConsumers) { - config.numSHAVEs = 1; - config.numCMXSlices = 1; + config.compileConfig().numSHAVEs = 1; + config.compileConfig().numCMXSlices = 1; InitCompileEnv(); DataDesc dataDesc1(DataType::FP16, DimsOrder::NCHW, {CMX_SLICE_SIZE / (2 * 2), 1, 2, 1}); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp index aac3ac3ee97..d0c2855f679 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/get_vpu_scale_from_ir_tests.cpp @@ -24,8 +24,8 @@ TEST_F(VPU_AddVpuScaleTest, CanAddVpuScaleToNetwork) { InitCompileEnv(); auto& env = CompileEnv::get(); - CompilationConfig config{}; - config.irWithVpuScalesDir = "/"; + auto config = createConfiguration(); + config.compileConfig().irWithVpuScalesDir = "/"; env.updateConfig(config); std::shared_ptr function; @@ -69,8 +69,8 @@ TEST_F(VPU_AddVpuScaleTest, CanAddVpuScaleToNetwork) { TEST_F(VPU_AddVpuScaleTest, VpuScaleFromIrChangesWeights) { InitCompileEnv(); const auto& env = CompileEnv::get(); - CompilationConfig config{}; - config.irWithVpuScalesDir = "/"; + auto config = createConfiguration(); + config.compileConfig().irWithVpuScalesDir = "/"; env.updateConfig(config); std::shared_ptr function; diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp index cd4b1619bdf..d0cd3a315cc 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.cpp @@ -8,6 +8,8 @@ #include #include +#include +#include namespace vpu { @@ -158,6 +160,18 @@ void TestModel::setStageBatchInfo( } } +PluginConfiguration createConfiguration() { + PluginConfiguration configuration; + configuration.registerOption(); + configuration.registerOption(); + +IE_SUPPRESS_DEPRECATED_START + configuration.registerDeprecatedOption(VPU_CONFIG_KEY(LOG_LEVEL)); +IE_SUPPRESS_DEPRECATED_END + + return configuration; +} + void GraphTransformerTest::SetUp() { ASSERT_NO_FATAL_FAILURE(TestsCommon::SetUp()); @@ -170,6 +184,8 @@ void GraphTransformerTest::SetUp() { frontEnd = std::make_shared(stageBuilder, &_mockCore); backEnd = std::make_shared(); passManager = std::make_shared(stageBuilder, backEnd); + + config = createConfiguration(); } void GraphTransformerTest::TearDown() { @@ -186,13 +202,13 @@ void GraphTransformerTest::TearDown() { void GraphTransformerTest::InitCompileEnv() { if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_FILE_NAME")) { - config.dumpInternalGraphFileName = envVar; + config.compileConfig().dumpInternalGraphFileName = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_INTERNAL_GRAPH_DIRECTORY")) { - config.dumpInternalGraphDirectory = envVar; + config.compileConfig().dumpInternalGraphDirectory = envVar; } if (const auto envVar = std::getenv("IE_VPU_DUMP_ALL_PASSES")) { - config.dumpAllPasses = std::stoi(envVar) != 0; + config.compileConfig().dumpAllPasses = std::stoi(envVar) != 0; } CompileEnv::init(platform, config, _log); diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp index dc9768ea529..6a656bc94d2 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/graph_transformer_tests.hpp @@ -176,10 +176,12 @@ void CheckStageTestInds(const StageRange& stageRange, std::initializer_list } } +PluginConfiguration createConfiguration(); + class GraphTransformerTest : public TestsCommon { public: - Platform platform = Platform::MYRIAD_X; - CompilationConfig config; + ncDevicePlatform_t platform = ncDevicePlatform_t::NC_MYRIAD_X; + PluginConfiguration config; StageBuilder::Ptr stageBuilder; FrontEnd::Ptr frontEnd; diff --git a/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp b/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp index ef18901be41..59e9c77dadc 100644 --- a/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp +++ b/inference-engine/tests_deprecated/unit/engines/vpu/replace_deconv_by_conv_tests.cpp @@ -91,7 +91,7 @@ TEST_F(VPU_ReplaceDeconvByConvTest, deconvReplacedByConvIfKernelSizeFitsHWUnit) } TEST_F(VPU_ReplaceDeconvByConvTest, deconvCannotBeReplacedByConvIfDisabledInConfig) { - config.hwBlackList.insert("deconv"); + config.compileConfig().hwBlackList.insert("deconv"); InitCompileEnv(); InitDeconvStage(16, 15); diff --git a/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp b/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp index 36990430195..01fb9f61163 100644 --- a/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp +++ b/inference-engine/tests_deprecated/unit/inference_engine_tests/get_num_iterations_test.cpp @@ -10,6 +10,8 @@ namespace { +using InferenceEngine::details::operator<<; + struct From { explicit From(int new_value) : value(new_value) {} int value; diff --git a/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt b/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt index 6e7f904227a..9b365d8da39 100644 --- a/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt +++ b/inference-engine/thirdparty/movidius/XLink/CMakeLists.txt @@ -40,3 +40,6 @@ if (ENABLE_MYRIAD_NO_BOOT) endif() set_property(TARGET ${TARGET_NAME} PROPERTY C_STANDARD 99) + +# TODO: remove once all options are migrated +ie_developer_export_targets(${TARGET_NAME}) diff --git a/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt b/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt index 37fd33e136b..31a22c74035 100644 --- a/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt +++ b/inference-engine/thirdparty/movidius/mvnc/CMakeLists.txt @@ -71,6 +71,9 @@ if(NOT WIN32) ${LIBUSB_LIBRARY}) endif() +# TODO: remove once all options are migrated +ie_developer_export_targets(${TARGET_NAME}) + if(ENABLE_TESTS AND ENABLE_MYRIAD_MVNC_TESTS) add_subdirectory(tests) endif() diff --git a/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp b/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp index 0f7b69d1b49..1a3bca457f9 100644 --- a/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp +++ b/inference-engine/thirdparty/movidius/mvnc/tests/mvnc_tests_common.cpp @@ -300,7 +300,6 @@ TEST_P(MvncOpenDevice, WatchdogShouldResetDeviceWithoutConnection) { if (availableDevices_ == 0) GTEST_SKIP() << ncProtocolToStr(_deviceProtocol) << " devices not found"; - ncDeviceHandle_t* deviceHandle = nullptr; std::string deviceName; deviceDesc_t deviceDescToBoot = {}; deviceDesc_t in_deviceDesc = {}; diff --git a/model-optimizer/automation/package_BOM.txt b/model-optimizer/automation/package_BOM.txt index e7c779543cd..668eb02325f 100644 --- a/model-optimizer/automation/package_BOM.txt +++ b/model-optimizer/automation/package_BOM.txt @@ -134,6 +134,8 @@ extensions/front/caffe/split_to_identity.py extensions/front/caffe/tanh.py extensions/front/ChangePlaceholderTypes.py extensions/front/create_tensor_nodes.py +extensions/front/CTCGreedyDecoderReplacement.py +extensions/front/CTCLossReplacement.py extensions/front/disable_weights_quantize_value_propagation.py extensions/front/div.py extensions/front/DropoutWithRandomUniformReplacer.py @@ -274,6 +276,7 @@ extensions/front/onnx/constant_of_shape_ext.py extensions/front/onnx/constant_of_shape_to_broadcast.py extensions/front/onnx/conv_ext.py extensions/front/onnx/crop_ext.py +extensions/front/onnx/CTCGreedyDecoder_ext.py extensions/front/onnx/cumsum_ext.py extensions/front/onnx/deformable_conv_ext.py extensions/front/onnx/depth_to_space_ext.py @@ -370,6 +373,7 @@ extensions/front/SizeReplacer.py extensions/front/softmax.py extensions/front/Softplus_fusion.py extensions/front/softsign_replacer.py +extensions/front/sparse_to_dense_replacer.py extensions/front/split_normalizer.py extensions/front/SqueezeNormalize.py extensions/front/sub.py @@ -401,9 +405,7 @@ extensions/front/tf/CorrectRollAxes.py extensions/front/tf/crop_and_resize_ext.py extensions/front/tf/CropAndResizeReplacement.py extensions/front/tf/CTCGreedyDecoder_ext.py -extensions/front/tf/CTCGreedyDecoderReplacement.py extensions/front/tf/CTCLoss_ext.py -extensions/front/tf/CTCLossReplacement.py extensions/front/tf/cumsum_ext.py extensions/front/tf/deconv_ext.py extensions/front/tf/depth_to_space.py @@ -497,7 +499,6 @@ extensions/front/tf/sparse_fill_empty_rows_ext.py extensions/front/tf/sparse_segment_mean_ext.py extensions/front/tf/sparse_segment_sqrtn_ext.py extensions/front/tf/sparse_segment_sum_ext.py -extensions/front/tf/sparse_to_dense_replacer.py extensions/front/tf/split_ext.py extensions/front/tf/ssd_support.json extensions/front/tf/ssd_support_api_v1.14.json diff --git a/model-optimizer/extensions/front/tf/CTCGreedyDecoderReplacement.py b/model-optimizer/extensions/front/CTCGreedyDecoderReplacement.py similarity index 100% rename from model-optimizer/extensions/front/tf/CTCGreedyDecoderReplacement.py rename to model-optimizer/extensions/front/CTCGreedyDecoderReplacement.py diff --git a/model-optimizer/extensions/front/tf/CTCLossReplacement.py b/model-optimizer/extensions/front/CTCLossReplacement.py similarity index 98% rename from model-optimizer/extensions/front/tf/CTCLossReplacement.py rename to model-optimizer/extensions/front/CTCLossReplacement.py index c47296db98e..ea2e6cbd3bc 100644 --- a/model-optimizer/extensions/front/tf/CTCLossReplacement.py +++ b/model-optimizer/extensions/front/CTCLossReplacement.py @@ -20,7 +20,7 @@ class CTCLossReplacement(FrontReplacementSubgraph): enabled = True def run_before(self): - from extensions.front.tf.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement + from extensions.front.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement return [CTCGreedyDecoderReplacement] def pattern(self): diff --git a/model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py b/model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py new file mode 100644 index 00000000000..31e0799876c --- /dev/null +++ b/model-optimizer/extensions/front/onnx/CTCGreedyDecoder_ext.py @@ -0,0 +1,19 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +from extensions.ops.ctc_greedy_decoder_seq_len import CTCGreedyDecoderSeqLenOp +from mo.front.extractor import FrontExtractorOp +from mo.front.onnx.extractors.utils import onnx_attr + + +class CTCCGreedyDecoderFrontExtractor(FrontExtractorOp): + op = 'CTCGreedyDecoder' + enabled = True + + @classmethod + def extract(cls, node): + attrs = { + 'merge_repeated': bool(onnx_attr(node, 'merge_repeated', 'i', default=1)), + } + CTCGreedyDecoderSeqLenOp.update_node_stat(node, attrs) + return cls.enabled diff --git a/model-optimizer/extensions/front/tf/sparse_to_dense_replacer.py b/model-optimizer/extensions/front/sparse_to_dense_replacer.py similarity index 93% rename from model-optimizer/extensions/front/tf/sparse_to_dense_replacer.py rename to model-optimizer/extensions/front/sparse_to_dense_replacer.py index 1440b150696..f285192a5a0 100644 --- a/model-optimizer/extensions/front/tf/sparse_to_dense_replacer.py +++ b/model-optimizer/extensions/front/sparse_to_dense_replacer.py @@ -21,8 +21,8 @@ class SparseToDenseReplacer(FrontReplacementOp): enabled = True def run_after(self): - from extensions.front.tf.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement - from extensions.front.tf.CTCLossReplacement import CTCLossReplacement + from extensions.front.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement + from extensions.front.CTCLossReplacement import CTCLossReplacement return [CTCGreedyDecoderReplacement, CTCLossReplacement] def replace_op(self, graph: Graph, node: Node): diff --git a/model-optimizer/unit_tests/extensions/front/tf/CTCGreedyDecoderReplacement_test.py b/model-optimizer/unit_tests/extensions/front/CTCGreedyDecoderReplacement_test.py similarity index 97% rename from model-optimizer/unit_tests/extensions/front/tf/CTCGreedyDecoderReplacement_test.py rename to model-optimizer/unit_tests/extensions/front/CTCGreedyDecoderReplacement_test.py index c4d1d467df4..063d71173e1 100644 --- a/model-optimizer/unit_tests/extensions/front/tf/CTCGreedyDecoderReplacement_test.py +++ b/model-optimizer/unit_tests/extensions/front/CTCGreedyDecoderReplacement_test.py @@ -3,7 +3,7 @@ import unittest -from extensions.front.tf.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement, CTCGreedyDecoderWithSparseToDenseShapeReplacement +from extensions.front.CTCGreedyDecoderReplacement import CTCGreedyDecoderReplacement, CTCGreedyDecoderWithSparseToDenseShapeReplacement from mo.front.common.partial_infer.utils import int64_array from mo.utils.ir_engine.compare_graphs import compare_graphs from unit_tests.utils.graph import build_graph, const diff --git a/model-optimizer/unit_tests/extensions/front/tf/CTCLossReplacement_test.py b/model-optimizer/unit_tests/extensions/front/CTCLossReplacement_test.py similarity index 99% rename from model-optimizer/unit_tests/extensions/front/tf/CTCLossReplacement_test.py rename to model-optimizer/unit_tests/extensions/front/CTCLossReplacement_test.py index f173ec15c17..77ecfc8fa1a 100644 --- a/model-optimizer/unit_tests/extensions/front/tf/CTCLossReplacement_test.py +++ b/model-optimizer/unit_tests/extensions/front/CTCLossReplacement_test.py @@ -5,7 +5,7 @@ import numpy as np import unittest from argparse import Namespace -from extensions.front.tf.CTCLossReplacement import CTCLossReplacement +from extensions.front.CTCLossReplacement import CTCLossReplacement from mo.front.common.partial_infer.utils import int64_array from mo.utils.ir_engine.compare_graphs import compare_graphs from unit_tests.utils.graph import build_graph, const diff --git a/model-optimizer/unit_tests/extensions/front/tf/sparse_to_dense_replacer_test.py b/model-optimizer/unit_tests/extensions/front/sparse_to_dense_replacer_test.py similarity index 96% rename from model-optimizer/unit_tests/extensions/front/tf/sparse_to_dense_replacer_test.py rename to model-optimizer/unit_tests/extensions/front/sparse_to_dense_replacer_test.py index 4e624dfd069..588d52198c9 100644 --- a/model-optimizer/unit_tests/extensions/front/tf/sparse_to_dense_replacer_test.py +++ b/model-optimizer/unit_tests/extensions/front/sparse_to_dense_replacer_test.py @@ -3,7 +3,7 @@ import unittest -from extensions.front.tf.sparse_to_dense_replacer import SparseToDenseReplacer +from extensions.front.sparse_to_dense_replacer import SparseToDenseReplacer from mo.front.common.partial_infer.utils import int64_array from mo.utils.ir_engine.compare_graphs import compare_graphs from unit_tests.utils.graph import build_graph, const diff --git a/ngraph/CMakeLists.txt b/ngraph/CMakeLists.txt index a05ca3b15c6..55e218daa2c 100644 --- a/ngraph/CMakeLists.txt +++ b/ngraph/CMakeLists.txt @@ -84,6 +84,7 @@ if (APPLE) endif() option(NGRAPH_UNIT_TEST_ENABLE "Control the building of unit tests" ON) +option(NGRAPH_UNIT_TEST_BACKENDS_ENABLE "Control the building of unit tests using backends" ON) option(NGRAPH_INTERPRETER_ENABLE "Control the building of the INTERPRETER backend" ON) option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" OFF) option(NGRAPH_ONNX_IMPORT_ENABLE "Enable ONNX importer" OFF) @@ -117,6 +118,7 @@ message(STATUS "NGRAPH_THREAD_SANITIZER_ENABLE: ${NGRAPH_THREAD_SANITIZER_ message(STATUS "NGRAPH_UB_SANITIZER_ENABLE: ${NGRAPH_UB_SANITIZER_ENABLE}") message(STATUS "NGRAPH_USE_PROTOBUF_LITE: ${NGRAPH_USE_PROTOBUF_LITE}") message(STATUS "NGRAPH_UNIT_TEST_ENABLE: ${NGRAPH_UNIT_TEST_ENABLE}") +message(STATUS "NGRAPH_UNIT_TEST_BACKENDS_ENABLE: ${NGRAPH_UNIT_TEST_BACKENDS_ENABLE}") # Setup CMAKE_ARGS to be forwarded to External Projects set(NGRAPH_FORWARD_CMAKE_ARGS diff --git a/ngraph/core/include/ngraph/node.hpp b/ngraph/core/include/ngraph/node.hpp index 51a0cccfa25..3d4880298b9 100644 --- a/ngraph/core/include/ngraph/node.hpp +++ b/ngraph/core/include/ngraph/node.hpp @@ -434,6 +434,8 @@ namespace ngraph /// \return Version of this node virtual size_t get_version() const { return get_type_info().version; } + + NGRAPH_DEPRECATED("This method is deprecated and will be removed soon.") virtual std::shared_ptr get_default_value() const { return nullptr; } /// Use instance ids for comparison instead of memory addresses to improve determinism bool operator<(const Node& other) const { return m_instance_id < other.m_instance_id; } diff --git a/ngraph/core/include/ngraph/op/add.hpp b/ngraph/core/include/ngraph/op/add.hpp index c16c8baac7b..1cf09af76cf 100644 --- a/ngraph/core/include/ngraph/op/add.hpp +++ b/ngraph/core/include/ngraph/op/add.hpp @@ -48,7 +48,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; - size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/avg_pool.hpp b/ngraph/core/include/ngraph/op/avg_pool.hpp index 8f414a6274d..a46250885f3 100644 --- a/ngraph/core/include/ngraph/op/avg_pool.hpp +++ b/ngraph/core/include/ngraph/op/avg_pool.hpp @@ -49,7 +49,6 @@ namespace ngraph op::RoundingType rounding_type = op::RoundingType::FLOOR, const PadType& auto_pad = op::PadType::EXPLICIT); - size_t get_version() const override { return 1; } void validate_and_infer_types() override; bool visit_attributes(AttributeVisitor& visitor) override; @@ -76,7 +75,9 @@ namespace ngraph op::RoundingType get_rounding_type() const; void set_rounding_type(op::RoundingType rounding_type); /// \return The default value for AvgPool. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Shape m_kernel; diff --git a/ngraph/core/include/ngraph/op/binary_convolution.hpp b/ngraph/core/include/ngraph/op/binary_convolution.hpp index 12e2c448f54..3d4bf98496e 100644 --- a/ngraph/core/include/ngraph/op/binary_convolution.hpp +++ b/ngraph/core/include/ngraph/op/binary_convolution.hpp @@ -59,7 +59,6 @@ namespace ngraph float pad_value, const PadType& auto_pad = PadType::EXPLICIT); - size_t get_version() const override { return 1; } void validate_and_infer_types() override; bool visit_attributes(AttributeVisitor& visitor) override; diff --git a/ngraph/core/include/ngraph/op/ceiling.hpp b/ngraph/core/include/ngraph/op/ceiling.hpp index 491ca099b2a..7ac74ad3dd4 100644 --- a/ngraph/core/include/ngraph/op/ceiling.hpp +++ b/ngraph/core/include/ngraph/op/ceiling.hpp @@ -16,8 +16,7 @@ namespace ngraph class NGRAPH_API Ceiling : public util::UnaryElementwiseArithmetic { public: - static constexpr NodeTypeInfo type_info{"Ceiling", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; /// \brief Constructs a ceiling operation. Ceiling() = default; /// \brief Constructs a ceiling operation. diff --git a/ngraph/core/include/ngraph/op/convolution.hpp b/ngraph/core/include/ngraph/op/convolution.hpp index 72a365be533..31f82c3c390 100644 --- a/ngraph/core/include/ngraph/op/convolution.hpp +++ b/ngraph/core/include/ngraph/op/convolution.hpp @@ -72,7 +72,9 @@ namespace ngraph const PadType& get_auto_pad() const { return m_auto_pad; } void set_auto_pad(const PadType& auto_pad) { m_auto_pad = auto_pad; } /// \return The default value for Convolution. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Strides m_strides; diff --git a/ngraph/core/include/ngraph/op/cum_sum.hpp b/ngraph/core/include/ngraph/op/cum_sum.hpp index 8a133a2502b..72cfe892256 100644 --- a/ngraph/core/include/ngraph/op/cum_sum.hpp +++ b/ngraph/core/include/ngraph/op/cum_sum.hpp @@ -91,7 +91,9 @@ namespace ngraph void validate_and_infer_types() override; /// \return The default value for CumSum. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END bool is_exclusive() const { return m_exclusive; } bool is_reverse() const { return m_reverse; } diff --git a/ngraph/core/include/ngraph/op/divide.hpp b/ngraph/core/include/ngraph/op/divide.hpp index 0c33fe6774e..f2e40dc5532 100644 --- a/ngraph/core/include/ngraph/op/divide.hpp +++ b/ngraph/core/include/ngraph/op/divide.hpp @@ -50,7 +50,6 @@ namespace ngraph virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/gather.hpp b/ngraph/core/include/ngraph/op/gather.hpp index 9293521a7d0..61bbf33bc3a 100644 --- a/ngraph/core/include/ngraph/op/gather.hpp +++ b/ngraph/core/include/ngraph/op/gather.hpp @@ -61,5 +61,32 @@ namespace ngraph clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace v7 + + namespace v8 + { + /// \brief Gather slices from axis of params according to indices + class NGRAPH_API Gather : public op::util::GatherBase + { + public: + NGRAPH_RTTI_DECLARATION; + Gather() = default; + + /// \param data The tensor from which slices are gathered + /// \param indices Tensor with indexes to gather + /// \param axis The tensor is a dimension index to gather data from + /// \param batch_dims The number of batch dimension in data and indices tensors. + Gather(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims = 0); + + bool visit_attributes(AttributeVisitor& visitor) override; + void validate_and_infer_types() override; + int64_t get_batch_dims() const; + + std::shared_ptr + clone_with_new_inputs(const OutputVector& new_args) const override; + }; + } // namespace v8 } // namespace op } // namespace ngraph diff --git a/ngraph/core/include/ngraph/op/group_conv.hpp b/ngraph/core/include/ngraph/op/group_conv.hpp index ebda0392d96..e55e3fd3457 100644 --- a/ngraph/core/include/ngraph/op/group_conv.hpp +++ b/ngraph/core/include/ngraph/op/group_conv.hpp @@ -71,7 +71,9 @@ namespace ngraph const PadType& get_auto_pad() const { return m_auto_pad; } void set_auto_pad(const PadType& auto_pad) { m_auto_pad = auto_pad; } /// \return The default value for Convolution. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Strides m_strides; diff --git a/ngraph/core/include/ngraph/op/log_softmax.hpp b/ngraph/core/include/ngraph/op/log_softmax.hpp index 8bc4cec8e06..f43bb82c5df 100644 --- a/ngraph/core/include/ngraph/op/log_softmax.hpp +++ b/ngraph/core/include/ngraph/op/log_softmax.hpp @@ -30,7 +30,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/max_pool.hpp b/ngraph/core/include/ngraph/op/max_pool.hpp index 9ca644cae75..fcfbf69132d 100644 --- a/ngraph/core/include/ngraph/op/max_pool.hpp +++ b/ngraph/core/include/ngraph/op/max_pool.hpp @@ -41,7 +41,6 @@ namespace ngraph const PadType& auto_pad = op::PadType::EXPLICIT); bool visit_attributes(AttributeVisitor& visitor) override; - size_t get_version() const override { return 1; } void validate_and_infer_types() override; virtual std::shared_ptr @@ -69,7 +68,9 @@ namespace ngraph m_rounding_type = rounding_mode; } /// \return The default value for MaxPool. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; diff --git a/ngraph/core/include/ngraph/op/pad.hpp b/ngraph/core/include/ngraph/op/pad.hpp index 93ef2740b60..9f0b94cf16c 100644 --- a/ngraph/core/include/ngraph/op/pad.hpp +++ b/ngraph/core/include/ngraph/op/pad.hpp @@ -57,7 +57,6 @@ namespace ngraph Pad() = default; bool visit_attributes(AttributeVisitor& visitor) override; - size_t get_version() const override { return 1; } void validate_and_infer_types() override; virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_l1.hpp b/ngraph/core/include/ngraph/op/reduce_l1.hpp index 5760f855727..5dd82a2b1f8 100644 --- a/ngraph/core/include/ngraph/op/reduce_l1.hpp +++ b/ngraph/core/include/ngraph/op/reduce_l1.hpp @@ -31,9 +31,10 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 4; } /// \return The default value for Reduce. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_l2.hpp b/ngraph/core/include/ngraph/op/reduce_l2.hpp index 4cd629f22aa..35c8419c3dd 100644 --- a/ngraph/core/include/ngraph/op/reduce_l2.hpp +++ b/ngraph/core/include/ngraph/op/reduce_l2.hpp @@ -30,9 +30,10 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 4; } /// \return The default value for Reduce. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_mean.hpp b/ngraph/core/include/ngraph/op/reduce_mean.hpp index fb4c393b3d5..dd642409810 100644 --- a/ngraph/core/include/ngraph/op/reduce_mean.hpp +++ b/ngraph/core/include/ngraph/op/reduce_mean.hpp @@ -26,7 +26,6 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 1; } std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_prod.hpp b/ngraph/core/include/ngraph/op/reduce_prod.hpp index 12ded1656d1..2b1b73d3927 100644 --- a/ngraph/core/include/ngraph/op/reduce_prod.hpp +++ b/ngraph/core/include/ngraph/op/reduce_prod.hpp @@ -30,9 +30,10 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 1; } /// \return The default value for Product. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reduce_sum.hpp b/ngraph/core/include/ngraph/op/reduce_sum.hpp index 5bef40536b1..83b663c10e6 100644 --- a/ngraph/core/include/ngraph/op/reduce_sum.hpp +++ b/ngraph/core/include/ngraph/op/reduce_sum.hpp @@ -77,13 +77,13 @@ namespace ngraph const Output& reduction_axes, bool keep_dims = false); - size_t get_version() const override { return 1; } - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; /// \return The default value for Sum. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; diff --git a/ngraph/core/include/ngraph/op/reshape.hpp b/ngraph/core/include/ngraph/op/reshape.hpp index 6be77386cd0..da2725247c0 100644 --- a/ngraph/core/include/ngraph/op/reshape.hpp +++ b/ngraph/core/include/ngraph/op/reshape.hpp @@ -46,7 +46,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/reverse.hpp b/ngraph/core/include/ngraph/op/reverse.hpp index 2a71ec75df2..012d02879df 100644 --- a/ngraph/core/include/ngraph/op/reverse.hpp +++ b/ngraph/core/include/ngraph/op/reverse.hpp @@ -15,14 +15,14 @@ namespace ngraph class NGRAPH_API Reverse : public Op { public: + NGRAPH_RTTI_DECLARATION; + enum class Mode { INDEX, MASK }; - static constexpr NodeTypeInfo type_info{"Reverse", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } Reverse() = default; /// \brief Constructs a reverse operation. /// @@ -47,7 +47,6 @@ namespace ngraph /// \return The second input data interpretation mode. Mode get_mode() const { return m_mode; } void set_mode(const Mode mode) { m_mode = mode; } - virtual size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/softmax.hpp b/ngraph/core/include/ngraph/op/softmax.hpp index 34537618153..33201cc843c 100644 --- a/ngraph/core/include/ngraph/op/softmax.hpp +++ b/ngraph/core/include/ngraph/op/softmax.hpp @@ -15,8 +15,8 @@ namespace ngraph class NGRAPH_API Softmax : public Op { public: - static constexpr NodeTypeInfo type_info{"Softmax", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } + NGRAPH_RTTI_DECLARATION; + Softmax() : m_axis(0) { @@ -34,7 +34,6 @@ namespace ngraph bool visit_attributes(AttributeVisitor& visitor) override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/core/include/ngraph/op/strided_slice.hpp b/ngraph/core/include/ngraph/op/strided_slice.hpp index 33144706b74..10e7e00feff 100644 --- a/ngraph/core/include/ngraph/op/strided_slice.hpp +++ b/ngraph/core/include/ngraph/op/strided_slice.hpp @@ -90,7 +90,6 @@ namespace ngraph std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; - size_t get_version() const override { return 1; } bool evaluate(const HostTensorVector& output_values, const HostTensorVector& input_values) const override; bool has_evaluate() const override; diff --git a/ngraph/core/include/ngraph/op/topk.hpp b/ngraph/core/include/ngraph/op/topk.hpp index 6d03190b6f6..e5ad952c46a 100644 --- a/ngraph/core/include/ngraph/op/topk.hpp +++ b/ngraph/core/include/ngraph/op/topk.hpp @@ -21,11 +21,11 @@ namespace ngraph class NGRAPH_API TopK : public Op { public: + NGRAPH_RTTI_DECLARATION; + using SortType = TopKSortType; using Mode = TopKMode; - static constexpr NodeTypeInfo type_info{"TopK", 1}; - const NodeTypeInfo& get_type_info() const override { return type_info; } /// \brief Constructs a TopK operation TopK() = default; /// \brief Constructs a TopK operation with two outputs: values and indices. @@ -60,7 +60,6 @@ namespace ngraph virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - virtual size_t get_version() const override { return 1; } /// \brief Returns axis value after normalization /// \note If input rank required to normalization is dynamic, the exception is /// thrown diff --git a/ngraph/core/include/ngraph/op/util/variable.hpp b/ngraph/core/include/ngraph/op/util/variable.hpp index 6d0f48dafd4..3390de9026e 100644 --- a/ngraph/core/include/ngraph/op/util/variable.hpp +++ b/ngraph/core/include/ngraph/op/util/variable.hpp @@ -14,6 +14,12 @@ namespace ngraph PartialShape data_shape; element::Type data_type; std::string variable_id; + + inline bool operator==(const VariableInfo& other) const + { + return data_shape == other.data_shape && data_type == other.data_type && + variable_id == other.variable_id; + } }; class NGRAPH_API Variable diff --git a/ngraph/core/include/ngraph/op/variadic_split.hpp b/ngraph/core/include/ngraph/op/variadic_split.hpp index 4293270fcbe..fbff40bc21a 100644 --- a/ngraph/core/include/ngraph/op/variadic_split.hpp +++ b/ngraph/core/include/ngraph/op/variadic_split.hpp @@ -4,9 +4,7 @@ #pragma once -#include "ngraph/coordinate.hpp" #include "ngraph/op/op.hpp" -#include "ngraph/strides.hpp" namespace ngraph { diff --git a/ngraph/core/include/ngraph/opsets/opset8.hpp b/ngraph/core/include/ngraph/opsets/opset8.hpp new file mode 100644 index 00000000000..f31a3142cf6 --- /dev/null +++ b/ngraph/core/include/ngraph/opsets/opset8.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/ops.hpp" + +namespace ngraph +{ + namespace opset8 + { +#define NGRAPH_OP(a, b) using b::a; +#include "ngraph/opsets/opset8_tbl.hpp" +#undef NGRAPH_OP + } // namespace opset8 +} // namespace ngraph diff --git a/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp new file mode 100644 index 00000000000..0dbe077ddae --- /dev/null +++ b/ngraph/core/include/ngraph/opsets/opset8_tbl.hpp @@ -0,0 +1,179 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#ifndef NGRAPH_OP +#warning "NGRAPH_OP not defined" +#define NGRAPH_OP(x, y) +#endif + +NGRAPH_OP(Abs, ngraph::op::v0) +NGRAPH_OP(Acos, ngraph::op::v0) +NGRAPH_OP(Add, ngraph::op::v1) +NGRAPH_OP(Asin, ngraph::op::v0) +NGRAPH_OP(Atan, ngraph::op::v0) +NGRAPH_OP(AvgPool, ngraph::op::v1) +NGRAPH_OP(BatchNormInference, ngraph::op::v5) +NGRAPH_OP(BinaryConvolution, ngraph::op::v1) +NGRAPH_OP(Broadcast, ngraph::op::v3) +NGRAPH_OP(Bucketize, ngraph::op::v3) +NGRAPH_OP(CTCGreedyDecoder, ngraph::op::v0) +NGRAPH_OP(Ceiling, ngraph::op::v0) +NGRAPH_OP(Clamp, ngraph::op::v0) +NGRAPH_OP(Concat, ngraph::op::v0) +NGRAPH_OP(Constant, ngraph::op) +NGRAPH_OP(Convert, ngraph::op::v0) +NGRAPH_OP(ConvertLike, ngraph::op::v1) +NGRAPH_OP(Convolution, ngraph::op::v1) +NGRAPH_OP(ConvolutionBackpropData, ngraph::op::v1) +NGRAPH_OP(Cos, ngraph::op::v0) +NGRAPH_OP(Cosh, ngraph::op::v0) +NGRAPH_OP(CumSum, ngraph::op::v0) +NGRAPH_OP(DeformableConvolution, ngraph::op::v1) +NGRAPH_OP(DeformablePSROIPooling, ngraph::op::v1) +NGRAPH_OP(DepthToSpace, ngraph::op::v0) +NGRAPH_OP(DetectionOutput, ngraph::op::v0) +NGRAPH_OP(Divide, ngraph::op::v1) +NGRAPH_OP(Elu, ngraph::op::v0) +NGRAPH_OP(Erf, ngraph::op::v0) +NGRAPH_OP(Equal, ngraph::op::v1) +NGRAPH_OP(Exp, ngraph::op::v0) +NGRAPH_OP(ExtractImagePatches, ngraph::op::v3) +NGRAPH_OP(FakeQuantize, ngraph::op::v0) +NGRAPH_OP(Floor, ngraph::op::v0) +NGRAPH_OP(FloorMod, ngraph::op::v1) +NGRAPH_OP(GatherTree, ngraph::op::v1) +NGRAPH_OP(Greater, ngraph::op::v1) +NGRAPH_OP(GreaterEqual, ngraph::op::v1) +NGRAPH_OP(GroupConvolution, ngraph::op::v1) +NGRAPH_OP(GroupConvolutionBackpropData, ngraph::op::v1) +NGRAPH_OP(GRN, ngraph::op::v0) +NGRAPH_OP(HardSigmoid, ngraph::op::v0) +NGRAPH_OP(Less, ngraph::op::v1) +NGRAPH_OP(LessEqual, ngraph::op::v1) +NGRAPH_OP(Log, ngraph::op::v0) +NGRAPH_OP(LogicalAnd, ngraph::op::v1) +NGRAPH_OP(LogicalNot, ngraph::op::v1) +NGRAPH_OP(LogicalOr, ngraph::op::v1) +NGRAPH_OP(LogicalXor, ngraph::op::v1) +NGRAPH_OP(LRN, ngraph::op::v0) +NGRAPH_OP(LSTMCell, ngraph::op::v4) +NGRAPH_OP(MatMul, ngraph::op::v0) +NGRAPH_OP(MaxPool, ngraph::op::v1) +NGRAPH_OP(Maximum, ngraph::op::v1) +NGRAPH_OP(Minimum, ngraph::op::v1) +NGRAPH_OP(Mod, ngraph::op::v1) +NGRAPH_OP(Multiply, ngraph::op::v1) +NGRAPH_OP(Negative, ngraph::op::v0) +NGRAPH_OP(NormalizeL2, ngraph::op::v0) +NGRAPH_OP(NotEqual, ngraph::op::v1) +NGRAPH_OP(OneHot, ngraph::op::v1) +NGRAPH_OP(PRelu, ngraph::op::v0) +NGRAPH_OP(PSROIPooling, ngraph::op::v0) +NGRAPH_OP(Pad, ngraph::op::v1) +NGRAPH_OP(Parameter, ngraph::op::v0) +NGRAPH_OP(Power, ngraph::op::v1) +NGRAPH_OP(PriorBox, ngraph::op::v0) +NGRAPH_OP(PriorBoxClustered, ngraph::op::v0) +NGRAPH_OP(Proposal, ngraph::op::v4) +NGRAPH_OP(Range, ngraph::op::v4) +NGRAPH_OP(Relu, ngraph::op::v0) +NGRAPH_OP(ReduceMax, ngraph::op::v1) +NGRAPH_OP(ReduceLogicalAnd, ngraph::op::v1) +NGRAPH_OP(ReduceLogicalOr, ngraph::op::v1) +NGRAPH_OP(ReduceMean, ngraph::op::v1) +NGRAPH_OP(ReduceMin, ngraph::op::v1) +NGRAPH_OP(ReduceProd, ngraph::op::v1) +NGRAPH_OP(ReduceSum, ngraph::op::v1) +NGRAPH_OP(RegionYolo, ngraph::op::v0) +NGRAPH_OP(ReorgYolo, ngraph::op::v0) +NGRAPH_OP(Reshape, ngraph::op::v1) +NGRAPH_OP(Result, ngraph::op::v0) +NGRAPH_OP(ReverseSequence, ngraph::op::v0) +NGRAPH_OP(ROIPooling, ngraph::op::v0) +NGRAPH_OP(ScatterNDUpdate, ngraph::op::v3) +NGRAPH_OP(Select, ngraph::op::v1) +NGRAPH_OP(Selu, ngraph::op::v0) +NGRAPH_OP(Sign, ngraph::op::v0) +NGRAPH_OP(Sigmoid, ngraph::op::v0) +NGRAPH_OP(Sin, ngraph::op::v0) +NGRAPH_OP(Sinh, ngraph::op::v0) +NGRAPH_OP(Softmax, ngraph::op::v1) +NGRAPH_OP(Sqrt, ngraph::op::v0) +NGRAPH_OP(SpaceToDepth, ngraph::op::v0) +NGRAPH_OP(Split, ngraph::op::v1) +NGRAPH_OP(SquaredDifference, ngraph::op::v0) +NGRAPH_OP(Squeeze, ngraph::op::v0) +NGRAPH_OP(StridedSlice, ngraph::op::v1) +NGRAPH_OP(Subtract, ngraph::op::v1) +NGRAPH_OP(Tan, ngraph::op::v0) +NGRAPH_OP(Tanh, ngraph::op::v0) +NGRAPH_OP(TensorIterator, ngraph::op::v0) +NGRAPH_OP(Tile, ngraph::op::v0) +NGRAPH_OP(Transpose, ngraph::op::v1) +NGRAPH_OP(Unsqueeze, ngraph::op::v0) +NGRAPH_OP(VariadicSplit, ngraph::op::v1) + +// New operations added in opset2 +NGRAPH_OP(BatchToSpace, ngraph::op::v1) +NGRAPH_OP(SpaceToBatch, ngraph::op::v1) + +// New operations added in opset3 +NGRAPH_OP(EmbeddingBagPackedSum, ngraph::op::v3) +NGRAPH_OP(EmbeddingSegmentsSum, ngraph::op::v3) +NGRAPH_OP(EmbeddingBagOffsetsSum, ngraph::op::v3) +NGRAPH_OP(GRUCell, ngraph::op::v3) +NGRAPH_OP(NonZero, ngraph::op::v3) +NGRAPH_OP(RNNCell, ngraph::op::v0) +NGRAPH_OP(ROIAlign, ngraph::op::v3) +NGRAPH_OP(ScatterElementsUpdate, ngraph::op::v3) +NGRAPH_OP(ScatterUpdate, ngraph::op::v3) +NGRAPH_OP(ShuffleChannels, ngraph::op::v0) +NGRAPH_OP(ShapeOf, ngraph::op::v3) +NGRAPH_OP(TopK, ngraph::op::v3) + +// New operations added in opset4 +NGRAPH_OP(Acosh, ngraph::op::v3) +NGRAPH_OP(Asinh, ngraph::op::v3) +NGRAPH_OP(Atanh, ngraph::op::v3) +NGRAPH_OP(CTCLoss, ngraph::op::v4) +NGRAPH_OP(HSwish, ngraph::op::v4) +NGRAPH_OP(Interpolate, ngraph::op::v4) +NGRAPH_OP(Mish, ngraph::op::v4) +NGRAPH_OP(ReduceL1, ngraph::op::v4) +NGRAPH_OP(ReduceL2, ngraph::op::v4) +NGRAPH_OP(SoftPlus, ngraph::op::v4) +NGRAPH_OP(Swish, ngraph::op::v4) + +// New operations added in opset5 +NGRAPH_OP(GatherND, ngraph::op::v5) +NGRAPH_OP(GRUSequence, ngraph::op::v5) +NGRAPH_OP(HSigmoid, ngraph::op::v5) +NGRAPH_OP(LogSoftmax, ngraph::op::v5) +NGRAPH_OP(Loop, ngraph::op::v5) +NGRAPH_OP(LSTMSequence, ngraph::op::v5) +NGRAPH_OP(NonMaxSuppression, ngraph::op::v5) +NGRAPH_OP(RNNSequence, ngraph::op::v5) +NGRAPH_OP(Round, ngraph::op::v5) + +// New operations added in opset6 +NGRAPH_OP(CTCGreedyDecoderSeqLen, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronDetectionOutput, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronGenerateProposalsSingleImage, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronPriorGridGenerator, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronROIFeatureExtractor, ngraph::op::v6) +NGRAPH_OP(ExperimentalDetectronTopKROIs, ngraph::op::v6) +NGRAPH_OP(GatherElements, ngraph::op::v6) +NGRAPH_OP(MVN, ngraph::op::v6) +NGRAPH_OP(Assign, ngraph::op::v6) // new version +NGRAPH_OP(ReadValue, ngraph::op::v6) // new version + +// New operations added in opset7 +NGRAPH_OP(DFT, ngraph::op::v7) +NGRAPH_OP(Einsum, ngraph::op::v7) +NGRAPH_OP(Gelu, ngraph::op::v7) +NGRAPH_OP(IDFT, ngraph::op::v7) +NGRAPH_OP(Roll, ngraph::op::v7) + +// New operations added in opset8 +NGRAPH_OP(Gather, ngraph::op::v8) diff --git a/ngraph/core/src/op/ceiling.cpp b/ngraph/core/src/op/ceiling.cpp index 7ef0e8a6bec..22abc45eba3 100644 --- a/ngraph/core/src/op/ceiling.cpp +++ b/ngraph/core/src/op/ceiling.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Ceiling::type_info; +NGRAPH_RTTI_DEFINITION(op::v0::Ceiling, "Ceiling", 0, util::UnaryElementwiseArithmetic); op::Ceiling::Ceiling(const Output& arg) : UnaryElementwiseArithmetic(arg) diff --git a/ngraph/core/src/op/gather.cpp b/ngraph/core/src/op/gather.cpp index f2ddc9948b3..aeacffc2719 100644 --- a/ngraph/core/src/op/gather.cpp +++ b/ngraph/core/src/op/gather.cpp @@ -86,3 +86,50 @@ shared_ptr op::v7::Gather::clone_with_new_inputs(const OutputVector& new_a check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); } + +NGRAPH_RTTI_DEFINITION(op::v8::Gather, "Gather", 8, op::util::GatherBase); + +op::v8::Gather::Gather(const Output& data, + const Output& indices, + const Output& axis, + const int64_t batch_dims) + : GatherBase(data, indices, axis, batch_dims) +{ + constructor_validate_and_infer_types(); +} + +void op::v8::Gather::validate_and_infer_types() +{ + NGRAPH_OP_SCOPE(v8_Gather_validate_and_infer_types); + NODE_VALIDATION_CHECK(this, + get_input_element_type(1).is_integral_number(), + "Indices element type must be of an integral number type."); + + NODE_VALIDATION_CHECK(this, + get_input_element_type(2).is_integral_number(), + "Axis element type must be of an integral number type."); + + op::util::GatherBase::validate_and_infer_types(); +} + +int64_t op::v8::Gather::get_batch_dims() const +{ + if (m_batch_dims < 0 && get_input_partial_shape(1).rank().is_static()) + return m_batch_dims + get_input_partial_shape(1).rank().get_length(); + else + return m_batch_dims; +} + +bool ngraph::op::v8::Gather::visit_attributes(AttributeVisitor& visitor) +{ + NGRAPH_OP_SCOPE(v8_Gather_visit_attributes); + visitor.on_attribute("batch_dims", m_batch_dims); + return true; +} + +shared_ptr op::v8::Gather::clone_with_new_inputs(const OutputVector& new_args) const +{ + NGRAPH_OP_SCOPE(v8_Gather_clone_with_new_inputs); + check_new_args_count(this, new_args); + return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_batch_dims); +} diff --git a/ngraph/core/src/op/reverse.cpp b/ngraph/core/src/op/reverse.cpp index 68571a94a95..903e9eea6c2 100644 --- a/ngraph/core/src/op/reverse.cpp +++ b/ngraph/core/src/op/reverse.cpp @@ -18,7 +18,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::v1::Reverse::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::Reverse, "Reverse", 1); op::v1::Reverse::Reverse(const Output& data, const Output& reversed_axes, diff --git a/ngraph/core/src/op/softmax.cpp b/ngraph/core/src/op/softmax.cpp index ae4317a9c12..097d46dd159 100644 --- a/ngraph/core/src/op/softmax.cpp +++ b/ngraph/core/src/op/softmax.cpp @@ -51,7 +51,7 @@ namespace } // namespace // *** SOFTMAX OP SET V1 *** -constexpr NodeTypeInfo op::v1::Softmax::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::Softmax, "Softmax", 1); op::v1::Softmax::Softmax(const Output& arg, const size_t axis) : Op({arg}) diff --git a/ngraph/core/src/op/topk.cpp b/ngraph/core/src/op/topk.cpp index 6b91fd13339..b346c5d238f 100644 --- a/ngraph/core/src/op/topk.cpp +++ b/ngraph/core/src/op/topk.cpp @@ -205,7 +205,7 @@ namespace topk } // namespace topk // v1 version starts -constexpr NodeTypeInfo op::v1::TopK::type_info; +NGRAPH_RTTI_DEFINITION(op::v1::TopK, "TopK", 1); static const std::uint64_t UNKNOWN_NORMALIZED_AXIS = std::numeric_limits::max(); diff --git a/ngraph/core/src/op/util/gather_base.cpp b/ngraph/core/src/op/util/gather_base.cpp index a58ab3e3851..566d9184e33 100644 --- a/ngraph/core/src/op/util/gather_base.cpp +++ b/ngraph/core/src/op/util/gather_base.cpp @@ -236,6 +236,8 @@ namespace gather { NGRAPH_TYPE_CASE(evaluate_gather, i32, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, i64, arg0, arg1, out, axis, batch_dims); + NGRAPH_TYPE_CASE(evaluate_gather, i8, arg0, arg1, out, axis, batch_dims); + NGRAPH_TYPE_CASE(evaluate_gather, u8, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, u32, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, u64, arg0, arg1, out, axis, batch_dims); NGRAPH_TYPE_CASE(evaluate_gather, f16, arg0, arg1, out, axis, batch_dims); diff --git a/ngraph/core/src/op/variadic_split.cpp b/ngraph/core/src/op/variadic_split.cpp index 505584ec6e1..4b3cf710bc6 100644 --- a/ngraph/core/src/op/variadic_split.cpp +++ b/ngraph/core/src/op/variadic_split.cpp @@ -5,13 +5,9 @@ #include #include "itt.hpp" -#include "ngraph/op/constant.hpp" -#include "ngraph/op/util/op_types.hpp" #include "ngraph/op/variadic_split.hpp" -#include "ngraph/validation_util.hpp" - -#include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/reference/slice.hpp" +#include "ngraph/validation_util.hpp" using namespace std; using namespace ngraph; @@ -49,11 +45,11 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() split_lengths_pshape.rank(), " instead."); - auto num_outputs = split_lengths_pshape[0].get_length(); - auto data = input_value(0); - auto axis_source = input_value(1); - auto split_lengths_source = input_value(2); - auto data_shape = data.get_partial_shape(); + const auto num_outputs = split_lengths_pshape[0].get_length(); + const auto data = input_value(0); + const auto axis_source = input_value(1); + const auto split_lengths_source = input_value(2); + const auto data_shape = data.get_partial_shape(); const auto& data_type = data.get_element_type(); set_output_size(num_outputs); @@ -61,9 +57,9 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() const auto& split_lengths_constant = get_constant_from_source(split_lengths_source); if (data_shape.rank().is_static() && axis_input_constant && split_lengths_constant) { - auto axis_val = axis_input_constant->cast_vector()[0]; + const auto axis_val = axis_input_constant->cast_vector()[0]; // Adjust split axis in case of negatives - int64_t axis = ngraph::normalize_axis(this, axis_val, data_shape.rank()); + const int64_t axis = ngraph::normalize_axis(this, axis_val, data_shape.rank()); auto split_lengths = split_lengths_constant->cast_vector(); // Adjust split lengths in case of negatives @@ -92,8 +88,8 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() sum_of_splits += split_lengths[i]; } } - auto data_shape_dims = vector{data.get_partial_shape()}; - auto dimension_at_axis = data_shape_dims.at(axis); + const auto data_shape_dims = vector{data.get_partial_shape()}; + const auto dimension_at_axis = data_shape_dims.at(axis); if (negative_one >= 0 && dimension_at_axis.is_static()) { @@ -112,8 +108,9 @@ void ngraph::op::v1::VariadicSplit::validate_and_infer_types() for (int64_t output{0}; output < num_outputs; ++output) { - auto output_split_dim = split_lengths.at(output) == -1 ? Dimension::dynamic() - : split_lengths.at(output); + const auto output_split_dim = split_lengths.at(output) == -1 + ? Dimension::dynamic() + : split_lengths.at(output); auto tmp_shape = data_shape_dims; tmp_shape.at(axis) = output_split_dim; set_output_type(output, data_type, PartialShape{tmp_shape}); diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index ca45c965c9f..278121669a8 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -99,6 +99,9 @@ set(SRC span.cpp specialize_function.cpp tensor.cpp + type_prop/abs.cpp + type_prop/acos.cpp + type_prop/asin.cpp type_prop/assign.cpp type_prop/avg_pool.cpp type_prop/batch_norm.cpp @@ -107,6 +110,7 @@ set(SRC type_prop/binary_elementwise.cpp type_prop/broadcast.cpp type_prop/bucketize.cpp + type_prop/ceiling.cpp type_prop/clamp.cpp type_prop/concat.cpp type_prop/constant.cpp @@ -123,6 +127,7 @@ set(SRC type_prop/dft.cpp type_prop/dyn_reshape.cpp type_prop/einsum.cpp + type_prop/exp.cpp type_prop/experimental_detectron_generate_proposals.cpp type_prop/experimental_detectron_roi_feature_extractor.cpp type_prop/experimental_detectron_topkrois.cpp @@ -135,6 +140,7 @@ set(SRC type_prop/embeddingbag_packedsum.cpp type_prop/embedding_segments_sum.cpp type_prop/fake_quantize.cpp + type_prop/floor.cpp type_prop/floor_mod.cpp type_prop/gather.cpp type_prop/gather_elements.cpp @@ -201,11 +207,13 @@ set(SRC type_prop/selu.cpp type_prop/shape_of.cpp type_prop/shuffle_channels.cpp + type_prop/sin.cpp type_prop/softmax.cpp type_prop/softplus.cpp type_prop/space_to_batch.cpp type_prop/space_to_depth.cpp type_prop/split.cpp + type_prop/sqrt.cpp type_prop/squared_difference.cpp type_prop/squeeze.cpp type_prop/swish.cpp @@ -214,7 +222,6 @@ set(SRC type_prop/top_k.cpp type_prop/transpose.cpp type_prop/unary_elementwise.cpp - type_prop/unary_ops.cpp type_prop/unsqueeze.cpp type_prop/variadic_split.cpp type_prop_layers.cpp @@ -224,6 +231,7 @@ set(SRC visitors/op/batch_norm.cpp visitors/op/broadcast.cpp visitors/op/bucketize.cpp + visitors/op/ceiling.cpp visitors/op/constant.cpp visitors/op/convert.cpp visitors/op/convolution_backprop.cpp @@ -288,6 +296,7 @@ set(SRC visitors/op/topk.cpp visitors/op/transpose.cpp visitors/op/unsqueeze.cpp + visitors/op/variadic_split.cpp uint4.cpp util.cpp ) @@ -295,7 +304,7 @@ set(SRC set_source_files_properties(includes.cpp PROPERTIES COMPILE_DEFINITIONS NGRAPH_INCLUDES="${PROJECT_SOURCE_DIR}/src/ngraph") -if (ENABLE_MKL_DNN) +if (ENABLE_MKL_DNN AND NGRAPH_UNIT_TEST_BACKENDS_ENABLE) message(STATUS "NGRAPH_TESTS: IE:CPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:CPU") if (ENABLE_STRICT_DEPENDENCIES) @@ -305,7 +314,7 @@ if (ENABLE_MKL_DNN) endif() endif() -if (ENABLE_CLDNN) +if (ENABLE_CLDNN AND NGRAPH_UNIT_TEST_BACKENDS_ENABLE) message(STATUS "NGRAPH_TESTS: IE:GPU enabled") set(ACTIVE_BACKEND_LIST ${ACTIVE_BACKEND_LIST} "IE:GPU") if (ENABLE_STRICT_DEPENDENCIES) @@ -315,7 +324,7 @@ if (ENABLE_CLDNN) endif() endif() -if (NGRAPH_INTERPRETER_ENABLE) +if (NGRAPH_INTERPRETER_ENABLE AND NGRAPH_UNIT_TEST_BACKENDS_ENABLE) list(APPEND SRC builder.cpp backend_api.cpp) @@ -466,6 +475,7 @@ set(MULTI_TEST_SRC backend/unhandled_op.in.cpp backend/unsqueeze.in.cpp backend/validate_call.in.cpp + backend/variadic_split.in.cpp backend/zero_sized.in.cpp ) diff --git a/ngraph/test/backend/ceiling.in.cpp b/ngraph/test/backend/ceiling.in.cpp index cfd5d71e3e1..2cf7b548949 100644 --- a/ngraph/test/backend/ceiling.in.cpp +++ b/ngraph/test/backend/ceiling.in.cpp @@ -2,13 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include - // clang-format off #ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS #define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS diff --git a/ngraph/test/backend/variadic_split.in.cpp b/ngraph/test/backend/variadic_split.in.cpp new file mode 100644 index 00000000000..d582d567550 --- /dev/null +++ b/ngraph/test/backend/variadic_split.in.cpp @@ -0,0 +1,360 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" +#include "ngraph/ngraph.hpp" +#include "util/engine/test_engines.hpp" +#include "util/test_case.hpp" +#include "util/test_control.hpp" + +using namespace std; +using namespace ngraph; + +static string s_manifest = "${MANIFEST}"; +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); + +namespace +{ + template + std::shared_ptr StaticVariadicSplit(ngraph::element::Type_t inputs_type, + Shape data_shape, + Shape axis_shape, + Shape split_lenghts_shape, + std::vector axis_value, + std::vector split_lenghts_value) + { + const auto data = make_shared(inputs_type, data_shape); + const auto axis = op::Constant::create(inputs_type, axis_shape, axis_value); + const auto split_lengths = + op::Constant::create(inputs_type, split_lenghts_shape, split_lenghts_value); + const auto variadic_split = make_shared(data, axis, split_lengths); + return make_shared(variadic_split, ParameterVector{data}); + } + + std::shared_ptr DynamicVariadicSplit(ngraph::element::Type_t inputs_type, + Shape data_shape, + Shape axis_shape, + Shape split_lenghts_shape) + { + const auto data = make_shared(inputs_type, data_shape); + const auto axis = make_shared(inputs_type, axis_shape); + const auto split_lengths = make_shared(inputs_type, split_lenghts_shape); + const auto variadic_split = make_shared(data, axis, split_lengths); + return make_shared(variadic_split, ParameterVector{data, axis, split_lengths}); + } +} // namespace + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_1d_static) +{ + const Shape data_shape{10}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{5, 3, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{5}, {1, 2, 3, 4, 5}); + test_case.add_expected_output(Shape{3}, {6, 7, 8}); + test_case.add_expected_output(Shape{2}, {9, 10}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_1d_dynamic) +{ + const Shape data_shape{10}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{5, 3, 2}; + + const auto f = DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape); + auto test_case = test::TestCase(f); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{5}, {1, 2, 3, 4, 5}); + test_case.add_expected_output(Shape{3}, {6, 7, 8}); + test_case.add_expected_output(Shape{2}, {9, 10}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_0_static) +{ + const Shape data_shape{6, 2}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{0}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{4, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{4, 2}, {1, 2, 3, 4, 5, 6, 7, 8}); + test_case.add_expected_output(Shape{2, 2}, {9, 10, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_0_dynamic) +{ + const Shape data_shape{6, 2}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{0}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{4, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{4, 2}, {1, 2, 3, 4, 5, 6, 7, 8}); + test_case.add_expected_output(Shape{2, 2}, {9, 10, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_1_static) +{ + const Shape data_shape{4, 3}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{1}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{1, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{4, 1}, {1, 4, 7, 10}); + test_case.add_expected_output(Shape{4, 2}, {2, 3, 5, 6, 8, 9, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_2d_axis_1_dynamic) +{ + const Shape data_shape{4, 3}; + const std::vector data{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + const Shape axis_shape{}; // scalar + const std::vector axis_value{1}; + const Shape split_lenghts_shape{2}; + const std::vector split_lenghts{1, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{4, 1}, {1, 4, 7, 10}); + test_case.add_expected_output(Shape{4, 2}, {2, 3, 5, 6, 8, 9, 11, 12}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_0_static) +{ + const Shape data_shape{6, 2, 3, 1}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{3, 1, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output( + Shape{3, 2, 3, 1}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{1, 2, 3, 1}, {18, 19, 20, 21, 22, 23}); + test_case.add_expected_output(Shape{2, 2, 3, 1}, + {24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_0_dynamic) +{ + const Shape data_shape{6, 2, 3, 1}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + const Shape axis_shape{1}; + const std::vector axis_value{0}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{3, 1, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output( + Shape{3, 2, 3, 1}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{1, 2, 3, 1}, {18, 19, 20, 21, 22, 23}); + test_case.add_expected_output(Shape{2, 2, 3, 1}, + {24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35}); + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_1_static) +{ + const Shape data_shape{2, 8, 2, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{1}; + const Shape split_lenghts_shape{4}; + const std::vector split_lenghts{1, 3, 2, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {0, 1, 2, 3, 32, 33, 34, 35}); + test_case.add_expected_output( + Shape{2, 3, 2, 2}, + {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {16, 17, 18, 19, 20, 21, 22, 23, 48, 49, 50, 51, 52, 53, 54, 55}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {24, 25, 26, 27, 28, 29, 30, 31, 56, 57, 58, 59, 60, 61, 62, 63}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_1_dynamic) +{ + const Shape data_shape{2, 8, 2, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{1}; + const Shape split_lenghts_shape{4}; + const std::vector split_lenghts{1, 3, 2, 2}; + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {0, 1, 2, 3, 32, 33, 34, 35}); + test_case.add_expected_output( + Shape{2, 3, 2, 2}, + {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {16, 17, 18, 19, 20, 21, 22, 23, 48, 49, 50, 51, 52, 53, 54, 55}); + test_case.add_expected_output( + Shape{2, 2, 2, 2}, {24, 25, 26, 27, 28, 29, 30, 31, 56, 57, 58, 59, 60, 61, 62, 63}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_2_static) +{ + const Shape data_shape{2, 1, 6, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{2}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{3, 1, 2}; + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{2, 1, 3, 2}, + {0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{2, 1, 1, 2}, {6, 7, 18, 19}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {8, 9, 10, 11, 20, 21, 22, 23}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_2_dynamic) +{ + const Shape data_shape{2, 1, 6, 2}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{2}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{-1, 1, 2}; // -1 means "all remaining items" + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{2, 1, 3, 2}, + {0, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17}); + test_case.add_expected_output(Shape{2, 1, 1, 2}, {6, 7, 18, 19}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {8, 9, 10, 11, 20, 21, 22, 23}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_3_static) +{ + const Shape data_shape{2, 1, 2, 6}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{3}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{1, -1, 3}; // -1 means "all remaining items" + + auto test_case = test::TestCase(StaticVariadicSplit( + element::i32, data_shape, axis_shape, split_lenghts_shape, axis_value, split_lenghts)); + + test_case.add_input(data_shape, data); + test_case.add_expected_output(Shape{2, 1, 2, 1}, {0, 6, 12, 18}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {1, 2, 7, 8, 13, 14, 19, 20}); + test_case.add_expected_output(Shape{2, 1, 2, 3}, + {3, 4, 5, 9, 10, 11, 15, 16, 17, 21, 22, 23}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, variadic_split_4d_axis_3_dynamic) +{ + const Shape data_shape{2, 1, 2, 6}; + std::vector data(shape_size(data_shape)); + std::iota(data.begin(), data.end(), 0); + + const Shape axis_shape{1}; + const std::vector axis_value{3}; + const Shape split_lenghts_shape{3}; + const std::vector split_lenghts{1, 2, -1}; // -1 means "all remaining items" + + auto test_case = test::TestCase( + DynamicVariadicSplit(element::i32, data_shape, axis_shape, split_lenghts_shape)); + + test_case.add_input(data_shape, data); + test_case.add_input(axis_shape, axis_value); + test_case.add_input(split_lenghts_shape, split_lenghts); + test_case.add_expected_output(Shape{2, 1, 2, 1}, {0, 6, 12, 18}); + test_case.add_expected_output(Shape{2, 1, 2, 2}, {1, 2, 7, 8, 13, 14, 19, 20}); + test_case.add_expected_output(Shape{2, 1, 2, 3}, + {3, 4, 5, 9, 10, 11, 15, 16, 17, 21, 22, 23}); + + test_case.run(); +} \ No newline at end of file diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index adfebe2b57a..03d0185ad8f 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -723,9 +723,6 @@ cum_sum_2dim cum_sum_3d cum_sum_2dim_allmodes -# Unsupported primitive of type: Ceiling -ceiling - # Incorrect dimensions for broadcasting for Add auto_bcast_binary_elementwise_pdpd_dynamic @@ -1529,6 +1526,13 @@ onnx_controlflow_loop_infinite # unsupported dynamic ops onnx_dyn_shapes_reduce_max_dynamic_input_rank_negative_axis IE_GPU.range_v4_trunc_inputs +variadic_split_1d_dynamic +variadic_split_2d_axis_0_dynamic +variadic_split_2d_axis_1_dynamic +variadic_split_4d_axis_0_dynamic +variadic_split_4d_axis_1_dynamic +variadic_split_4d_axis_2_dynamic +variadic_split_4d_axis_3_dynamic # CPU plugin does not support bool type IE_CPU.evaluate_2D_gather_elements_3x2_data_bool diff --git a/ngraph/test/runtime/op/avg_pool.hpp b/ngraph/test/runtime/op/avg_pool.hpp index 1fab6fc25de..701b3e174f3 100644 --- a/ngraph/test/runtime/op/avg_pool.hpp +++ b/ngraph/test/runtime/op/avg_pool.hpp @@ -146,7 +146,9 @@ namespace ngraph bool get_ceil_mode() const; void set_ceil_mode(bool ceil_mode); /// \return The default value for AvgPool. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Shape m_window_shape; diff --git a/ngraph/test/runtime/op/convolution.hpp b/ngraph/test/runtime/op/convolution.hpp index 5ddea7b0f7d..f5d45d26918 100644 --- a/ngraph/test/runtime/op/convolution.hpp +++ b/ngraph/test/runtime/op/convolution.hpp @@ -178,7 +178,9 @@ namespace ngraph const PadType& get_pad_type() const { return m_pad_type; } void set_pad_type(const PadType& pad_type) { m_pad_type = pad_type; } /// \return The default value for Convolution. + NGRAPH_SUPPRESS_DEPRECATED_START virtual std::shared_ptr get_default_value() const override; + NGRAPH_SUPPRESS_DEPRECATED_END protected: Strides m_window_movement_strides; diff --git a/ngraph/test/type_prop/abs.cpp b/ngraph/test/type_prop/abs.cpp new file mode 100644 index 00000000000..7ef727bdee0 --- /dev/null +++ b/ngraph/test/type_prop/abs.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_abs, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/acos.cpp b/ngraph/test/type_prop/acos.cpp new file mode 100644 index 00000000000..8bff6e06dd9 --- /dev/null +++ b/ngraph/test/type_prop/acos.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_acos, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/asin.cpp b/ngraph/test/type_prop/asin.cpp new file mode 100644 index 00000000000..96293580d57 --- /dev/null +++ b/ngraph/test/type_prop/asin.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_asin, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/assign.cpp b/ngraph/test/type_prop/assign.cpp index 9f8169ae71f..996231175e3 100644 --- a/ngraph/test/type_prop/assign.cpp +++ b/ngraph/test/type_prop/assign.cpp @@ -64,3 +64,26 @@ TEST(type_prop, assign_read_value_new_shape) ASSERT_EQ(variable->get_info().data_type, element::f16); ASSERT_EQ(variable->get_info().data_shape, (PartialShape{3, {4, 5}, 8})); } + +TEST(type_prop, variable_comparison) +{ + auto variable1 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "ID"}); + + auto variable2 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "ID"}); + + auto variable3 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::dynamic, "ID1"}); + + auto variable4 = + std::make_shared(VariableInfo{PartialShape::dynamic(), element::f32, "ID"}); + + auto variable5 = + std::make_shared(VariableInfo{Shape{1}, element::dynamic, "ID"}); + + ASSERT_TRUE(variable1->get_info() == variable2->get_info()); + ASSERT_FALSE(variable1->get_info() == variable3->get_info()); + ASSERT_FALSE(variable1->get_info() == variable4->get_info()); + ASSERT_FALSE(variable1->get_info() == variable5->get_info()); +} \ No newline at end of file diff --git a/ngraph/test/type_prop/ceiling.cpp b/ngraph/test/type_prop/ceiling.cpp new file mode 100644 index 00000000000..f173a031491 --- /dev/null +++ b/ngraph/test/type_prop/ceiling.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_ceiling, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/exp.cpp b/ngraph/test/type_prop/exp.cpp new file mode 100644 index 00000000000..f25c335504e --- /dev/null +++ b/ngraph/test/type_prop/exp.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_exp, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/floor.cpp b/ngraph/test/type_prop/floor.cpp new file mode 100644 index 00000000000..3eca60835f0 --- /dev/null +++ b/ngraph/test/type_prop/floor.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_floor, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/gather.cpp b/ngraph/test/type_prop/gather.cpp index 70bfc8530ee..96b2bbff832 100644 --- a/ngraph/test/type_prop/gather.cpp +++ b/ngraph/test/type_prop/gather.cpp @@ -13,7 +13,7 @@ using namespace ngraph; // ------------------------------ V1 ------------------------------ -TEST(type_prop, gather_axis_0) +TEST(type_prop, gather_v1_axis_0) { Shape params_shape{3, 2}; Shape indices_shape{2, 2}; @@ -27,7 +27,7 @@ TEST(type_prop, gather_axis_0) ASSERT_EQ(G->get_axis(), 0); } -TEST(type_prop, gather_7_uint8) +TEST(type_prop, gather_v1_uint8) { // Gather_1 must allow even if indices is not int32/int64 PartialShape data_shape{3, 2}; @@ -44,7 +44,7 @@ TEST(type_prop, gather_7_uint8) ASSERT_EQ(G->get_axis(), 0); } -TEST(type_prop, gather_7_float32) +TEST(type_prop, gather_v1_float32) { // Gather_1 should allow non int32/int64 indices PartialShape data_shape{3, 2}; @@ -335,7 +335,7 @@ TEST(type_prop, gather_7_axis_not_set_positive_batch_dims) ASSERT_EQ(G->get_output_partial_shape(0), out_shape); } -// --------------------- Negative tests ------------------------------ +// --------------------- V7 Negative tests ------------------------------ TEST(type_prop, gather_7_incorrect_axis_shape) { @@ -470,8 +470,7 @@ TEST(type_prop, gather_7_batch_dims_less_indices_rank_check) } } -// disabled until decision of type constrains for gather -TEST(type_prop, DISABLED_gather_7_indices_type_check) +TEST(type_prop, gather_7_indices_type_check) { PartialShape data_shape{1, 20, 20, 22, 22}; PartialShape indices_shape{1, 3}; @@ -500,8 +499,7 @@ TEST(type_prop, DISABLED_gather_7_indices_type_check) } } -// disabled until decision of type constrains for gather -TEST(type_prop, DISABLED_gather_7_axis_type_check) +TEST(type_prop, gather_7_axis_type_check) { PartialShape data_shape{1, 20, 20, 22, 22}; PartialShape indices_shape{1, 3}; @@ -529,3 +527,402 @@ TEST(type_prop, DISABLED_gather_7_axis_type_check) FAIL() << "Deduced type check failed for unexpected reason"; } } + +// ------------------------------ V8 ------------------------------ + +TEST(type_prop, gather_v8_axis_0) +{ + PartialShape data_shape{3, 2}; + PartialShape indices_shape{2, 2}; + PartialShape out_shape{2, 2, 2}; + int64_t batch_dims = 0; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i32, indices_shape); + auto A = op::Constant::create(element::i64, Shape{}, {0}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); + ASSERT_EQ(G->get_axis(), 0); +} + +TEST(type_prop, gather_v8_axis_1) +{ + PartialShape data_shape{3, 3}; + PartialShape indices_shape{1, 2}; + PartialShape out_shape{3, 1, 2}; + int64_t axis = 1; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i32, indices_shape); + auto A = op::Constant::create(element::i64, Shape{}, {axis}); + auto G = make_shared(D, I, A); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); + ASSERT_EQ(G->get_axis(), 1); +} + +TEST(type_prop, gather_v8_negative_axis) +{ + PartialShape data_shape{5, 6, 7}; + PartialShape indices_shape{4}; + PartialShape out_shape{5, 4, 7}; + int64_t axis = -2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A); + + ASSERT_EQ(G->get_axis(), 1); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_pshape_batch_dims_1_axis_1) +{ + PartialShape data_shape{Dimension(1, 7), 20, 20}; + PartialShape indices_shape{Dimension(7, 10), 3, 8}; + PartialShape out_shape{7, 3, 8, 20}; + int64_t axis = 1; + int64_t batch_dims = 1; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_pshape_batch_dims_1_axis_3) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape{Dimension(7, 10), Dimension(2, 10), 3, 8}; + PartialShape out_shape{7, Dimension(1, 3), 200, Dimension(2, 10), 3, 8}; + int64_t axis = 3; + int64_t batch_dims = 1; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_2d_pshape_batch_dim) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape{Dimension(7, 10), Dimension(2, 10), 3, 8}; + PartialShape out_shape{7, Dimension(2, 3), 3, 8, 400}; + int64_t axis = 2; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_2d_pshape_batch_dim_axis_3) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape{Dimension(7, 10), Dimension(2, 10), 3, 8}; + PartialShape out_shape{7, Dimension(2, 3), 200, 3, 8}; + int64_t axis = 3; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_rank) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape = PartialShape::dynamic(Rank(3, 5)); + PartialShape out_shape = PartialShape::dynamic(Rank(4, 6)); + int64_t axis = 3; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_axis_boundcheck_for_dynamic_data_rank) +{ + PartialShape data_shape = PartialShape::dynamic(); + PartialShape indices_shape{7, 3, 8}; + PartialShape out_shape = PartialShape::dynamic(); + int64_t axis = 3; + int64_t batch_dims = 2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_dynamic_rank_negative_batch_dims) +{ + PartialShape data_shape{Dimension(1, 7), Dimension(1, 3), 200, 400}; + PartialShape indices_shape = PartialShape::dynamic(Rank(3, 5)); + PartialShape out_shape = PartialShape::dynamic(Rank(3, 5)); + int64_t axis = 3; + int64_t batch_dims = -2; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_axis_not_set) +{ + PartialShape data_shape{1, 1, 200, 400}; + PartialShape indices_shape{2, 2}; + // default batch_dims = 0 + PartialShape out_shape = PartialShape::dynamic(5); // out_rank = data_rank + indices_rank - 1 - batch_dims + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i32, Shape{1}); + auto G = make_shared(D, I, A); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +TEST(type_prop, gather_v8_axis_not_set_positive_batch_dims) +{ + PartialShape data_shape{2, 1, 200, 400}; + PartialShape indices_shape{2, 2}; + int64_t batch_dims = 1; + PartialShape out_shape = PartialShape({2, + Dimension::dynamic(), + Dimension::dynamic(), + Dimension::dynamic()}); + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + auto A = make_shared(element::i32, Shape{1}); + auto G = make_shared(D, I, A, batch_dims); + + ASSERT_EQ(G->get_element_type(), element::f32); + ASSERT_EQ(G->get_output_partial_shape(0), out_shape); +} + +// --------------------- V8 Negative tests ------------------------------ + +TEST(type_prop, gather_v8_incorrect_axis_shape) +{ + auto D = make_shared(element::f32, Shape{5, 6}); + auto I = make_shared(element::i64, Shape{4}); + auto A = make_shared(element::i64, Shape{2}); + + try + { + auto G = make_shared(D, I, A); + // Should have thrown, so fail if it didn't + FAIL() << "Incorrect A input shape"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING(error.what(), + std::string("Axis input must be scalar or have 1 element")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_axis_out_of_input_rank) +{ + auto D = make_shared(element::f32, Shape{5, 6}); + auto I = make_shared(element::i64, Shape{4}); + auto A = make_shared(element::i64, Shape{1}, vector{2}); + int64_t batch_dims = 0; + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "axis check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), std::string("Normalized axis must be >= 0 and < data_rank. But instead got")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_dynamic_batch_dims_inconsistent) +{ + PartialShape data_shape{Dimension(1, 7), 20, 20}; + PartialShape indices_shape{Dimension(8, 10), 3, 8}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + int64_t axis = 1; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 1; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "Shape inconsistency check for dynamic PartialShape failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("data and indices must have equal or intersecting sizes until batch_dims")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_batch_dims_less_check) +{ + PartialShape data_shape{1, 3, 20}; + PartialShape indices_shape{1, 3, 8}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + int64_t axis = 1; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 2; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "batch_dims check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("After normalization batch_dims must be <= axis. But instead got: batch_dims =")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_batch_dims_less_indices_rank_check) +{ + PartialShape data_shape{1, 20, 20, 22, 22}; + PartialShape indices_shape{1, 3}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i64, indices_shape); + int64_t axis = 4; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 3; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "batch_dims check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("batch_dims must be <= indices_rank")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_indices_type_check) +{ + PartialShape data_shape{1, 20, 20, 22, 22}; + PartialShape indices_shape{1, 3}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::f32, indices_shape); + int64_t axis = 4; + auto A = make_shared(element::i64, Shape{1}, vector{axis}); + int64_t batch_dims = 0; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "indices element_type check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("Indices element type must be of an integral number type")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} + +TEST(type_prop, gather_v8_axis_type_check) +{ + PartialShape data_shape{1, 20, 20, 22, 22}; + PartialShape indices_shape{1, 3}; + + auto D = make_shared(element::f32, data_shape); + auto I = make_shared(element::i32, indices_shape); + int64_t axis = 4; + auto A = make_shared(element::f32, Shape{1}, vector{axis}); + int64_t batch_dims = 0; + + try + { + auto G = make_shared(D, I, A, batch_dims); + // Should have thrown, so fail if it didn't + FAIL() << "axis element_type check failed"; + } + catch (const NodeValidationFailure& error) + { + EXPECT_HAS_SUBSTRING( + error.what(), + std::string("Axis element type must be of an integral number type")); + } + catch (...) + { + FAIL() << "Deduced type check failed for unexpected reason"; + } +} diff --git a/ngraph/test/type_prop/sin.cpp b/ngraph/test/type_prop/sin.cpp new file mode 100644 index 00000000000..ab777d9a442 --- /dev/null +++ b/ngraph/test/type_prop/sin.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_sin, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/sqrt.cpp b/ngraph/test/type_prop/sqrt.cpp new file mode 100644 index 00000000000..48a5ce13a85 --- /dev/null +++ b/ngraph/test/type_prop/sqrt.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "unary_ops.hpp" + +using Type = ::testing::Types; + +INSTANTIATE_TYPED_TEST_CASE_P(type_prop_sqrt, UnaryOperator, Type); diff --git a/ngraph/test/type_prop/unary_ops.cpp b/ngraph/test/type_prop/unary_ops.hpp similarity index 94% rename from ngraph/test/type_prop/unary_ops.cpp rename to ngraph/test/type_prop/unary_ops.hpp index 788b50917fa..e8babcba406 100644 --- a/ngraph/test/type_prop/unary_ops.cpp +++ b/ngraph/test/type_prop/unary_ops.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -95,7 +95,3 @@ REGISTER_TYPED_TEST_CASE_P(UnaryOperator, dynamic_rank_input_shape_2D, dynamic_rank_input_shape_3D, dynamic_rank_input_shape_full); - -using Types = ::testing::Types; - -INSTANTIATE_TYPED_TEST_CASE_P(type_prop, UnaryOperator, Types); diff --git a/ngraph/test/visitors/op/ceiling.cpp b/ngraph/test/visitors/op/ceiling.cpp new file mode 100644 index 00000000000..34ed3b653b3 --- /dev/null +++ b/ngraph/test/visitors/op/ceiling.cpp @@ -0,0 +1,26 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; + +TEST(attributes, ceiling_op) +{ + NodeBuilder::get_ops().register_factory(); + const auto A = make_shared(element::f32, Shape{5, 2}); + + const auto ceiling = make_shared(A); + NodeBuilder builder(ceiling); + + const auto expected_attr_count = 0; + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} diff --git a/ngraph/test/visitors/op/gather.cpp b/ngraph/test/visitors/op/gather.cpp index 3e6446a07b8..c162d8949ff 100644 --- a/ngraph/test/visitors/op/gather.cpp +++ b/ngraph/test/visitors/op/gather.cpp @@ -7,6 +7,7 @@ #include "ngraph/ngraph.hpp" #include "ngraph/opsets/opset1.hpp" #include "ngraph/opsets/opset7.hpp" +#include "ngraph/opsets/opset8.hpp" #include "util/visitor.hpp" @@ -29,3 +30,18 @@ TEST(attributes, gather_v7_op) EXPECT_EQ(g_gather->get_batch_dims(), gather->get_batch_dims()); } + +TEST(attributes, gather_v8_op) +{ + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::i32, Shape{2, 3, 4}); + auto indices = make_shared(element::i32, Shape{2}); + auto axis = make_shared(element::i32, Shape{}, 2); + int64_t batch_dims = 1; + + auto gather = make_shared(data, indices, axis, batch_dims); + NodeBuilder builder(gather); + auto g_gather = as_type_ptr(builder.create()); + + EXPECT_EQ(g_gather->get_batch_dims(), gather->get_batch_dims()); +} diff --git a/ngraph/test/visitors/op/variadic_split.cpp b/ngraph/test/visitors/op/variadic_split.cpp new file mode 100644 index 00000000000..ae4b0c8c2d6 --- /dev/null +++ b/ngraph/test/visitors/op/variadic_split.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +#include "ngraph/ngraph.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "ngraph/opsets/opset1.hpp" + +#include "util/visitor.hpp" + +using namespace std; +using namespace ngraph; +using ngraph::test::NodeBuilder; +using ngraph::test::ValueMap; + +TEST(attributes, variadic_split_op) +{ + using namespace opset1; + + NodeBuilder::get_ops().register_factory(); + auto data = make_shared(element::i32, Shape{200}); + auto axis = make_shared(element::i32, Shape{1}); + auto split_lengths = make_shared(element::i32, Shape{1}); + + auto split = make_shared(data, axis, split_lengths); + NodeBuilder builder(split); + const auto expected_attr_count = 0; + + EXPECT_EQ(builder.get_value_map_size(), expected_attr_count); +} diff --git a/tests/layer_tests/tensorflow_tests/test_tf_Roll.py b/tests/layer_tests/tensorflow_tests/test_tf_Roll.py new file mode 100644 index 00000000000..340adcc1eca --- /dev/null +++ b/tests/layer_tests/tensorflow_tests/test_tf_Roll.py @@ -0,0 +1,42 @@ +import pytest +import tensorflow as tf +from common.tf_layer_test_class import CommonTFLayerTest + + +class TestTFRoll(CommonTFLayerTest): + def create_tf_roll_net(self, shift, axis, x_shape, input_type, ir_version): + tf.compat.v1.reset_default_graph() + + # Create the graph and model + with tf.compat.v1.Session() as sess: + tf_x_shape = x_shape.copy() + # reshaping + if len(tf_x_shape) >= 3: + tf_x_shape.append(tf_x_shape.pop(1)) + + x = tf.compat.v1.placeholder(input_type, tf_x_shape, 'Input') + roll = tf.roll(x, shift=shift, axis=axis) + + tf.compat.v1.global_variables_initializer() + tf_net = sess.graph_def + + # TODO: add reference IR net. Now it is omitted and tests only inference result that is more important + ref_net = None + + return tf_net, ref_net + + test_data = [dict(shift=[1], axis=[-1], x_shape=[4, 3], input_type=tf.float32), + dict(shift=[1, 5, -7], axis=[0, 1, 1], x_shape=[2, 3, 5], input_type=tf.float16), + dict(shift=[11, -8], axis=[-1, -2], x_shape=[3, 4, 3, 1], input_type=tf.int32), + dict(shift=[7, -2, 5], axis=[0, -1, -1], x_shape=[5, 2, 3, 7], input_type=tf.int64), + dict(shift=[3, 7], axis=[0, 1], x_shape=[2, 4, 3, 5, 4], input_type=tf.half), + pytest.param(dict(shift=[1, -2], axis=[0, 1], x_shape=[2, 4, 3, 5], input_type=tf.float32), + marks=pytest.mark.precommit)] + + @pytest.mark.parametrize("params", test_data) + @pytest.mark.nightly + def test_tf_roll(self, params, ie_device, precision, ir_version, temp_dir): + if ie_device == 'GPU': + pytest.skip("Roll is not supported on GPU") + self._test(*self.create_tf_roll_net(**params, ir_version=ir_version), ie_device, precision, + temp_dir=temp_dir, ir_version=ir_version, **params)