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

Refactor unfold4d + Add Module #870

Merged
merged 6 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Remove custom wgpu unfold kernel since doesn't handle complex cases w…
…ithout performance benefits
  • Loading branch information
nathanielsimard committed Oct 20, 2023
commit 7d49d2cd3e96a313d435fd8485ede5a827f9cb34
4 changes: 2 additions & 2 deletions burn-tensor/src/tensor/ops/modules/unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::{ConvOptions, UnfoldOptions};
pub(crate) fn create_unfolding_weight<B: Backend>(
in_channels: usize,
kernel_size: [usize; 2],
devide: &B::Device,
device: &B::Device,
) -> B::TensorPrimitive<4> {
let shape = Shape::new([
in_channels * kernel_size[0] * kernel_size[1],
Expand Down Expand Up @@ -53,7 +53,7 @@ pub(crate) fn create_unfolding_weight<B: Backend>(
}
}

B::from_data(Data::new(weight, shape), devide)
B::from_data(Data::new(weight, shape), device)
}

/// Compute the unfold4d operation using the conv2d operations.
Expand Down
2 changes: 0 additions & 2 deletions burn-wgpu/src/kernel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ pub mod matmul;
pub mod pool;
/// Pseudo-random number generator kernels
pub mod prng;
/// Unfold kernel
pub mod unfold;

pub(crate) use cat::*;
pub(crate) use comparison::*;
Expand Down
3 changes: 0 additions & 3 deletions burn-wgpu/src/kernel/unfold/mod.rs

This file was deleted.

92 changes: 0 additions & 92 deletions burn-wgpu/src/kernel/unfold/unfold4d.rs

This file was deleted.

21 changes: 2 additions & 19 deletions burn-wgpu/src/ops/module_ops.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use burn_tensor::{
ops::{
ConvOptions, ConvTransposeOptions, MaxPool2dBackward, MaxPool2dWithIndices, ModuleOps,
TensorOps, UnfoldOptions,
},
Shape,
use burn_tensor::ops::{
ConvOptions, ConvTransposeOptions, MaxPool2dBackward, MaxPool2dWithIndices, ModuleOps,
};

use crate::{
Expand Down Expand Up @@ -37,19 +33,6 @@ where
kernel::conv::conv_transpose2d(x, weight, bias, options)
}

fn unfold4d(
x: FloatTensor<Self, 4>,
kernel_size: [usize; 2],
options: UnfoldOptions,
) -> FloatTensor<Self, 3> {
let unfold_intermediate = kernel::unfold::unfold4d(x, kernel_size, options);
let [batch_size, channels_out, out_height, out_width] = unfold_intermediate.shape.dims;
<WgpuBackend<G, F, I> as TensorOps<WgpuBackend<G, F, I>>>::reshape(
unfold_intermediate,
Shape::new([batch_size, channels_out, out_height * out_width]),
)
}

fn avg_pool2d(
x: FloatTensor<Self, 4>,
kernel_size: [usize; 2],
Expand Down
20 changes: 0 additions & 20 deletions burn-wgpu/src/template/unfold/fill_weights.wgsl

This file was deleted.