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

Support no_std #544

Open
ivila opened this issue Dec 2, 2024 · 0 comments
Open

Support no_std #544

ivila opened this issue Dec 2, 2024 · 0 comments

Comments

@ivila
Copy link

ivila commented Dec 2, 2024

Feature request

make safetensors crate support no_std feature.

Motivation

Safetensors is used by some other crates, and some of them support no_std feature, for example, the dfdx, however, currently safetensors do not support no_std, so people cannot use dfdx to export model at no_std environment.

Your contribution

Currently I make a patch in my own git repository, adding a no_std feature and:

  1. when enable no_std, swtich from HashMap to hashbrown::HashMap
  2. change some types or macros from std to alloc:
    1. String => alloc::string::String
    2. format! => alloc::format!
    3. Vec => alloc::vec::Vec
    4. vec! => alloc::vec!
    5. std::borrow::Cow => alloc::borrow::Cow
  3. change some traits or types from std to core:
    1. std::ops => core::ops
    2. std::fmt::Display => core::fmt::Display
    3. std::error::Error => core::error::Error
    4. std::str => core::str
  4. switch serde and serde_json to no_std
  5. when enable, remove some dependencies of std:
    1. remove the IoError in std::io::Error
    2. remove methods that loads from or writes to file (serialize_to_file)

I would like to create a PR if you allow.

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