}
}
+std::unique_ptr<loco::TensorShape> make_tensor_shape(const mir::Shape &shape)
+{
+ auto res = stdex::make_unique<loco::TensorShape>();
+ setupShape(shape, res.get());
+ return std::move(res);
+}
+
void setupPad(const std::vector<int32_t> &padding_before, const std::vector<int32_t> &padding_after,
loco::Pad<2> *pad)
{
auto loco_it = _mir2loco_map.find(op.getInput(0)->getProducer()->getNode());
assert(loco_it != _mir2loco_map.end()); // can't find the input
push_node->from(loco_it->second);
- // Set Shape
- const auto &out_shape = op.getInput(0)->getProducer()->getShape();
- setupShape(out_shape, push_node);
// Set graph output
auto graph_output = _loco_graph->outputs()->create();
graph_output->name(op.getName());
graph_output->dtype(loco::DataType::FLOAT32); // TODO Support other types
+ // Set graph output shape
+ const auto &out_shape = op.getInput(0)->getProducer()->getShape();
+ graph_output->shape(make_tensor_shape(out_shape));
loco::link(graph_output, push_node);
// Add to map
_mir2loco_map.emplace(&op, push_node);
ASSERT_EQ(pull_node->dim(2), 7);
ASSERT_EQ(pull_node->dim(3), 8);
- ASSERT_EQ(push_node->rank(), 4);
- ASSERT_EQ(push_node->dim(0), 5);
- ASSERT_EQ(push_node->dim(1), 6);
- ASSERT_EQ(push_node->dim(2), 7);
- ASSERT_EQ(push_node->dim(3), 8);
+ ASSERT_TRUE(push_node->indexed());
+ ASSERT_EQ(push_node->index(), 0);
+
+ // Check Graph-level properties
+ ASSERT_EQ(loco_graph->outputs()->size(), 1);
+ ASSERT_NE(loco_graph->outputs()->at(0)->shape(), nullptr);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->rank(), 4);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(0), 5);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(1), 6);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(2), 7);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(3), 8);
}
TEST_F(TestTransformer_mir2loco, Relu_Test)
ASSERT_EQ(pull_node->dim(2), 9);
ASSERT_EQ(pull_node->dim(3), 9);
- ASSERT_EQ(push_node->rank(), 4);
- ASSERT_EQ(push_node->dim(0), 7);
- ASSERT_EQ(push_node->dim(1), 7);
- ASSERT_EQ(push_node->dim(2), 9);
- ASSERT_EQ(push_node->dim(3), 9);
+ ASSERT_TRUE(push_node->indexed());
+ ASSERT_EQ(push_node->index(), 0);
+
+ // Check Graph-level properties
+ ASSERT_EQ(loco_graph->outputs()->size(), 1);
+ ASSERT_NE(loco_graph->outputs()->at(0)->shape(), nullptr);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->rank(), 4);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(0), 7);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(1), 7);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(2), 9);
+ ASSERT_EQ(loco_graph->outputs()->at(0)->shape()->dim(3), 9);
}
TEST_F(TestTransformer_mir2loco, Avg_Pool_Test)