ptrendx commented on a change in pull request #15167: [WIP] Pointwise fusion for GPU URL: https://github.com/apache/incubator-mxnet/pull/15167#discussion_r296302617
########## File path: src/operator/fusion/fused_op.cu ########## @@ -0,0 +1,534 @@ +/* + * 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. + */ + +#include <sys/stat.h> +#include <nvrtc.h> +#include <cuda.h> +#include <nnvm/pass_functions.h> +#include <algorithm> +#include <mutex> +#include "./fused_op.h" +#include "./fused_op-inl.h" +#include "../operator_common.h" +#include "../elemwise_op_common.h" +#include "../../executor/exec_pass.h" +#include "../../common/cuda_utils.h" + +namespace mxnet { + +namespace detail { + +inline std::string mshadowTypeToString(int type) { + switch (type) { + case mshadow::kFloat32: + return "float"; + case mshadow::kFloat64: + return "double"; + case mshadow::kFloat16: + return "half"; + case mshadow::kUint8: + return "unsigned char"; + case mshadow::kInt8: + return "char"; + case mshadow::kInt32: + return "int"; + case mshadow::kInt64: + return "long long"; + default: + LOG(FATAL) << "Unknown type enum " << type; + } + return ""; +} + +inline int mshadowTypeToVectorLength(int type) { + switch (type) { + case mshadow::kFloat32: + return 1; + case mshadow::kFloat64: + return 1; + case mshadow::kFloat16: + return 2; + case mshadow::kUint8: + return 4; + case mshadow::kInt8: + return 4; + case mshadow::kInt32: + return 1; + case mshadow::kInt64: + return 1; + default: + LOG(FATAL) << "Unknown type enum " << type; + } + return 0; +} + +inline void replaceString(std::string *input, const std::string old, const std::string repl) { + size_t pos = 0; + while ((pos = input->find(old, pos)) != std::string::npos) { + input->replace(pos, old.size(), repl); + pos += repl.size(); + } +} + +} // namespace detail + +std::string ParseOpDescription(const std::vector<std::string>& op_desc, Review comment: ok ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
