/* * Copyright (c) 2019 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. */ #include "TestHelper.h" #include "Importer.h" #include #include #include #include #include #include #include using namespace moco::tf::test; namespace { // clang-format off const char *known_batch_pbtxt = STRING_CONTENT( node { name: "placeholder" op: "Placeholder" attr { key: "dtype" value { type: DT_FLOAT } } attr { key: "shape" value { shape { dim { size: 1024 } dim { size: 2 } dim { size: 3 } dim { size: 4 } } } } } node { name: "output" op: "Identity" input: "placeholder" attr { key: "T" value { type: DT_FLOAT } } } ); // clang-format on } // namespace TEST(TensorFlowImport, placeholder_knwon_batch) { // load graph moco::tf::Importer importer; moco::tf::ModelSignature signature; signature.add_output(moco::tf::TensorName("output", 0)); tensorflow::GraphDef graph_def; EXPECT_TRUE(plier::tf::parse_graphdef(known_batch_pbtxt, graph_def)); std::unique_ptr graph = importer.import(signature, graph_def); // get loco::Pull loco::Graph::NodeContext *loco_nodes = graph->nodes(); loco::Pull *pull_node = dynamic_cast(loco_nodes->at(0)); // Check dim ASSERT_TRUE(pull_node->dim(0).known() && pull_node->dim(0).value() == 1024); ASSERT_TRUE(pull_node->dim(1).known() && pull_node->dim(1).value() == 2); ASSERT_TRUE(pull_node->dim(2).known() && pull_node->dim(2).value() == 3); ASSERT_TRUE(pull_node->dim(3).known() && pull_node->dim(3).value() == 4); }