提交 23e1ddae 编写于 作者: G gineshidalgo99

Check functions give more feedback

上级 13354b93
......@@ -8,52 +8,52 @@ namespace op
{
// CHECK, CHECK_EQ, CHECK_NE, CHECK_LE, CHECK_LT, CHECK_GE, and CHECK_GT
template<typename T>
inline void check(const bool condition, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void check(const bool condition, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (!condition)
error(message, line, function, file);
error("Check failed: " + tToString(message), line, function, file);
}
template<typename T, typename T1, typename T2>
inline void checkE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void checkE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (conditionA != conditionB)
error(message, line, function, file);
error("CheckE failed (" + tToString(conditionA) + " vs. " + tToString(conditionB) + "): " + tToString(message), line, function, file);
}
template<typename T, typename T1, typename T2>
inline void checkNE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void checkNE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (conditionA == conditionB)
error(message, line, function, file);
error("CheckNE failed (" + tToString(conditionA) + " vs. " + tToString(conditionB) + "): " + tToString(message), line, function, file);
}
template<typename T, typename T1, typename T2>
inline void checkLE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void checkLE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (conditionA > conditionB)
error(message, line, function, file);
error("CheckLE failed (" + tToString(conditionA) + " vs. " + tToString(conditionB) + "): " + tToString(message), line, function, file);
}
template<typename T, typename T1, typename T2>
inline void checkLT(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void checkLT(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (conditionA >= conditionB)
error(message, line, function, file);
error("CheckLT failed (" + tToString(conditionA) + " vs. " + tToString(conditionB) + "): " + tToString(message), line, function, file);
}
template<typename T, typename T1, typename T2>
inline void checkGE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void checkGE(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (conditionA < conditionB)
error(message, line, function, file);
error("CheckGE failed (" + tToString(conditionA) + " vs. " + tToString(conditionB) + "): " + tToString(message), line, function, file);
}
template<typename T, typename T1, typename T2>
inline void checkGT(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
void checkGT(const T1& conditionA, const T2& conditionB, const T& message = "", const int line = -1, const std::string& function = "", const std::string& file = "")
{
if (conditionA <= conditionB)
error(message, line, function, file);
error("CheckGT failed (" + tToString(conditionA) + " vs. " + tToString(conditionB) + "): " + tToString(message), line, function, file);
}
}
......
......@@ -19,7 +19,8 @@ namespace op
{
try
{
checkE(netOutputSize, netInputSize, "Net input and output size must be equal.", __LINE__, __FUNCTION__, __FILE__);
checkE(netOutputSize.x, netInputSize.x, "Net input and output size must be equal.", __LINE__, __FUNCTION__, __FILE__);
checkE(netOutputSize.y, netInputSize.y, "Net input and output size must be equal.", __LINE__, __FUNCTION__, __FILE__);
// Properties
for (auto& property : mProperties)
property = 0.;
......
......@@ -22,7 +22,8 @@ namespace op
{
try
{
checkE(netOutputSize, netInputSize, "Net input and output size must be equal.", __LINE__, __FUNCTION__, __FILE__);
checkE(netOutputSize.x, netInputSize.x, "Net input and output size must be equal.", __LINE__, __FUNCTION__, __FILE__);
checkE(netOutputSize.y, netInputSize.y, "Net input and output size must be equal.", __LINE__, __FUNCTION__, __FILE__);
spResizeAndMergeCaffe->setScaleGap(scaleGap);
}
catch (const std::exception& e)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册