Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions src/operator/numpy/np_elemwise_broadcast_logic_op.cu

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@

/*!
* Copyright (c) 2019 by Contributors
* \file np_elemwise_binary_logic_op.cc
* \brief CPU Implementation of basic logic functions for elementwise numpy binary
* \file np_elemwise_broadcast_logic_op.h
* \brief Function definition of basic logic functions for elementwise numpy binary
* broadcast operator.
*/

#ifndef MXNET_OPERATOR_NUMPY_NP_ELEMWISE_BROADCAST_LOGIC_OP_H_
#define MXNET_OPERATOR_NUMPY_NP_ELEMWISE_BROADCAST_LOGIC_OP_H_

#if MXNET_USE_TVM_OP
#include <tvm/runtime/c_runtime_api.h>
#include <tvm/runtime/packed_func.h>
#include "../tvmop/op_module.h"
#endif // MXNET_USE_TVM_OP

#include <string>
#include <utility>
#include <vector>
#include "../tensor/elemwise_binary_broadcast_op.h"
#include "../tensor/elemwise_binary_scalar_op.h"

Expand Down Expand Up @@ -58,7 +64,7 @@ static constexpr char func_logical_xor_cpu[] = "logical_xor_cpu";
static constexpr char func_logical_xor_gpu[] = "logical_xor_gpu";
#pragma clang diagnostic pop

bool NumpyBinaryLogicOpType(const nnvm::NodeAttrs& attrs,
inline bool NumpyBinaryLogicOpType(const nnvm::NodeAttrs& attrs,
std::vector<int>* in_attrs,
std::vector<int>* out_attrs) {
CHECK_EQ(in_attrs->size(), 2U);
Expand All @@ -69,7 +75,7 @@ bool NumpyBinaryLogicOpType(const nnvm::NodeAttrs& attrs,
return true;
}

TBlob PrependAxes(const TBlob& src, const int dst_ndim) {
inline TBlob PrependAxes(const TBlob& src, const int dst_ndim) {
CHECK_LE(src.shape_.ndim(), dst_ndim);
const int src_ndim = src.shape_.ndim();
if (src_ndim == dst_ndim)
Expand Down Expand Up @@ -228,16 +234,6 @@ struct GetBinaryBroadcastCompute {
.add_argument("lhs", "NDArray-or-Symbol", "First input to the function") \
.add_argument("rhs", "NDArray-or-Symbol", "Second input to the function")

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(not_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(greater);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(less);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(greater_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(less_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(logical_or);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(logical_xor);

#if MXNET_USE_TVM_OP

#define MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(name) \
Expand All @@ -253,16 +249,6 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(logical_xor);
.set_attr<FCompute>("FCompute<gpu>", \
TVMBinaryBroadcastCompute{func_##name##_gpu, "np_" #name})

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(not_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(greater);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(less);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(greater_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(less_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(logical_or);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(logical_xor);

#endif // MXNET_USE_CUDA

#else
Expand All @@ -272,19 +258,17 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(logical_xor);
.set_attr<FCompute>("FCompute<cpu>", \
BinaryBroadcastComputeLogic<cpu, mshadow_op::np_##name>)

#if MXNET_USE_CUDA

#define MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(name) \
NNVM_REGISTER_OP(_npi_##name) \
.set_attr<FCompute>("FCompute<gpu>", BinaryBroadcastRTCCompute{"np_" #name})

#endif // MXNET_USE_CUDA

#endif // MXNET_USE_TVM_OP

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(not_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(greater);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(less);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(greater_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(less_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(logical_or);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(logical_xor);

bool NumpyBinaryScalarLogicOpType(const nnvm::NodeAttrs& attrs,
inline bool NumpyBinaryScalarLogicOpType(const nnvm::NodeAttrs& attrs,
std::vector<int>* in_attrs,
std::vector<int>* out_attrs) {
CHECK_EQ(in_attrs->size(), 1U);
Expand Down Expand Up @@ -358,15 +342,6 @@ struct TVMBinaryBroadcastScalarCompute {
.add_argument("data", "NDArray-or-Symbol", "First input to the function") \
.add_arguments(NumpyBinaryScalarParam::__FIELDS__())

MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(not_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(greater);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(less);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(greater_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(less_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(logical_or);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(logical_xor);

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-const-variable"
Expand Down Expand Up @@ -404,16 +379,6 @@ static constexpr char func_logical_xor_scalar_gpu[] = "logical_xor_scalar_gpu"
.set_attr<FCompute>("FCompute<gpu>", \
TVMBinaryBroadcastScalarCompute{func_##name##_scalar_gpu})

MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(not_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(greater);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(less);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(greater_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(less_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(logical_or);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(logical_xor);

#endif // MXNET_USE_CUDA

#else
Expand All @@ -426,17 +391,17 @@ MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(logical_xor);
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; \
})

#endif // MXNET_USE_TVM_OP
#if MXNET_USE_CUDA

#define MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(name) \
NNVM_REGISTER_OP(_npi_##name##_scalar) \
.set_attr<FCompute>("FCompute<gpu>", BinaryScalarRTCCompute{"np_" #name})

MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(not_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(greater);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(less);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(greater_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(less_equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(logical_or);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(logical_xor);
#endif // MXNET_USE_CUDA

#endif // MXNET_USE_TVM_OP

} // namespace op
} // namespace mxnet

#endif // MXNET_OPERATOR_NUMPY_NP_ELEMWISE_BROADCAST_LOGIC_OP_H_
38 changes: 38 additions & 0 deletions src/operator/numpy/np_elemwise_broadcast_logic_op_and.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.
*/

/*!
* Copyright (c) 2019 by Contributors
* \file np_elemwise_binary_logic_op_and.cc
* \brief CPU Implementation of basic logic functions for logical_and operation.
*/

#include "./np_elemwise_broadcast_logic_op.h"

namespace mxnet {
namespace op {

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(logical_and);

MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(logical_and);

} // namespace op
} // namespace mxnet
35 changes: 35 additions & 0 deletions src/operator/numpy/np_elemwise_broadcast_logic_op_and.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.
*/

/*!
* Copyright (c) 2019 by Contributors
* \file np_elemwise_broadcast_logic_op_and.cu
* \brief GPU Implementation of basic functions for logical_and operation.
*/

#include "./np_elemwise_broadcast_logic_op.h"

namespace mxnet {
namespace op {

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(logical_and);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(logical_and);

} // namespace op
} // namespace mxnet
38 changes: 38 additions & 0 deletions src/operator/numpy/np_elemwise_broadcast_logic_op_equal.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.
*/

/*!
* Copyright (c) 2019 by Contributors
* \file np_elemwise_binary_logic_op_equal.cc
* \brief CPU Implementation of basic logic functions for equal operation.
*/

#include "./np_elemwise_broadcast_logic_op.h"

namespace mxnet {
namespace op {

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_CPU(equal);

MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_CPU(equal);

} // namespace op
} // namespace mxnet
35 changes: 35 additions & 0 deletions src/operator/numpy/np_elemwise_broadcast_logic_op_equal.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.
*/

/*!
* Copyright (c) 2019 by Contributors
* \file np_elemwise_broadcast_logic_op_equal.cu
* \brief GPU Implementation of basic functions for equal operation.
*/

#include "./np_elemwise_broadcast_logic_op.h"

namespace mxnet {
namespace op {

MXNET_OPERATOR_REGISTER_NP_BINARY_LOGIC_GPU(equal);
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR_LOGIC_GPU(equal);

} // namespace op
} // namespace mxnet
Loading