#include <cassert>
-namespace
-{
-
-/**
- * @breif Infer (positive) channel axis from channel axis specifier (which may be negative)
- *
- * NOTE This implementation SHOULD be aligned with CanonicalAxisIndex method in ::caffe::Blob
- */
-class CanonicalChannelAxis
-{
-public:
- CanonicalChannelAxis(int32_t axis) : _axis{axis}
- {
- // DO NOTHING
- }
-
-public:
- uint32_t eval(const nncc::core::ADT::tensor::Shape &ifm) const
- {
- return query_on(ifm).axis(axis_specifier(_axis));
- }
-
-private:
- int32_t _axis;
-};
-
-CanonicalChannelAxis canonical_channel_axis(int32_t axis) { return CanonicalChannelAxis{axis}; }
-
-} // namespace
-
ConvolutionSpec::ConvolutionSpec(const ::caffe::ConvolutionParameter ¶m) : _param(param)
{
// NOTE Dilation is not supported, yet
uint32_t ConvolutionSpec::channel_axis(void) const
{
- return canonical_channel_axis(_param.axis()).eval(ifm_shape());
+ return query_on(ifm_shape()).axis(axis_specifier(_param.axis()));
}
uint32_t ConvolutionSpec::pad(uint32_t spatial_axis) const