Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16125
Add defined() method to check whether the Tensor is defined.
Reviewed By: ezyang
Differential Revision:
D13719222
fbshipit-source-id:
ff8efef2159ed1026bd16acaea40c768a1e20a47
EXPECT_EQ(tensor.numel(), large_number * 100);
}
+TEST(TensorTest, UndefinedTensor) {
+ Tensor x;
+ EXPECT_FALSE(x.defined());
+}
+
TEST(TensorDeathTest, CannotCastDownLargeDims) {
int64_t large_number =
static_cast<int64_t>(std::numeric_limits<int>::max()) + 1;
return impl_;
}
+ bool defined() const {
+ return impl_;
+ }
+
/**
* Returns a const raw void* pointer of the underlying storage. mutable_data()
* or raw_mutable_data() must have been called prior to this function call.