Also add a test that reshapes a blob to shape (0, 5).
int* shape_data = static_cast<int*>(shape_data_->mutable_cpu_data());
for (int i = 0; i < shape.size(); ++i) {
CHECK_GE(shape[i], 0);
- CHECK_LE(shape[i], INT_MAX / count_) << "blob size exceeds INT_MAX";
+ if (count_ != 0) {
+ CHECK_LE(shape[i], INT_MAX / count_) << "blob size exceeds INT_MAX";
+ }
count_ *= shape[i];
shape_[i] = shape[i];
shape_data[i] = shape[i];
EXPECT_EQ(this->blob_->count(), 120);
}
+TYPED_TEST(BlobSimpleTest, TestReshapeZero) {
+ vector<int> shape(2);
+ shape[0] = 0;
+ shape[1] = 5;
+ this->blob_->Reshape(shape);
+ EXPECT_EQ(this->blob_->count(), 0);
+}
+
TYPED_TEST(BlobSimpleTest, TestLegacyBlobProtoShapeEquals) {
BlobProto blob_proto;