disallowing zero sized tensors

This commit is contained in:
alexander-g
2021-01-30 19:41:47 +01:00
parent acc3e96227
commit a995cbf9ec
2 changed files with 23 additions and 1 deletions

View File

@@ -113,3 +113,21 @@ TEST(TestOpTensorCreate, NoErrorIfTensorFreedBefore)
EXPECT_FALSE(tensorA->isInit());
EXPECT_FALSE(tensorB->isInit());
}
TEST(TestOpTensorCreate, ExceptionOnZeroSizeTensor)
{
std::vector<float> testVecA;
std::shared_ptr<kp::Tensor> tensorA{ new kp::Tensor(testVecA) };
kp::Manager mgr;
try{
mgr.evalOpDefault<kp::OpTensorCreate>({ tensorA });
} catch( const std::runtime_error& err ) {
// check exception
ASSERT_STREQ("Kompute Tensor attempted to create a zero-sized buffer", err.what() );
}
}