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

Migrate/jit/matmul tiling 2d #1472

Merged
merged 28 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
configurable unrolling
  • Loading branch information
louisfd committed Mar 13, 2024
commit 7e07825acc670674f3c0b30e7ecde04b4f6162cc
12 changes: 12 additions & 0 deletions crates/burn-jit/src/codegen/dialect/gpu/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ impl Loop {
parent_scope.register(Branch::Loop(op));
}
}

#[allow(missing_docs)]
pub struct UnrolledRangeLoop;

impl UnrolledRangeLoop {
/// Registers an unrolled range loop to the given scope.
pub fn register<F: Fn(Variable, &mut Scope)>(scope: &mut Scope, start: u32, end: u32, func: F) {
for i in start..end {
func(i.into(), scope);
}
}
}
10 changes: 9 additions & 1 deletion crates/burn-jit/src/codegen/dialect/gpu/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,18 @@ macro_rules! gpu {
out: $out.into(),
});
};
// range(start, end).for_each(|scope| { ... })
// range(start, end).for_each(|i, scope| { ... })
($scope:expr, range($start:expr, $end:expr).for_each($arg:expr)) => {
$crate::codegen::dialect::gpu::RangeLoop::register($scope, $start.into(), $end.into(), $arg);
};
// range(start, end, unroll).for_each(|i, scope| { ... })
($scope:expr, range($start:expr, $end:expr, $unroll:expr).for_each($arg:expr)) => {
if $unroll {
$crate::codegen::dialect::gpu::UnrolledRangeLoop::register($scope, $start.into(), $end.into(), $arg);
} else {
$crate::codegen::dialect::gpu::RangeLoop::register($scope, $start.into(), $end.into(), $arg);
}
};
// loop(|scope| { ... })
($scope:expr, loop($arg:expr)) => {
$crate::codegen::dialect::gpu::Loop::register($scope, $arg);
Expand Down
Loading