Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a sample of cnpy load int8_t npy #99

Open
lix19937 opened this issue Nov 15, 2024 · 0 comments
Open

a sample of cnpy load int8_t npy #99

lix19937 opened this issue Nov 15, 2024 · 0 comments

Comments

@lix19937
Copy link

  #include "cnpy.h"
  
  auto readnpy_int8_t = [](const std::string &npy_name, int read_num) -> std::vector<int8_t>
  {
    cnpy::NpyArray arr = cnpy::npy_load(npy_name);
    std::vector<int8_t> read_vec(read_num);
    auto loaded_data = arr.data<int8_t>();

    for (int i = 0; i < read_num; ++i)
    {
      read_vec[i] = loaded_data[i];
    }
    return read_vec;
  };
  std::vector<int8_t> data_vec = readnpy_int8_t("./out.npy", h * w);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant