--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This is test set of text generator from DOM entities
+ * ArtifactEntity, ArtifactNamed, ArtifactExpr and ArtifactClassMember
+ * are not tested since they are abstract classes
+ */
+
+#include <sstream>
+
+#include "ArtifactModel.h"
+#include "ArtifactGeneratorCppCode.h"
+#include "ArtifactGeneratorCppDecl.h"
+
+#include "gtest/gtest.h"
+
+using namespace std;
+using namespace nnc;
+
+TEST(acl_backend_dom_to_text, ArtifactLiteral) {
+ stringstream code_out;
+ stringstream decl_out;
+ ArtifactGeneratorCppCode code_gen(code_out);
+ ArtifactGeneratorCppDecl decl_gen(decl_out);
+ const char* data = "hello_world";
+ shared_ptr<ArtifactLiteral> lit = ArtifactFactory::lit(data);
+ lit->accept(&code_gen);
+ lit->accept(&decl_gen);
+ ASSERT_EQ(code_out.str(), data);
+ // TODO why not generate data for literal in decl generator?
+ //ASSERT_EQ(decl_out.str(), data);
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactId) {
+ // TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactRef) {
+ // TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactDeref) {
+ // TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactFunctionCall) {
+ // TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactUnaryExpr) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactBinaryExpr) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactIndex) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactRet) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactBreak) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactCont) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactVariable) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactBlock) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactForLoop) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactIf) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactFunction) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactClassVariable) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactClassFunction) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactClass) {
+ //TODO
+}
+
+TEST(acl_backend_dom_to_text, DISABLED_ArtifactModule) {
+ //TODO
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This test set checks correctness of MIR to DOM transformation
+ */
+
+// system
+#include <functional>
+#include <vector>
+
+// ACL backend
+#include "ArtifactModel.h"
+#include "AclCppOpGenerator.h"
+
+// MIR
+#include "core/modelIR/Graph.h"
+#include "core/modelIR/operations/VariableOp.h"
+#include "core/modelIR/operations/FullyConnectedOp.h"
+#include "core/modelIR/operations/Conv2DOp.h"
+#include "core/modelIR/operations/DepthwiseConv2DOp.h"
+#include "core/modelIR/operations/PoolOp.h"
+#include "core/modelIR/operations/ReluOp.h"
+#include "core/modelIR/operations/ReduceFOp.h"
+#include "core/modelIR/operations/CappedReluOp.h"
+#include "core/modelIR/operations/ReshapeOp.h"
+#include "core/modelIR/operations/ConcatOp.h"
+#include "core/modelIR/operations/BiasAddOp.h"
+#include "core/modelIR/operations/SoftmaxOp.h"
+#include "core/modelIR/operations/ScaleOp.h"
+#include "core/modelIR/operations/EluOp.h"
+#include "core/modelIR/operations/ElementwiseOp.h"
+#include "core/modelIR/operations/Deconv2DOp.h"
+#include "core/modelIR/operations/TanhOp.h"
+#include "core/modelIR/operations/PadOp.h"
+#include "core/modelIR/operations/TransposeOp.h"
+
+#include "gtest/gtest.h"
+
+using namespace std;
+using namespace nnc;
+using namespace mir;
+
+namespace {
+
+using OpConstructor = function<Operation*(Graph& g, vector<IODescriptor>& inputs)>;
+
+const char* artifactName = "nnmodel";
+
+/**
+ * @brief Creates graph with one operation generated by opGen function and returns this operation node
+ * @param g reference to graph which should be filled with operations
+ * @param opConstr functor which creates main operations of graph
+ * @param inputShapes vector of network input shapes
+ * */
+void fillGraph(Graph& g, OpConstructor opConstr, const vector<Shape>& inputShapes) {
+ // Create inputs
+ vector<mir::IODescriptor> inputs;
+ int numInputs = inputShapes.size();
+ for (int i = 0; i < numInputs; ++i) {
+ auto inputOp = g.create<ops::VariableOp>("x" + to_string(i), inputShapes[i]);
+ inputs.push_back(inputOp->getOutput(0));
+ }
+
+ // Create operation
+ Operation* op = opConstr(g, inputs);
+
+ // Mark outputs
+ g.markOutput(op);
+}
+
+/**
+ * @brief Check that artifact DOM has all needed includes
+ * @param m Root module of DOM
+ */
+void checkDomIncludes(const ArtifactModule& m) {
+ // TODO
+}
+
+/**
+ * @brief Check that artifact DOM contains appropriate getters
+ * @param c Main artifact class
+ * @param names List of values accessible via getters
+ */
+void checkDomArtifactGetters(const ArtifactClass& c, const vector<string>& tensors) {
+ // TODO
+}
+
+/**
+ * @brief Check that artifact class constructor initializes all layers
+ * @param c Main artifact class
+ * @param layers List of NN layers
+ */
+void checkDomArtifactConstructor(const ArtifactClass& c, const vector<string>& tensors) {
+ // TODO
+}
+
+/**
+ * @brief Check that inference executes layers in appropriate order
+ * @param f Inference function description
+ * @param layers List of layers in inference
+ */
+void checkDomInference(const ArtifactFunction& f, const vector<string>& layers) {
+ // TODO
+}
+
+/**
+ * @brief Check that artifact DOM contains appropriate class
+ * @param m Root module of DOM
+ */
+void checkArtifactClass(const ArtifactClass& c,
+ const vector<string>& layers,
+ const vector<string>& tensors) {
+ checkDomArtifactGetters(c, tensors);
+ checkDomArtifactConstructor(c, tensors);
+ const ArtifactFunction* inf_func = nullptr;
+ for (const shared_ptr<ArtifactClassFunction>& method: c.publicFunctions()) {
+ if (method->name() == "Inference") {
+ inf_func = method.get();
+ break;
+ }
+ }
+ ASSERT_NE(inf_func, nullptr);
+ checkDomInference(*inf_func, layers);
+}
+
+/**
+ * @brief Root of check functions
+ * @param m Main artifact module
+ */
+void checkDomStructure(const ArtifactModule& m,
+ const vector<string>& layers,
+ const vector<string>& tensors) {
+ ASSERT_EQ(m.name(), artifactName);
+ checkDomIncludes(m);
+ ASSERT_EQ(m.entities().size(), 1);
+ ArtifactClass* cls = dynamic_cast<ArtifactClass*>(m.entities().front().get());
+ ASSERT_NE(cls, nullptr);
+ checkArtifactClass(*cls, layers, tensors);
+}
+
+}
+
+// Actual tests
+
+TEST(acl_backend_mir_to_dom, bias) {
+ const int channels = 2;
+ shared_ptr<float> data(new float[channels], default_delete<float[]>());
+ TensorVariant w({channels}, data, DTYPE::FLOAT32);
+
+ Graph g;
+ OpConstructor opGenerator = [&w](Graph& g, const vector<IODescriptor>& inputs) {
+ return g.create<mir::ops::BiasAddOp>("bias", inputs[0], w);
+ };
+ vector<Shape> inputShapes{{1, 10, 10, channels}};
+
+ fillGraph(g, opGenerator, inputShapes);
+
+ stringstream params_out;
+ AclCppOpGenerator dom_gen(artifactName, params_out);
+
+ const ArtifactModule& m = dom_gen.generate(&g);
+
+ checkDomStructure(m, {}, {});
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_scale) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_capped_relu) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_concat) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_add) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_mul) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_max) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_conv_transposed2d) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_conv2d) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_depthwise_conv) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_fully_connected) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_maxpool) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_avgpool) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_relu) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_elu) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_tanh) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_reduce_mean) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_softmax) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_reshape) {
+ // TODO
+}
+
+TEST(acl_backend_mir_to_dom, DISABLED_pad) {
+ // TODO
+}