提交 78fa5e30 编写于 作者: F fengjiayi

Add DDim::size()

上级 78bd815e
...@@ -117,6 +117,8 @@ int DDim::operator[](int idx) const { ...@@ -117,6 +117,8 @@ int DDim::operator[](int idx) const {
return boost::apply_visitor(DynamicConstIndexer(idx), var); return boost::apply_visitor(DynamicConstIndexer(idx), var);
} }
ssize_t DDim::size() const { return arity(*this); }
bool DDim::operator==(DDim d) const { bool DDim::operator==(DDim d) const {
if (var.which() != d.getVar().which()) { if (var.which() != d.getVar().which()) {
return false; return false;
......
...@@ -50,6 +50,8 @@ struct DDim { ...@@ -50,6 +50,8 @@ struct DDim {
DDimVar getVar() { return var; } DDimVar getVar() { return var; }
ssize_t size() const;
bool operator==(DDim d) const; bool operator==(DDim d) const;
bool operator!=(DDim d) const; bool operator!=(DDim d) const;
......
...@@ -49,6 +49,7 @@ TEST(DDim, Equality) { ...@@ -49,6 +49,7 @@ TEST(DDim, Equality) {
// arity of a DDim // arity of a DDim
EXPECT_EQ(paddle::framework::arity(ddim), 3); EXPECT_EQ(paddle::framework::arity(ddim), 3);
EXPECT_EQ(ddim.size(), 3);
// product of a DDim // product of a DDim
EXPECT_EQ(paddle::framework::product(vddim), 45); EXPECT_EQ(paddle::framework::product(vddim), 45);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册