Skip to content

Commit

Permalink
update submod
Browse files Browse the repository at this point in the history
  • Loading branch information
shiinamiyuki committed Sep 19, 2023
1 parent 157c2f3 commit c3d317e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions luisa_compute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ dx = ["luisa_compute_sys/dx"]
strict = ["luisa_compute_sys/strict"]
remote = ["luisa_compute_sys/remote"]
cpu = ["luisa_compute_sys/cpu"]


8 changes: 4 additions & 4 deletions luisa_compute/examples/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ fn main() {
let buf_y = y.var();
let x = buf_x.read(tid);
let y = buf_y.read(tid);
let f = track!(|x: Expr<f32>, y: Expr<f32>| {
if x > y {
let f = |x: Expr<f32>, y: Expr<f32>| {
track!(if x > y {
x * y
} else {
y * x + (x / 32.0 * PI).sin()
}
});
})
};
autodiff(|| {
requires_grad(x);
requires_grad(y);
Expand Down
1 change: 1 addition & 0 deletions luisa_compute/src/lang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub mod ops;
pub mod poly;
pub mod swizzle;
pub mod types;
pub mod soa;

#[allow(dead_code)]
pub(crate) static KERNEL_ID: AtomicUsize = AtomicUsize::new(0);
Expand Down
9 changes: 9 additions & 0 deletions luisa_compute/src/lang/soa.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use luisa_compute_ir::{ir::Type, CArc};

use crate::prelude::*;
/** A buffer with SOA layout.
*/
pub struct SoaBuffer<T: Value> {
inner: ByteBuffer,
_marker: std::marker::PhantomData<T>,
}
5 changes: 5 additions & 0 deletions luisa_compute/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use raw_window_handle::HasRawWindowHandle;
use winit::window::Window;

use crate::internal_prelude::*;
use crate::lang::soa::SoaBuffer;
use ir::{
CallableModule, CallableModuleRef, Capture, CpuCustomOp, KernelModule, Module, ModuleFlags,
ModuleKind, ModulePools,
Expand Down Expand Up @@ -180,6 +181,10 @@ impl Device {
};
buffer
}
pub fn create_soa_buffer<T: Value>(&self, count: usize) -> SoaBuffer<T> {
// let inner = self.create_byte_buffer(len)
todo!()
}
pub fn create_buffer<T: Value>(&self, count: usize) -> Buffer<T> {
assert!(
std::mem::size_of::<T>() > 0,
Expand Down
1 change: 1 addition & 0 deletions luisa_compute_derive_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl Compiler {
}
)
}

pub fn derive_value(&self, struct_: &ItemStruct) -> TokenStream {
self.check_repr_c(&struct_.attrs);
let span = struct_.span();
Expand Down
4 changes: 3 additions & 1 deletion luisa_compute_track/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ impl VisitMut for TraceVisitor {

#[proc_macro]
pub fn track(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
track_impl(parse_macro_input!(input as Expr)).into()
let input: TokenStream = input.into();
let block_input: proc_macro::TokenStream = quote!({ #input }).into();
track_impl(parse_macro_input!(block_input as Expr)).into()
}

fn track_impl(mut ast: Expr) -> TokenStream {
Expand Down

0 comments on commit c3d317e

Please sign in to comment.