larroy commented on a change in pull request #15625: Minor refactor of fully connected. URL: https://github.com/apache/incubator-mxnet/pull/15625#discussion_r307627450
########## File path: src/operator/nn/fully_connected-inl.h ########## @@ -75,6 +75,38 @@ struct FullyConnectedParam : public dmlc::Parameter<FullyConnectedParam> { } }; +/** + * Flatten additional dimensions after the first + * @tparam xpu + * @tparam DType + * @param tblob + * @param ctx + * @return 2 Dimensional Tensor with upper shapes collapsed + */ +template<typename xpu, typename DType> +Tensor<xpu, 2, DType> FlattenAs2DTail(const TBlob& tblob, const OpContext& ctx) { + const TShape& shape = tblob.shape_; + Stream<xpu> *stream = ctx.get_stream<xpu>(); + return tblob.get_with_shape<xpu, 2, DType>( + Shape2(shape[0], shape.ProdShape(1, shape.ndim())), stream); +} + +/** + * Flatten dimensions except last + * @tparam xpu + * @tparam DType + * @param tblob + * @param ctx + * @return 2 Dimensional tensor with front shapes collapsed + */ +template<typename xpu, typename DType> +Tensor<xpu, 2, DType> FlattenAs2DHead(const TBlob& tblob, const OpContext& ctx) { Review comment: Please suggest a better name. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services