Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
elftausend committed Dec 8, 2023
1 parent 12611d5 commit e2cf938
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/buffer/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ impl<T> PtrType for Num<T> {
fn flag(&self) -> crate::flag::AllocFlag {
crate::flag::AllocFlag::Num
}

#[inline]
unsafe fn set_flag(&mut self, _flag: AllocFlag) {}
}

impl<T> CommonPtrs<T> for Num<T> {
Expand Down
2 changes: 0 additions & 2 deletions src/device_traits.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// TODO: move to devices folder ig

use core::ops::Deref;

use crate::{flag::AllocFlag, prelude::Device, Buffer, HasId, Parents, PtrType, Shape, StackArray};

pub trait Alloc<T>: Device + Sized {
Expand Down
3 changes: 2 additions & 1 deletion src/devices/cpu/cpu_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
cpu::CPUPtr, flag::AllocFlag, impl_buffer_hook_traits, impl_retriever, pass_down_grad_fn,
pass_down_optimize_mem_graph, pass_down_tape_actions, Alloc, Base, Buffer, CloneBuf, Device,
DevicelessAble, HasModules, Module, OnDropBuffer, OnNewBuffer, PtrConv, Setup, Shape,
WrappedData,
WrappedData, PtrType,
};

pub trait IsCPU {}
Expand Down Expand Up @@ -163,6 +163,7 @@ impl<Mods: OnDropBuffer, OtherMods: OnDropBuffer> PtrConv<CPU<OtherMods>> for CP
data: &Mods::Wrap<CPUPtr<T>>,
flag: AllocFlag,
) -> OtherMods::Wrap<CPUPtr<Conv>> {
// data.flag()
todo!()
// CPUPtr {
// ptr: data.ptr as *mut Conv,
Expand Down
5 changes: 5 additions & 0 deletions src/devices/cpu/cpu_ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ impl<T> PtrType for CPUPtr<T> {
fn flag(&self) -> AllocFlag {
self.flag
}

#[inline]
unsafe fn set_flag(&mut self, flag: AllocFlag) {
self.flag = flag
}
}

impl<T> CommonPtrs<T> for CPUPtr<T> {
Expand Down
2 changes: 0 additions & 2 deletions src/devices/cpu/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use crate::{
pass_down_add_operation!(CPU);
pass_down_exec_now!(CPU);

pub fn slice<T>(x: &[T]) {}

impl<Mods, T, D, S> ApplyFunction<T, S, D> for CPU<Mods>
where
Mods: Retrieve<Self, T> + AddOperation + 'static,
Expand Down
3 changes: 3 additions & 0 deletions src/devices/stack_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ impl<S: Shape, T> PtrType for StackArray<S, T> {
fn flag(&self) -> crate::flag::AllocFlag {
crate::flag::AllocFlag::None
}

#[inline]
unsafe fn set_flag(&mut self, _flag: crate::flag::AllocFlag) {}
}

impl<S: Shape, T> CommonPtrs<T> for StackArray<S, T> {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub trait PtrType {
fn size(&self) -> usize;
/// Returns the [`AllocFlag`].
fn flag(&self) -> AllocFlag;
unsafe fn set_flag(&mut self, flag: AllocFlag);
}

pub trait HostPtr<T>: PtrType {
Expand Down
7 changes: 6 additions & 1 deletion src/modules/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl<Data: PtrType> PtrType for LazyWrapper<Data> {
fn flag(&self) -> crate::flag::AllocFlag {
self.data.flag()
}

#[inline]
unsafe fn set_flag(&mut self, flag: crate::flag::AllocFlag) {
self.data.set_flag(flag)
}
}

impl<Data> Deref for LazyWrapper<Data> {
Expand Down Expand Up @@ -145,7 +150,7 @@ impl<D: LazySetup, Mods: Setup<D>> Setup<D> for Lazy<Mods> {
}
}

impl<Mods: RunModule<D>, D: LazyRun + PtrConv + 'static> RunModule<D> for Lazy<Mods> {
impl<Mods: RunModule<D>, D: LazyRun + Device + 'static> RunModule<D> for Lazy<Mods> {
#[inline]
fn run(&self, device: &D) -> crate::Result<()> {
unsafe { self.call_lazily::<D>()? };
Expand Down

0 comments on commit e2cf938

Please sign in to comment.