Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2018-08-06 03:43:45 +0300
committerMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2018-08-06 03:43:45 +0300
commit08361fd10f1bc5910e4101d1a6efd6033bbad545 (patch)
treef745f21a6c0a3d82bbb6f3aabff2697e8e6bbb43
parentc879ee2d787a1d8d1cbbe1488b8d9973081ecb22 (diff)
fix dimension
-rw-r--r--src/common/io.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/common/io.cpp b/src/common/io.cpp
index ee29f76d..d4f5e248 100644
--- a/src/common/io.cpp
+++ b/src/common/io.cpp
@@ -62,14 +62,15 @@ void addMetaToItems(const std::string& meta,
const std::string& varName,
std::vector<io::Item>& items) {
Item item;
-
item.name = varName;
// increase size by 1 to add \0
item.shape = Shape({(int)meta.size() + 1});
- item.bytes.resize(item.shape[0]);
- std::copy(meta.begin(), meta.end() + item.shape[0], item.bytes.begin());
+ item.bytes.resize(item.shape.elements());
+ std::copy(meta.begin(), meta.end(), item.bytes.begin());
+ // set string terminator
+ item.bytes.back() = '\0';
item.type = Type::int8;
@@ -133,22 +134,17 @@ void saveItemsNpz(const std::string& fileName, const std::vector<Item>& items) {
std::vector<cnpy::NpzItem> npzItems;
for(auto& item : items) {
std::vector<unsigned int> shape(item.shape.begin(), item.shape.end());
+ char type = 'f';
+
if(item.type == Type::float32)
- npzItems.emplace_back(item.name,
- item.bytes,
- shape,
- cnpy::map_type(typeid(float)),
- sizeOf(Type::float32));
- else if(item.type == Type::int8) {
- npzItems.emplace_back(item.name,
- item.bytes,
- shape,
- cnpy::map_type(typeid(char)),
- sizeOf(Type::int8));
- }
- else {
- ABORT("Type currently not supported");
- }
+ type = cnpy::map_type(typeid(float));
+ else if(item.type == Type::uint8)
+ type = cnpy::map_type(typeid(char));
+ else
+ ABORT("Other types not supported yet");
+
+ npzItems.emplace_back(item.name, item.bytes, shape, type, sizeOf(item.type));
+
}
cnpy::npz_save(fileName, npzItems);
}