Compute Library
 22.08
DepthwiseDepthfirstMultiplier< TInput, TWeight, TOutput, TAccum, is_generic, OutputStage > Class Template Reference

#include <depthwise_depthfirst_multiplier.hpp>

Collaboration diagram for DepthwiseDepthfirstMultiplier< TInput, TWeight, TOutput, TAccum, is_generic, OutputStage >:
[legend]

Public Member Functions

 DepthwiseDepthfirstMultiplier (StratType *const strat, const DepthwiseArgs &args, const OutputStage &os={})
 
 DepthwiseDepthfirstMultiplier (DepthwiseDepthfirstMultiplier &)=delete
 
DepthwiseDepthfirstMultiplieroperator= (DepthwiseDepthfirstMultiplier &)=delete
 
size_t get_storage_size (void) const override
 
void pack_parameters (void *buffer, const void *biases, const void *weights, size_t ld_weight_col, size_t ld_weight_row) override
 
size_t get_working_size_per_thread (const unsigned int n_input_channels) const override
 
void initialise_working_space (void *buffer, unsigned int n_input_channels) const override
 
void compute_tile_padded (unsigned int output_i, unsigned int output_j, unsigned int output_channel_start, unsigned int output_channel_end, const TensorSpec< const TInput *> &input, const TensorSpec< TOutput *> &output, const void *parameters, void *working_space_raw) const override
 
- Public Member Functions inherited from DepthfirstDriver< TInput, TWeight, TOutput >
 DepthfirstDriver (IDepthfirstStrategy *strategy, const DepthwiseArgs &args)
 
size_t get_working_size (unsigned int n_threads, unsigned int n_input_channels) const override final
 

Detailed Description

template<typename TInput, typename TWeight = TInput, typename TOutput = TInput, typename TAccum = typename DefaultTAccum<TInput>::Type, bool is_generic = false, typename OutputStage = typename DefaultOutputStage<TOutput>::Type>
class arm_conv::depthwise::DepthwiseDepthfirstMultiplier< TInput, TWeight, TOutput, TAccum, is_generic, OutputStage >

Definition at line 476 of file depthwise_depthfirst_multiplier.hpp.

Constructor & Destructor Documentation

◆ DepthwiseDepthfirstMultiplier() [1/2]

DepthwiseDepthfirstMultiplier ( StratType *const  strat,
const DepthwiseArgs &  args,
const OutputStage &  os = {} 
)
inline

Definition at line 491 of file depthwise_depthfirst_multiplier.hpp.

491  {})
492  : DepthfirstDriver<TInput, TWeight, TOutput>(strat, args), m_os(os)
493  {
494  }

◆ DepthwiseDepthfirstMultiplier() [2/2]

DepthwiseDepthfirstMultiplier ( DepthwiseDepthfirstMultiplier< TInput, TWeight, TOutput, TAccum, is_generic, OutputStage > &  )
delete

Member Function Documentation

◆ compute_tile_padded()

void compute_tile_padded ( unsigned int  output_i,
unsigned int  output_j,
unsigned int  output_channel_start,
unsigned int  output_channel_end,
const TensorSpec< const TInput *> &  input,
const TensorSpec< TOutput *> &  output,
const void *  parameters,
void *  working_space_raw 
) const
inlineoverridevirtual

Implements DepthfirstDriver< TInput, TWeight, TOutput >.

Definition at line 527 of file depthwise_depthfirst_multiplier.hpp.

References TensorSpec< T >::base, StrategyType< IsGeneric, TInput, TWeight, TOutput, TAccum, OutputStage >::execute(), arm_conv::addressing::fill_pointer_array(), DepthfirstMultiplierStrategy< TInput, TWeight, TOutput, TAccum >::get_storage_size(), TensorSpec< T >::ld_col, TensorSpec< T >::ld_row, arm_compute::test::validation::n, and arm_compute::test::parameters.

535  {
536  // Get the working space
537  auto ws = reinterpret_cast<WorkingSpace *>(working_space_raw);
538 
539  const int ii = static_cast<int>(output_i * this->m_args.stride_rows) - this->m_args.padding.top;
540  const auto input_pad_top = static_cast<unsigned int>(ii < 0 ? -ii : 0);
541  const auto input_i = static_cast<unsigned int>(ii < 0 ? 0 : ii);
542 
543  const int ij = static_cast<int>(output_j * this->m_args.stride_cols) - this->m_args.padding.left;
544  const auto input_pad_left = static_cast<unsigned int>(ij < 0 ? -ij : 0);
545  const auto input_j = static_cast<unsigned int>(ij < 0 ? 0 : ij);
546 
547  // Compute the output pointer array. We'll update this array after every
548  // invocation of the kernel.
550  ws->outptr_array, this->m_strat->get_output_rows(), this->m_strat->get_output_cols(),
551  output.base + output_i*output.ld_row + output_j*output.ld_col + output_channel_start,
552  output.ld_row, output.ld_col,
553  ws->output_buffer,
554  0, this->m_args.output_rows - output_i, // Top padding, # valid rows
555  0, this->m_args.output_cols - output_j // Left padding, # valid columns
556  );
557 
558  // Compute the parameter stride
559  DepthwiseArgs single_iter(this->m_args);
560  single_iter.input_channels = 1;
561  const size_t parameter_stride = reinterpret_cast<const StratType *>(this->m_strat.get())
562  ->get_storage_size(single_iter);
563 
564  for (; output_channel_start < output_channel_end;
565  output_channel_start += this->m_args.channel_multiplier)
566  {
567  // Compute the input pointer array
568  const auto input_channel = output_channel_start / this->m_args.channel_multiplier;
569 
570  // Construct the input patch
571  depthfirst_multiplier::PrepareInputSample<is_generic>::execute(
572  this->m_args, ws, this->m_strat.get(),
573  input.base + input_channel + input_i*input.ld_row + input_j*input.ld_col, input.ld_row, input.ld_col,
574  input_pad_top, this->m_args.input_rows - input_i,
575  input_pad_left, this->m_args.input_cols - input_j
576  );
577 
578  // Execute the kernel
580  this->m_args, ws, reinterpret_cast<const StratType *>(this->m_strat.get()), m_os, output_channel_start,
581  parameters, m_bias
582  );
583 
584  // Update the output pointers
585  for (unsigned int n = 0; n < this->m_strat->get_output_rows() * this->m_strat->get_output_cols(); n++)
586  {
587  ws->outptr_array[n] += this->m_args.channel_multiplier;
588  }
589 
590  // Progress the parameters
591  parameters = reinterpret_cast<const char *>(parameters) + parameter_stride;
592  }
593  }
static void execute(const DepthwiseArgs &args, const WorkspaceType *ws, const Type *strat, const OutputStage &, const unsigned int, const void *parameters, const void *)
std::unique_ptr< ParametersLibrary > parameters
Definition: Framework.cpp:46
void fill_pointer_array(size_t element_size, void **dest_raw, const unsigned int array_rows, const unsigned int array_cols, void *base_ptr_raw, size_t ld_row, size_t ld_col, void *pad_buffer_raw, const unsigned int pad_top, const unsigned int valid_rows, const unsigned int pad_left, const unsigned int valid_cols)
Definition: addressing.cpp:32

◆ get_storage_size()

size_t get_storage_size ( void  ) const
inlineoverride

Definition at line 499 of file depthwise_depthfirst_multiplier.hpp.

References DepthfirstMultiplierStrategy< TInput, TWeight, TOutput, TAccum >::get_storage_size().

500  {
501  return reinterpret_cast<const StratType *>(this->m_strat.get())
502  ->get_storage_size(this->m_args);
503  }

◆ get_working_size_per_thread()

size_t get_working_size_per_thread ( const unsigned int  n_input_channels) const
inlineoverridevirtual

Implements DepthfirstDriver< TInput, TWeight, TOutput >.

Definition at line 513 of file depthwise_depthfirst_multiplier.hpp.

References GemmTuner::args.

514  {
515  DepthwiseArgs args(this->m_args);
516  args.input_channels = n_input_channels;
517  return WorkspaceManager::get_sizeof_workspace(WorkspaceArgs<IDepthfirstStrategy, OutputStage>(this->m_strat.get(), args, m_os));
518  }

◆ initialise_working_space()

void initialise_working_space ( void *  buffer,
unsigned int  n_input_channels 
) const
inlineoverridevirtual

Implements DepthfirstDriver< TInput, TWeight, TOutput >.

Definition at line 520 of file depthwise_depthfirst_multiplier.hpp.

References GemmTuner::args.

521  {
522  DepthwiseArgs args(this->m_args);
523  args.input_channels = n_input_channels;
524  return WorkspaceManager::initialise(buffer, WorkspaceArgs<IDepthfirstStrategy, OutputStage>(this->m_strat.get(), args, m_os));
525  }

◆ operator=()

DepthwiseDepthfirstMultiplier& operator= ( DepthwiseDepthfirstMultiplier< TInput, TWeight, TOutput, TAccum, is_generic, OutputStage > &  )
delete

◆ pack_parameters()

void pack_parameters ( void *  buffer,
const void *  biases,
const void *  weights,
size_t  ld_weight_col,
size_t  ld_weight_row 
)
inlineoverride

Definition at line 505 of file depthwise_depthfirst_multiplier.hpp.

References DepthfirstMultiplierStrategy< TInput, TWeight, TOutput, TAccum >::pack_parameters().

506  {
507  reinterpret_cast<const StratType *>(this->m_strat.get())
508  ->pack_parameters(this->m_args, buffer, biases, m_os, weights, ld_weight_col, ld_weight_row);
509  m_bias = biases;
510  depthwise_depthfirst::stash_bias(m_os, biases);
511  }
void pack_parameters(void *buffer, const void *biases, const void *weights, size_t ld_weight_col, size_t ld_weight_row) override

The documentation for this class was generated from the following file: