Upgrade FDASSERT (#97)

* upgrade FDASSERT

* Optimize error message of FDTensor function

* upgrade FDASSERT

Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
Jack Zhou
2022-08-11 19:42:31 +08:00
committed by GitHub
parent d900e8d35e
commit 5c6b3d6150
5 changed files with 54 additions and 32 deletions

View File

@@ -94,10 +94,14 @@ void Transpose(const FDTensor& x, FDTensor* out,
const std::vector<int64_t>& dims) {
size_t dims_size = dims.size();
FDASSERT(dims_size == x.shape.size(),
"The input tensor's dimension should be equal to the dims's size.");
"The input tensor's dimension should be equal to the dims's size. "
"Expect dims size is %d, but receive %d.",
x.shape.size(), dims_size);
std::vector<int> count(dims_size, 0);
for (size_t i = 0; i < dims_size; i++) {
FDASSERT(dims[i] >= 0, "The dims should be greater than or equal to 0.");
FDASSERT(dims[i] >= 0,
"The dims should be greater than or equal to 0, but receive %d.",
dims[i]);
FDASSERT(dims[i] < static_cast<int>(dims_size) && ++count[dims[i]] == 1,
"Each element of Attribute axis should be a unique value range "
"from 0 to (dims - 1), where the dims is the axis's size, unique "