mirror of
https://github.com/pykeio/ort
synced 2026-04-25 16:34:55 +02:00
refactor: use rust 1.88 features
This commit is contained in:
@@ -323,11 +323,11 @@ pub fn static_link(base_lib_dir: &Path) -> bool {
|
||||
for entry in glob::glob(&pattern).unwrap() {
|
||||
match entry {
|
||||
Ok(path) => {
|
||||
if let Some(lib_name) = path.file_name() {
|
||||
if let Some(lib_name_str) = lib_name.to_str() {
|
||||
let lib_name = lib_name_str.trim_start_matches("lib").trim_end_matches(".a");
|
||||
println!("cargo:rustc-link-lib=static={}", lib_name);
|
||||
}
|
||||
if let Some(lib_name) = path.file_name()
|
||||
&& let Some(lib_name_str) = lib_name.to_str()
|
||||
{
|
||||
let lib_name = lib_name_str.trim_start_matches("lib").trim_end_matches(".a");
|
||||
println!("cargo:rustc-link-lib=static={}", lib_name);
|
||||
}
|
||||
}
|
||||
Err(e) => eprintln!("error matching file: {}", e)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
@@ -92,10 +92,10 @@ impl Drop for Environment {
|
||||
/// Gets a reference to the global environment, creating one if an environment does not yet exist.
|
||||
pub fn get_environment() -> Result<Arc<Environment>> {
|
||||
let mut env_lock = G_ENV.lock();
|
||||
if let Some(env) = env_lock.as_ref() {
|
||||
if let Some(upgraded) = Weak::upgrade(env) {
|
||||
return Ok(upgraded);
|
||||
}
|
||||
if let Some(env) = env_lock.as_ref()
|
||||
&& let Some(upgraded) = Weak::upgrade(env)
|
||||
{
|
||||
return Ok(upgraded);
|
||||
}
|
||||
|
||||
let options = G_ENV_OPTIONS.get_or_init(EnvironmentBuilder::new);
|
||||
|
||||
@@ -13,10 +13,10 @@ impl EvaluationStrategy {
|
||||
pub(crate) fn should_fire(&self, _global_step: usize, iter_step: usize, dataloader_size: Option<usize>) -> bool {
|
||||
match self {
|
||||
Self::None => false,
|
||||
Self::Steps(steps) => iter_step > 0 && iter_step % steps == 0,
|
||||
Self::Steps(steps) => iter_step > 0 && iter_step.is_multiple_of(*steps),
|
||||
Self::Epochs(epochs) => {
|
||||
if let Some(dataloader_size) = dataloader_size {
|
||||
iter_step > 0 && iter_step % (dataloader_size * epochs) == 0
|
||||
iter_step > 0 && iter_step.is_multiple_of(dataloader_size * epochs)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
@@ -35,10 +35,10 @@ impl CheckpointStrategy {
|
||||
pub(crate) fn should_fire(&self, _global_step: usize, iter_step: usize, dataloader_size: Option<usize>) -> bool {
|
||||
match self {
|
||||
Self::None => false,
|
||||
Self::Steps(steps) => iter_step > 0 && iter_step % steps == 0,
|
||||
Self::Steps(steps) => iter_step > 0 && iter_step.is_multiple_of(*steps),
|
||||
Self::Epochs(epochs) => {
|
||||
if let Some(dataloader_size) = dataloader_size {
|
||||
iter_step > 0 && iter_step % (dataloader_size * epochs) == 0
|
||||
iter_step > 0 && iter_step.is_multiple_of(dataloader_size * epochs)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user