-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
130 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::{fs::File, path::PathBuf}; | ||
|
||
use anyhow::Result; | ||
use clap::Parser; | ||
use memmap2::Mmap; | ||
use web_rwkv::converter::{convert_safetensors, RENAME, TRANSPOSE}; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Cli { | ||
#[arg(short, long, value_name = "FILE")] | ||
input: PathBuf, | ||
#[arg(short, long, value_name = "FILE")] | ||
output: Option<PathBuf>, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let cli = Cli::parse(); | ||
|
||
let file = File::open(&cli.input)?; | ||
let map = unsafe { Mmap::map(&file)? }; | ||
|
||
let output = cli.output.unwrap_or_else(|| { | ||
let path = cli | ||
.input | ||
.parent() | ||
.map(|p| p.to_path_buf()) | ||
.unwrap_or_default(); | ||
let stem = cli.input.file_stem().expect("please name the file"); | ||
let name: PathBuf = [&stem.to_string_lossy(), "st"].join(".").into(); | ||
path.join(name) | ||
}); | ||
convert_safetensors(cli.input, &map, output, RENAME, TRANSPOSE)?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters