This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix windows oversize by adding files
- Loading branch information
Showing
8 changed files
with
232 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
src/operator/numpy/np_elemwise_broadcast_op_extended_sec.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* 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_op_extended_sec.cc | ||
* \brief CPU Implementation of extended functions for elementwise numpy binary broadcast operator. (Second extended file) | ||
*/ | ||
|
||
#include "../../common/utils.h" | ||
#include "./np_elemwise_broadcast_op.h" | ||
|
||
namespace mxnet { | ||
namespace op { | ||
|
||
#define MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(name) \ | ||
NNVM_REGISTER_OP(name) \ | ||
.set_num_inputs(1) \ | ||
.set_num_outputs(1) \ | ||
.set_attr_parser([](NodeAttrs* attrs) { \ | ||
attrs->parsed = std::stod(attrs->dict["scalar"]); \ | ||
}) \ | ||
.set_attr<mxnet::FInferShape>("FInferShape", ElemwiseShape<1, 1>) \ | ||
.set_attr<nnvm::FInferType>("FInferType", NumpyBinaryScalarType) \ | ||
.set_attr<nnvm::FInplaceOption>("FInplaceOption", \ | ||
[](const NodeAttrs& attrs){ \ | ||
return std::vector<std::pair<int, int> >{{0, 0}}; \ | ||
}) \ | ||
.add_argument("data", "NDArray-or-Symbol", "source input") \ | ||
.add_argument("scalar", "float", "scalar input") | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY_BROADCAST(_npi_fmax) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryBroadcastCompute<cpu, mshadow_op::fmax>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_fmax"}); | ||
|
||
NNVM_REGISTER_OP(_backward_npi_fmax) | ||
.set_num_inputs(3) | ||
.set_num_outputs(2) | ||
.set_attr<nnvm::TIsBackward>("TIsBackward", true) | ||
.set_attr<nnvm::FInplaceOption>("FInplaceOption", | ||
[](const NodeAttrs& attrs){ | ||
return std::vector<std::pair<int, int> >{{0, 1}}; | ||
}) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryBroadcastBackwardUseIn<cpu, mshadow_op::ge, | ||
mshadow_op::lt>); | ||
|
||
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_fmax_scalar) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::fmax>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_fmax_scalar"}); | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY(_backward_npi_fmax_scalar) | ||
.add_argument("scalar", "float", "scalar value") | ||
.set_attr_parser([](NodeAttrs *attrs) { attrs->parsed = std::stod(attrs->dict["scalar"]); }) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Backward<cpu, mshadow_op::ge>); | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY_BROADCAST(_npi_fmin) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryBroadcastCompute<cpu, mshadow_op::fmin>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_fmin"}); | ||
|
||
NNVM_REGISTER_OP(_backward_npi_fmin) | ||
.set_num_inputs(3) | ||
.set_num_outputs(2) | ||
.set_attr<nnvm::TIsBackward>("TIsBackward", true) | ||
.set_attr<nnvm::FInplaceOption>("FInplaceOption", | ||
[](const NodeAttrs& attrs){ | ||
return std::vector<std::pair<int, int> >{{0, 1}}; | ||
}) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryBroadcastBackwardUseIn<cpu, mshadow_op::le, | ||
mshadow_op::gt>); | ||
|
||
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_fmin_scalar) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::fmin>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_fmin_scalar"}); | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY(_backward_npi_fmin_scalar) | ||
.add_argument("scalar", "float", "scalar value") | ||
.set_attr_parser([](NodeAttrs *attrs) { attrs->parsed = std::stod(attrs->dict["scalar"]); }) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Backward<cpu, mshadow_op::le>); | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY_BROADCAST(_npi_fmod) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryBroadcastCompute<cpu, mshadow_op::fmod>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_fmod"}); | ||
|
||
NNVM_REGISTER_OP(_backward_npi_fmod) | ||
.set_num_inputs(3) | ||
.set_num_outputs(2) | ||
.set_attr<nnvm::TIsBackward>("TIsBackward", true) | ||
.set_attr<nnvm::FInplaceOption>("FInplaceOption", | ||
[](const NodeAttrs& attrs){ | ||
return std::vector<std::pair<int, int> >{{0, 1}}; | ||
}) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryBroadcastBackwardUseIn<cpu, mshadow_op::mod_grad, | ||
mshadow_op::mod_rgrad>); | ||
|
||
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_fmod_scalar) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::fmod>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_fmod_scalar"}); | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY(_backward_npi_fmod_scalar) | ||
.add_argument("scalar", "float", "scalar value") | ||
.set_attr_parser([](NodeAttrs *attrs) { attrs->parsed = std::stod(attrs->dict["scalar"]); }) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Backward<cpu, mshadow_op::mod_grad>); | ||
|
||
MXNET_OPERATOR_REGISTER_NP_BINARY_SCALAR(_npi_rfmod_scalar) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Compute<cpu, mshadow_op::rfmod>) | ||
.set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{"_backward_npi_rfmod_scalar"}); | ||
|
||
MXNET_OPERATOR_REGISTER_BINARY(_backward_npi_rfmod_scalar) | ||
.add_argument("scalar", "float", "scalar value") | ||
.set_attr_parser([](NodeAttrs *attrs) { attrs->parsed = std::stod(attrs->dict["scalar"]); }) | ||
.set_attr<FCompute>("FCompute<cpu>", BinaryScalarOp::Backward<cpu, mshadow_op::rmod_grad>); | ||
|
||
} // namespace op | ||
} // namespace mxnet |
Oops, something went wrong.