Trait collenchyma_nn::Pooling
[−]
[src]
pub trait Pooling<F>: NN<F> { fn new_pooling_config(&self, window: &[i32], padding: &[i32], stride: &[i32]) -> Result<Self::CPOOL, Error>; fn pooling_max(&self, x: &mut SharedTensor<F>, result: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>; fn pooling_max_plain(&self, x: &SharedTensor<F>, result: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>; fn pooling_max_grad(&self, x: &mut SharedTensor<F>, x_diff: &mut SharedTensor<F>, result: &mut SharedTensor<F>, result_diff: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>; fn pooling_max_grad_plain(&self, x: &SharedTensor<F>, x_diff: &SharedTensor<F>, result: &SharedTensor<F>, result_diff: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>; }
Provides the functionality for a Backend to support Pooling operations.
Required Methods
fn new_pooling_config(&self, window: &[i32], padding: &[i32], stride: &[i32]) -> Result<Self::CPOOL, Error>
Creates a new PoolingConfig, which needs to be passed to further pooling Operations.
fn pooling_max(&self, x: &mut SharedTensor<F>, result: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>
Computes non-linear down-sampling (max Pooling) over the input Tensor x
with complete memory management.
Saves the result to result
.
For a no-memory managed version see pooling_max_plain
.
fn pooling_max_plain(&self, x: &SharedTensor<F>, result: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>
Computes the max pooling over the input Tensor x
without any memory management.
Saves the result to result
.
Attention:
For a correct computation result, you need to manage the memory allocation and synchronization yourself.
For a memory managed version see pooling_max
.
fn pooling_max_grad(&self, x: &mut SharedTensor<F>, x_diff: &mut SharedTensor<F>, result: &mut SharedTensor<F>, result_diff: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>
Computes the gradient of max Pooling over the input Tensor x
with complete memory management.
Saves the result to result_diff
.
For a no-memory managed version see pooling_max_grad_plain
.
fn pooling_max_grad_plain(&self, x: &SharedTensor<F>, x_diff: &SharedTensor<F>, result: &SharedTensor<F>, result_diff: &mut SharedTensor<F>, config: &Self::CPOOL) -> Result<(), Error>
Computes the gradient of max pooling over the input Tensor x
without any memory management.
Saves the result to result_diff
.
Attention:
For a correct computation result, you need to manage the memory allocation and synchronization yourself.
For a memory managed version see pooling_max_grad
.