Array<T> wrap(const Array<T> &in, const dim_t ox, const dim_t oy, const dim_t wx, const dim_t wy, const dim_t sx, const dim_t sy, const dim_t px, const dim_t py, const bool is_column) { af::dim4 idims = in.dims(); af::dim4 odims(ox, oy, idims[2], idims[3]); Array<T> out = createValueArray<T>(odims, scalar<T>(0)); const T *inPtr = in.get(); T *outPtr = out.get(); af::dim4 istrides = in.strides(); af::dim4 ostrides = out.strides(); if (is_column) { wrap_dim<T, true >(outPtr, inPtr, odims, idims, ostrides, istrides, wx, wy, sx, sy, px, py); } else { wrap_dim<T, false>(outPtr, inPtr, odims, idims, ostrides, istrides, wx, wy, sx, sy, px, py); } return out; }
Array<T>* resize(const Array<T> &in, const dim_type odim0, const dim_type odim1, const af_interp_type method) { af::dim4 idims = in.dims(); af::dim4 odims(odim0, odim1, idims[2], idims[3]); // Create output placeholder Array<T> *outArray = createValueArray(odims, (T)0); // Get pointers to raw data const T *inPtr = in.get(); T *outPtr = outArray->get(); af::dim4 ostrides = outArray->strides(); af::dim4 istrides = in.strides(); switch(method) { case AF_INTERP_NEAREST: resize_<T, AF_INTERP_NEAREST>(outPtr, inPtr, odims, idims, ostrides, istrides); break; case AF_INTERP_BILINEAR: resize_<T, AF_INTERP_BILINEAR>(outPtr, inPtr, odims, idims, ostrides, istrides); break; default: break; } return outArray; }
void pool_layer_t::gparam(const tensor_t& output, scalar_t* gradient) { NANOCV_UNUSED1(gradient); NANOCV_UNUSED1_RELEASE(output); assert(odims() == output.dims()); assert(orows() == output.rows()); assert(ocols() == output.cols()); }
const tensor_t& pool_layer_t::ginput(const tensor_t& output) { assert(odims() == output.dims()); assert(orows() == output.rows()); assert(ocols() == output.cols()); m_odata = output; for (size_t o = 0; o < odims(); o ++) { pooling::ginput( m_idata.matrix(o), m_wdata.matrix(o), m_sdata.matrix(o), m_cdata.matrix(o), m_odata.matrix(o)); } return m_idata; }
Array<T> wrap(const Array<T> &in, const dim_t ox, const dim_t oy, const dim_t wx, const dim_t wy, const dim_t sx, const dim_t sy, const dim_t px, const dim_t py, const bool is_column) { af::dim4 idims = in.dims(); af::dim4 odims(ox, oy, idims[2], idims[3]); Array<T> out = createValueArray<T>(odims, scalar<T>(0)); kernel::wrap<T>(out, in, wx, wy, sx, sy, px, py, is_column); return out; }
Array<T> wrap(const Array<T> &in, const dim_t ox, const dim_t oy, const dim_t wx, const dim_t wy, const dim_t sx, const dim_t sy, const dim_t px, const dim_t py, const bool is_column) { af::dim4 idims = in.dims(); af::dim4 odims(ox, oy, idims[2], idims[3]); Array<T> out = createValueArray<T>(odims, scalar<T>(0)); out.eval(); in.eval(); if (is_column) { getQueue().enqueue(kernel::wrap_dim<T, 1>, out, in, wx, wy, sx, sy, px, py); } else { getQueue().enqueue(kernel::wrap_dim<T, 0>, out, in, wx, wy, sx, sy, px, py); } return out; }
const tensor_t& pool_layer_t::output(const tensor_t& input) { assert(idims() == input.dims()); assert(irows() <= input.rows()); assert(icols() <= input.cols()); m_idata = input; for (size_t o = 0; o < odims(); o ++) { pooling::output( m_idata.matrix(o), m_alpha, m_wdata.matrix(o), m_sdata.matrix(o), m_cdata.matrix(o), m_odata.matrix(o)); } return m_odata; }
Array<T> resize(const Array<T> &in, const dim_t odim0, const dim_t odim1, const af_interp_type method) { af::dim4 idims = in.dims(); af::dim4 odims(odim0, odim1, idims[2], idims[3]); // Create output placeholder Array<T> out = createValueArray(odims, (T)0); out.eval(); in.eval(); switch(method) { case AF_INTERP_NEAREST: getQueue().enqueue(kernel::resize<T, AF_INTERP_NEAREST>, out, in); break; case AF_INTERP_BILINEAR: getQueue().enqueue(kernel::resize<T, AF_INTERP_BILINEAR>, out, in); break; case AF_INTERP_LOWER: getQueue().enqueue(kernel::resize<T, AF_INTERP_LOWER>, out, in); break; default: break; } return out; }