提交 5139e6c7 编写于 作者: Y Yang Yu

Follow comments

上级 d0cc7cc2
...@@ -59,11 +59,11 @@ static void CreateTensor(Variable* var, proto::VarDesc::VarType var_type) { ...@@ -59,11 +59,11 @@ static void CreateTensor(Variable* var, proto::VarDesc::VarType var_type) {
static void CheckTensorNANOrInf(const std::string& name, static void CheckTensorNANOrInf(const std::string& name,
const framework::Tensor& tensor) { const framework::Tensor& tensor) {
if (tensor.type().hash_code() != typeid(float).hash_code() && if (tensor.memory_size() == 0) {
tensor.type().hash_code() != typeid(double).hash_code()) {
return; return;
} }
if (tensor.memory_size() == 0) { if (tensor.type().hash_code() != typeid(float).hash_code() &&
tensor.type().hash_code() != typeid(double).hash_code()) {
return; return;
} }
PADDLE_ENFORCE(!framework::HasInf(tensor), "Tensor %s has Inf", name); PADDLE_ENFORCE(!framework::HasInf(tensor), "Tensor %s has Inf", name);
......
...@@ -210,10 +210,10 @@ inline void CopyToVector(const Tensor& src, std::vector<T>* dst) { ...@@ -210,10 +210,10 @@ inline void CopyToVector(const Tensor& src, std::vector<T>* dst) {
} }
// Returns true if a tensor contains NAN, i.e., Not A Number. // Returns true if a tensor contains NAN, i.e., Not A Number.
extern bool HasNAN(const framework::Tensor& tensor); bool HasNAN(const framework::Tensor& tensor);
// Returns true if a tensor contains Inf, i.e., Infinity. // Returns true if a tensor contains Inf, i.e., Infinity.
extern bool HasInf(const framework::Tensor& tensor); bool HasInf(const framework::Tensor& tensor);
inline void SerializeToStream(std::ostream& os, const Tensor& tensor, inline void SerializeToStream(std::ostream& os, const Tensor& tensor,
const platform::DeviceContext& dev_ctx) { const platform::DeviceContext& dev_ctx) {
......
...@@ -231,7 +231,7 @@ TEST(CopyToVector, Tensor) { ...@@ -231,7 +231,7 @@ TEST(CopyToVector, Tensor) {
#endif #endif
} }
TEST(IsNAN, CPU) { TEST(HasNAN, CPU) {
using namespace paddle::framework; using namespace paddle::framework;
using namespace paddle::platform; using namespace paddle::platform;
Tensor src; Tensor src;
...@@ -243,7 +243,7 @@ TEST(IsNAN, CPU) { ...@@ -243,7 +243,7 @@ TEST(IsNAN, CPU) {
ASSERT_TRUE(HasNAN(src)); ASSERT_TRUE(HasNAN(src));
} }
TEST(IsInf, CPU) { TEST(HasInf, CPU) {
using namespace paddle::framework; using namespace paddle::framework;
using namespace paddle::platform; using namespace paddle::platform;
Tensor src; Tensor src;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册