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 2022/03/21 15:17:26 UTC

[GitHub] [incubator-mxnet] anko-intel commented on a change in pull request #20911: [operator] Integrate oneDNN matmul primitive to mxnet dot operator

anko-intel commented on a change in pull request #20911:
URL: https://github.com/apache/incubator-mxnet/pull/20911#discussion_r831102856



##########
File path: src/operator/nn/dnnl/dnnl_dot.cc
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file dnnl_dot.cc
+ */
+
+#if MXNET_USE_ONEDNN == 1
+
+#include "dnnl_dot-inl.h"
+

Review comment:
       src/operator/nn/dnnl/dnnl_dot.cc:46:  Add #include <unordered_map> for unordered_map<>  [build/include_what_you_use] [4]
   src/operator/nn/dnnl/dnnl_dot.cc:103:  Add #include <memory> for make_shared<>  [build/include_what_you_use] [4]

##########
File path: src/operator/nn/dnnl/dnnl_dot-inl.h
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file dnnl_dot-inl.h
+ */
+
+#ifndef MXNET_OPERATOR_NN_DNNL_DNNL_DOT_INL_H_
+#define MXNET_OPERATOR_NN_DNNL_DNNL_DOT_INL_H_
+
+#if MXNET_USE_ONEDNN == 1
+
+#include <vector>
+
+#include "dnnl_base-inl.h"
+#include "dnnl_ops-inl.h"
+#include "operator/tensor/dot-inl.h"
+
+namespace mxnet {
+namespace op {
+
+using dot_fwd_t    = dnnl::matmul;
+using dot_fwd_pd_t = dnnl::matmul::primitive_desc;
+
+typedef ParamOpSign<DotParam> DotSignature;
+
+class DNNLDotFwd {
+ public:
+  static DNNLDotFwd& GetCached(const DotParam& param,
+                               const std::vector<NDArray>& inputs,
+                               const std::vector<NDArray>& outputs,
+                               const bool isNumpy);
+
+  DNNLDotFwd(const DotParam& param,
+             const std::vector<NDArray>& inputs,
+             const std::vector<NDArray>& outputs,
+             const bool isNumpy);
+
+  void Execute(const std::vector<NDArray>& inputs,
+               const std::vector<OpReqType>& req,
+               const std::vector<NDArray>& outputs,
+               const bool isNumpy);
+
+ private:
+  std::shared_ptr<dot_fwd_t> fwd;
+  std::shared_ptr<dot_fwd_pd_t> fwd_pd;
+};
+
+template <bool isNumpy>
+void DNNLDotForward(const nnvm::NodeAttrs& attrs,
+                    const OpContext& ctx,
+                    const std::vector<NDArray>& inputs,
+                    const std::vector<OpReqType>& req,
+                    const std::vector<NDArray>& outputs) {
+  DotParam param;
+  if (isNumpy) {
+    // NumPy version of dot operator does not support transpose flags.
+    param             = DotParam();
+    param.transpose_a = false;

Review comment:
       should it be checked or assert only  if transpose is set to false for numpy ?

##########
File path: src/operator/nn/dnnl/dnnl_dot-inl.h
##########
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file dnnl_dot-inl.h
+ */
+
+#ifndef MXNET_OPERATOR_NN_DNNL_DNNL_DOT_INL_H_
+#define MXNET_OPERATOR_NN_DNNL_DNNL_DOT_INL_H_
+
+#if MXNET_USE_ONEDNN == 1
+
+#include <vector>
+

Review comment:
       src/operator/nn/dnnl/dnnl_dot-inl.h:62:  Add #include <memory> for shared_ptr<>  [build/include_what_you_use] [4]




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org