Add DDim::size()

cblas_new
fengjiayi 8 years ago
parent 78bd815e85
commit 78fa5e307d

@ -117,6 +117,8 @@ int DDim::operator[](int idx) const {
return boost::apply_visitor(DynamicConstIndexer(idx), var);
}
ssize_t DDim::size() const { return arity(*this); }
bool DDim::operator==(DDim d) const {
if (var.which() != d.getVar().which()) {
return false;

@ -50,6 +50,8 @@ struct DDim {
DDimVar getVar() { return var; }
ssize_t size() const;
bool operator==(DDim d) const;
bool operator!=(DDim d) const;

@ -49,6 +49,7 @@ TEST(DDim, Equality) {
// arity of a DDim
EXPECT_EQ(paddle::framework::arity(ddim), 3);
EXPECT_EQ(ddim.size(), 3);
// product of a DDim
EXPECT_EQ(paddle::framework::product(vddim), 45);

Loading…
Cancel
Save