Skip to content

Commit

Permalink
chore: remove trait_alias
Browse files Browse the repository at this point in the history
  • Loading branch information
FL33TW00D committed Jan 20, 2024
1 parent 737f764 commit 051487d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Ratchet

<h3>
[Discord](https://discord.gg/XFe33KQTG4)
</h3>

A web-first, cross-platform ML framework.
6 changes: 3 additions & 3 deletions crates/ratchet-core/src/gpu/pools/dynamic_resource_pool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// All resource management taken from [Rerun](https://github.com/rerun-io/rerun) MIT.
use super::{PoolError, ResourceConstructor, ResourceDestructor};
use super::PoolError;
use crate::RVec;
use std::{
collections::hash_map::Entry,
Expand Down Expand Up @@ -82,7 +82,7 @@ where
Handle: Key,
Desc: Clone + Eq + Hash + Debug + DynamicResourcesDesc,
{
pub fn get_or_create<F: ResourceConstructor<Desc, Res>>(
pub fn get_or_create<F: Fn(&Desc) -> Res>(
&self,
desc: &Desc,
constructor: F,
Expand Down Expand Up @@ -141,7 +141,7 @@ where

pub fn begin_pass<D>(&mut self, pass_index: u64, mut destructor: D)
where
D: ResourceDestructor<Res>,
D: FnMut(&Res),
{
self.current_pass_index = pass_index;
let state = self.state.get_mut();
Expand Down
5 changes: 1 addition & 4 deletions crates/ratchet-core/src/gpu/pools/static_resource_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ pub enum PoolError {
UnknownDescriptor,
}

pub trait ResourceConstructor<Descriptor, Resource> = Fn(&Descriptor) -> Resource;
pub trait ResourceDestructor<Resource> = FnMut(&Resource);

/// Generic resource pool for all resources that are fully described upon creation, i.e. never have any variable content.
///
/// This implies, a resource is uniquely defined by its description.
Expand Down Expand Up @@ -56,7 +53,7 @@ where
})
}

pub fn get_or_create<C: ResourceConstructor<Descriptor, Resource>>(
pub fn get_or_create<C: Fn(&Descriptor) -> Resource>(
&self,
descriptor: &Descriptor,
constructor: C,
Expand Down
31 changes: 23 additions & 8 deletions crates/ratchet-core/src/kernels.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
// This file is generated by build.rs. Do not edit it manually.
use std::collections::HashMap;
use lazy_static::lazy_static;
use std::collections::HashMap;
lazy_static! {
pub static ref KERNELS: HashMap<&'static str, &'static str> = {
let mut m = HashMap::new();
m.insert("qgemm_vec4", include_str!("/Users/fleetwood/Code/ratchet/crates/ratchet-core/kernels/qgemm_vec4.wgsl"));
m.insert("sgemm_scalar", include_str!("/Users/fleetwood/Code/ratchet/crates/ratchet-core/kernels/sgemm_scalar.wgsl"));
m.insert("add_scalar", include_str!("/Users/fleetwood/Code/ratchet/crates/ratchet-core/kernels/add_scalar.wgsl"));
m
};
pub static ref KERNELS: HashMap<&'static str, &'static str> = {
let mut m = HashMap::new();
m.insert(
"qgemm_vec4",
include_str!(
"/Users/fleetwood/Code/ratchet/crates/ratchet-core/kernels/qgemm_vec4.wgsl"
),
);
m.insert(
"sgemm_scalar",
include_str!(
"/Users/fleetwood/Code/ratchet/crates/ratchet-core/kernels/sgemm_scalar.wgsl"
),
);
m.insert(
"add_scalar",
include_str!(
"/Users/fleetwood/Code/ratchet/crates/ratchet-core/kernels/add_scalar.wgsl"
),
);
m
};
}
1 change: 0 additions & 1 deletion crates/ratchet-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(trait_alias)]
#![allow(non_snake_case)]
mod compiled_op;
mod device;
Expand Down

0 comments on commit 051487d

Please sign in to comment.