Closed igsha closed 6 years ago
I use TensorHeader struct to parse dat-files of tensor weights coefficients. Its definition is in file parser/cpp/common/binary.h.
TensorHeader
parser/cpp/common/binary.h
This is my code to write tensor weights:
std::ofstream file(filename, std::ios::binary); nnef::Shape nnef_shape(...); ... nnef::TensorHeader header; size_t version[] = {1, 0}; nnef::fill_tensor_header(header, version, nnef_shape.rank(), nnef_shape.extents(), 8 * sizeof(float), nnef::TensorHeader::Float); file.write(reinterpret_cast<const char*>(&header), sizeof(header)); file.write(reinterpret_cast<const char*>(data), sizeof(float) * nnef_shape.volume());
But it writes incomplete header: there is no extents (dimentsions) values in the file. That's why I have to add something like this in my code (before calling file.write):
extents
file.write
std::copy_n(nnef_shape.extents(), nnef.shape.rank(), header.extents);
It seems there is some problem in nnef::fill_tensor_header function.
nnef::fill_tensor_header
You are right, there was a bug in the copy, fixed just now.
Checked your last commit. It works. Thanks!
I use
TensorHeader
struct to parse dat-files of tensor weights coefficients. Its definition is in fileparser/cpp/common/binary.h
.This is my code to write tensor weights:
But it writes incomplete header: there is no
extents
(dimentsions) values in the file. That's why I have to add something like this in my code (before callingfile.write
):It seems there is some problem in
nnef::fill_tensor_header
function.