Skip to content

Commit

Permalink
Revert the updated bitpack
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed Jun 19, 2019
1 parent 5cb318d commit f20f159
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions tools/onnx2bnn/OnnxConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,16 @@ OnnxConverter::BTensor OnnxConverter::bitpack(OnnxConverter::FTensor ftensor) {
static_assert(std::is_same<bin_t, uint64_t>::value,
"bitpack requires bin_t is 64 bit");

const auto N = Shaper::kn(ftensor.shape);
const auto HWC = Shaper::total(ftensor.shape) / N;
auto c = Shaper::kc(ftensor.shape);

BNN_ASSERT(c % 64 == 0, ftensor.shape);

vector<bin_t> packed_data;
bin_t tmp;

FORZ(n, N) {
FORZS(i, HWC, 128) {
const size_t eff_bits = std::max<size_t>(HWC - i, 128);
pack_64_bitset(&ftensor.data[n * HWC + i], &tmp,
std::min<size_t>(eff_bits, 64));
packed_data.push_back(tmp);
pack_64_bitset(
&ftensor.data[n * HWC + i + 64], &tmp,
std::min<size_t>(std::max<size_t>(0, eff_bits - 64), 64));
packed_data.push_back(tmp);
}
FORZS(i, Shaper::total(ftensor.shape), 64) {
pack_64_bitset(&ftensor.data[i], &tmp);
packed_data.push_back(tmp);
}

Shape shape = {ftensor.shape[0], ftensor.shape[1], ftensor.shape[2],
Expand Down

0 comments on commit f20f159

Please sign in to comment.