Dims<4> shapeToDims(const Shape &s)
{
Dims<4> dims;
- int rank = s.getDims();
- assert(rank == 4);
+ const int rank = s.getDims();
+ assert(rank >= 1 && rank <= 4);
int stride = 1;
for (int i = 0; i < rank; ++i)
{
dims.strides[i] = stride;
stride *= s[rank - 1 - i];
}
+ for (int i = rank; i < 4; ++i)
+ {
+ dims.sizes[i] = 1;
+ dims.strides[i] = stride;
+ }
return dims;
}
void serializeShape(const nncc::core::ADT::tensor::Shape &s);
void serializeTensor(const contrib::core::ADT::TensorVariant &t);
template <class Op>
- void serializePads(const Op &op, uint32_t padsRank);
+ void serializePads(const Op &op, int32_t padsRank);
ModelAnalyzer::OpDescr *_curOp;
const uint32_t _formatVersion = 1;
void Serializer::serializeShape(const Shape &s)
{
- uint32_t rank = s.rank();
+ int32_t rank = s.rank();
assert(rank < MAX_DIMS);
serializeT<char>(s.rank());
- for (uint32_t i = 0; i < rank; ++i)
+ for (int32_t i = 0; i < rank; ++i)
{
- uint32_t dim = s.dim(i);
+ int32_t dim = s.dim(i);
serializeT(dim);
}
}
}
template<class Op>
-void Serializer::serializePads(const Op &op, uint32_t padsRank)
+void Serializer::serializePads(const Op &op, int32_t padsRank)
{
// serialize padding type
assert(etoi(op.getPaddingType()) < MAX_ENUM_VAL);