You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/07/26 05:37:45 UTC
[GitHub] [incubator-mxnet] apeforest commented on a change in pull request
#15625: Minor refactor of fully connected.
apeforest commented on a change in pull request #15625: Minor refactor of fully connected.
URL: https://github.com/apache/incubator-mxnet/pull/15625#discussion_r307594376
##########
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:
These two methods seem to be generic for all operators. Can we add them to a common place?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services