5 * Copyright (C) 2018-2019 Intel Corporation.
7 * The source code contained or described herein and all documents
8 * related to the source code ("Material") are owned by Intel Corporation
9 * or its suppliers or licensors. Title to the Material remains with
10 * Intel Corporation or its suppliers and licensors. The Material may
11 * contain trade secrets and proprietary and confidential information
12 * of Intel Corporation and its suppliers and licensors, and is protected
13 * by worldwide copyright and trade secret laws and treaty provisions.
14 * No part of the Material may be used, copied, reproduced, modified,
15 * published, uploaded, posted, transmitted, distributed, or disclosed
16 * in any way without Intel's prior express written permission.
18 * No license under any patent, copyright, trade secret or other
19 * intellectual property right is granted to or conferred upon you by
20 * disclosure or delivery of the Materials, either expressly, by implication,
21 * inducement, estoppel or otherwise. Any license under such intellectual
22 * property rights must be express and approved by Intel in writing.
24 * Include any supplier copyright notices as supplier requires Intel to use.
26 * Include supplier trademarks or logos as supplier requires Intel to use,
27 * preceded by an asterisk. An asterisked footnote can be added as follows:
28 * *Third Party trademarks are the property of their respective owners.
30 * Unless otherwise agreed by Intel in writing, you may not remove or alter
31 * this notice or any other notice embedded in Materials by Intel or Intel's
32 * suppliers or licensors in any way.
35 #include <gtest/gtest.h>
36 #include <tests_common.hpp>
38 #include "parameters.h"
41 using namespace InferenceEngine;
42 using namespace InferenceEngine::details;
47 std::string dataName = "data";
48 std::unique_ptr<Parameters> parameters;
50 explicit LayerBuilder (InferenceEngine::CNNLayer::Ptr createdLayer) : layer(std::move(createdLayer)) {
51 parameters = std::unique_ptr<Parameters>(new Parameters(layer->type));
54 LayerBuilder& setParams(bool valid) {
56 layer->params = parameters->getValidParameters();
58 layer->params = parameters->getInvalidParameters();
63 LayerBuilder& setShapes(std::vector<DataPtr>& spData, bool valid_input) {
64 testing::InOutShapes shapes;
65 LayersWithNotEqualIO layersWithNotEqualIO;
66 LayersWithEqualIO layersWithEqualIO;
67 LayersWithNIO layersWithNIO;
68 std::vector<Layers*> layers{&layersWithNotEqualIO, &layersWithEqualIO, &layersWithNIO};
69 ShapesHelper* shapesHelper = nullptr;
70 for(const auto& layer : layers) {
71 if (layer->containLayer(this->layer->type)) {
72 shapesHelper = layer->factoryShape();
77 shapes = shapesHelper->getValidShapes();
79 shapes = shapesHelper->getInvalidInputShapes();
81 for (const auto& inData : shapes.inDims) {
82 DataPtr data = std::make_shared<Data>(dataName, inData, InferenceEngine::Precision::FP32);
83 spData.push_back(data);
84 layer->insData.push_back(data);
86 for (const auto& outData : shapes.outDims) {
87 layer->outData.push_back(std::make_shared<Data>(dataName, outData, InferenceEngine::Precision::FP32));
97 int getNumOfParams() {
98 return parameters->getNumOfParameters();
101 int getNumOfLayerVariant() {
102 LayersWithNotEqualIO layersWithNotEqualIO;
103 LayersWithEqualIO layersWithEqualIO;
104 LayersWithNIO layersWithNIO;
105 Layers* layers[] = {&layersWithNotEqualIO, &layersWithEqualIO, &layersWithNIO};
107 for(const auto& layer : layers) {
108 if (layer->containLayer(this->layer->type)) {
116 class CNNLayerValidationTests : public testing::TestWithParam<std::string>{
118 void SetUp() override {
119 auto params = GetParam();
123 std::shared_ptr<LayerBuilder>& createConcreteLayer(const std::string& type) {
124 layer = std::make_shared<LayerBuilder>(TestsCommon::createLayer(type));
128 std::shared_ptr<LayerBuilder>& getBuilder() {
132 CNNLayerPtr getLayer() {
133 return layer.get()->get();
136 int getNumOfParams() {
137 return layer.get()->getNumOfParams();
140 int getNumOfLayerVariant() {
141 return layer.get()->getNumOfLayerVariant();
145 bool valid_params = true;
146 bool valid_input = true;
147 std::shared_ptr<LayerBuilder> layer;
150 #define assertThat(type) SCOPED_TRACE("");createConcreteLayer(type)