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

Fix type name again #111

Merged
merged 2 commits into from
May 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion macro/src/type_check_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use quote::quote;
use std::error::Error;

const FLOAT_8E5M2_PATTERN: &str = "8_e_5_m_2";
const FLOAT_8E4M3_FN_PATTERN: &str = "8_e_4_m_3";

pub fn generate(identifiers: &[Ident]) -> Result<TokenStream, Box<dyn Error>> {
let mut stream = TokenStream::new();
Expand Down Expand Up @@ -35,6 +36,11 @@ pub fn generate(identifiers: &[Ident]) -> Result<TokenStream, Box<dyn Error>> {
fn map_type_name(name: &str) -> String {
match name {
"bf_16" | "f_16" | "f_32" | "f_64" => name.replace('_', ""),
name => name.replace(FLOAT_8E5M2_PATTERN, &FLOAT_8E5M2_PATTERN.replace('_', "")),
name => name
.replace(FLOAT_8E5M2_PATTERN, &FLOAT_8E5M2_PATTERN.replace('_', ""))
.replace(
FLOAT_8E4M3_FN_PATTERN,
&FLOAT_8E4M3_FN_PATTERN.replace('_', ""),
),
}
}