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
Refactor for windows CI 'out of heap space' errors #15922
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d30097c
Speed up test_random.py:test_shuffle to get past CI timeouts.
DickJC123 479ba38
Fix flakey test_operator.py:test_laop_6.
DickJC123 cff3947
Break up broadcast_reduce_op_value.{cc,cu}
DickJC123 f51f963
Revert "Fix flakey test_operator.py:test_laop_6."
DickJC123 56962f2
Break up elemwise_unary_op_basic.{cc,cu}
DickJC123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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) 2016 by Contributors | ||
* \file broadcast_reduce_minmax_value.cc | ||
* \brief CPU Implementation of broadcast and reduce min and max functions based on value. | ||
*/ | ||
#include "./broadcast_reduce_op.h" | ||
|
||
namespace mxnet { | ||
namespace op { | ||
|
||
MXNET_OPERATOR_REGISTER_MINMAX_REDUCE(max) | ||
.add_alias("max_axis") | ||
.describe(get_reduce_axes_description("max", __LINE__)) | ||
.set_attr<FCompute>("FCompute<cpu>", ReduceAxesCompute<cpu, mshadow::red::maximum>) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<nnvm::FGradient>("FGradient", ReduceGrad{"_backward_max"}); | ||
|
||
MXNET_OPERATOR_REGISTER_REDUCE_BACKWARD(_backward_max) | ||
.set_num_inputs(3) | ||
.set_attr<FCompute>("FCompute<cpu>", ReduceAxesBackwardUseInOut<cpu, mshadow_op::eq>); | ||
|
||
MXNET_OPERATOR_REGISTER_MINMAX_REDUCE(min) | ||
.add_alias("min_axis") | ||
.describe(get_reduce_axes_description("min", __LINE__)) | ||
.set_attr<FCompute>("FCompute<cpu>", ReduceAxesCompute<cpu, mshadow::red::minimum>) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<nnvm::FGradient>("FGradient", ReduceGrad{"_backward_min"}); | ||
|
||
MXNET_OPERATOR_REGISTER_REDUCE_BACKWARD(_backward_min) | ||
.set_num_inputs(3) | ||
.set_attr<FCompute>("FCompute<cpu>", ReduceAxesBackwardUseInOut<cpu, mshadow_op::eq>); | ||
|
||
} // namespace op | ||
} // namespace mxnet |
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,43 @@ | ||
/* | ||
* 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) 2016 by Contributors | ||
* \file broadcast_reduce_minmax_value.cu | ||
* \brief GPU Implementation of broadcast and reduce min and max functions based on value. | ||
*/ | ||
#include "./broadcast_reduce_op.h" | ||
|
||
namespace mxnet { | ||
namespace op { | ||
|
||
NNVM_REGISTER_OP(max) | ||
.set_attr<FCompute>("FCompute<gpu>", ReduceAxesCompute<gpu, mshadow::red::maximum>); | ||
|
||
NNVM_REGISTER_OP(_backward_max) | ||
.set_attr<FCompute>("FCompute<gpu>", ReduceAxesBackwardUseInOut<gpu, mshadow_op::eq>); | ||
|
||
NNVM_REGISTER_OP(min) | ||
.set_attr<FCompute>("FCompute<gpu>", ReduceAxesCompute<gpu, mshadow::red::minimum>); | ||
|
||
NNVM_REGISTER_OP(_backward_min) | ||
.set_attr<FCompute>("FCompute<gpu>", ReduceAxesBackwardUseInOut<gpu, mshadow_op::eq>); | ||
|
||
} // namespace op | ||
} // namespace mxnet |
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,118 @@ | ||
/* | ||
* 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) 2016 by Contributors | ||
* \file broadcast_reduce_norm_value.cc | ||
* \brief CPU Implementation of broadcast and reduce norm functions based on value. | ||
*/ | ||
#include "./broadcast_reduce_op.h" | ||
|
||
namespace mxnet { | ||
namespace op { | ||
DMLC_REGISTER_PARAMETER(NormParam); | ||
|
||
template<> | ||
void L2NormComputeEx<cpu>(const nnvm::NodeAttrs& attrs, | ||
const OpContext& ctx, | ||
const std::vector<NDArray>& inputs, | ||
const std::vector<OpReqType>& req, | ||
const std::vector<NDArray>& outputs) { | ||
CHECK_EQ(inputs.size(), 1U); | ||
CHECK_EQ(outputs.size(), 1U); | ||
CHECK_EQ(req.size(), 1U); | ||
const NormParam& param = nnvm::get<NormParam>(attrs.parsed); | ||
mshadow::Stream<cpu>* s = ctx.get_stream<cpu>(); | ||
const NDArrayStorageType istype = inputs[0].storage_type(); | ||
const mxnet::TShape axis = param.axis.has_value() ? param.axis.value() : mxnet::TShape(); | ||
if ((istype == kRowSparseStorage || istype == kCSRStorage) && axis.ndim() == 0 && | ||
param.ord == 2) { | ||
// l2 norm on the entire array | ||
L2NormComputeSparseImpl<cpu>(s, inputs[0], req[0], outputs[0].data()); | ||
} else if (istype == kCSRStorage && axis.ndim() == 1 && (axis[0] == 0 || axis[0] == 1) && | ||
!param.keepdims && param.ord == 2) { | ||
// l2 norm on a particular axis | ||
NDArray output = outputs[0]; | ||
ReduceCsrImpl<cpu, sq_sum, false>(s, ctx, inputs[0], req[0], &output, axis); | ||
CHECK_EQ(outputs[0].storage_type(), kDefaultStorage); | ||
SqRootForL2<cpu>(ctx, req[0], outputs[0].data()); | ||
} else { | ||
LogUnimplementedOp(attrs, ctx, inputs, req, outputs); | ||
} | ||
} | ||
|
||
NNVM_REGISTER_OP(norm) | ||
MXNET_ADD_SPARSE_OP_ALIAS(norm) | ||
.describe(R"code(Computes the norm on an NDArray. | ||
|
||
This operator computes the norm on an NDArray with the specified axis, depending | ||
on the value of the ord parameter. By default, it computes the L2 norm on the entire | ||
array. Currently only ord=2 supports sparse ndarrays. | ||
|
||
Examples:: | ||
|
||
x = [[[1, 2], | ||
[3, 4]], | ||
[[2, 2], | ||
[5, 6]]] | ||
|
||
norm(x, ord=2, axis=1) = [[3.1622777 4.472136 ] | ||
[5.3851647 6.3245554]] | ||
|
||
norm(x, ord=1, axis=1) = [[4., 6.], | ||
[7., 8.]] | ||
|
||
rsp = x.cast_storage('row_sparse') | ||
|
||
norm(rsp) = [5.47722578] | ||
|
||
csr = x.cast_storage('csr') | ||
|
||
norm(csr) = [5.47722578] | ||
|
||
)code" ADD_FILELINE) | ||
.set_num_inputs(1) | ||
.set_num_outputs(1) | ||
.set_attr_parser(ParamParser<NormParam>) | ||
.set_attr<mxnet::FInferShape>("FInferShape", NormShape) | ||
.set_attr<nnvm::FInferType>("FInferType", NormType) | ||
.set_attr<FInferStorageType>("FInferStorageType", LpNormStorageType) | ||
.set_attr<nnvm::FGradient>("FGradient", ReduceGrad{ "_backward_norm" }) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<FCompute>("FCompute<cpu>", LpNormCompute<cpu>) | ||
.set_attr<FComputeEx>("FComputeEx<cpu>", L2NormComputeEx<cpu>) | ||
.add_argument("data", "NDArray-or-Symbol", "The input") | ||
.add_arguments(NormParam::__FIELDS__()); | ||
|
||
NNVM_REGISTER_OP(_backward_norm) | ||
.set_num_outputs(1) | ||
.set_attr_parser(ParamParser<NormParam>) | ||
.set_attr<nnvm::TIsBackward>("TIsBackward", true) | ||
.set_attr<FResourceRequest>("FResourceRequest", | ||
[](const NodeAttrs& attrs) { | ||
return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; | ||
}) | ||
.set_attr<FCompute>("FCompute<cpu>", LpNormGradCompute<cpu>); | ||
|
||
|
||
} // namespace op | ||
} // namespace mxnet |
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,60 @@ | ||
/* | ||
* 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) 2016 by Contributors | ||
* \file broadcast_reduce_norm_value.cu | ||
* \brief GPU Implementation of broadcast and reduce norm functions based on value. | ||
*/ | ||
#include "./broadcast_reduce_op.h" | ||
|
||
namespace mxnet { | ||
namespace op { | ||
|
||
template<> | ||
void L2NormComputeEx<gpu>(const nnvm::NodeAttrs& attrs, | ||
const OpContext& ctx, | ||
const std::vector<NDArray>& inputs, | ||
const std::vector<OpReqType>& req, | ||
const std::vector<NDArray>& outputs) { | ||
CHECK_EQ(inputs.size(), 1U); | ||
CHECK_EQ(outputs.size(), 1U); | ||
CHECK_EQ(req.size(), 1U); | ||
const NormParam& param = nnvm::get<NormParam>(attrs.parsed); | ||
mshadow::Stream<gpu>* s = ctx.get_stream<gpu>(); | ||
const NDArrayStorageType istype = inputs[0].storage_type(); | ||
const mxnet::TShape axis = param.axis.has_value() ? param.axis.value() : mxnet::TShape(); | ||
if ((istype == kRowSparseStorage || istype == kCSRStorage) && axis.ndim() == 0 && | ||
param.ord == 2) { | ||
// l2 norm on the entire array | ||
L2NormComputeSparseImpl<gpu>(s, inputs[0], req[0], outputs[0].data()); | ||
} else { | ||
LogUnimplementedOp(attrs, ctx, inputs, req, outputs); | ||
} | ||
} | ||
|
||
NNVM_REGISTER_OP(norm) | ||
.set_attr<FCompute>("FCompute<gpu>", LpNormCompute<gpu>) | ||
.set_attr<FComputeEx>("FComputeEx<gpu>", L2NormComputeEx<gpu>); | ||
|
||
NNVM_REGISTER_OP(_backward_norm) | ||
.set_attr<FCompute>("FCompute<gpu>", LpNormGradCompute<gpu>); | ||
|
||
} // namespace op | ||
} // namespace mxnet |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you want to inline this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The short answer is that the function was formerly in broadcast_reduce_op_value.cc (with the inline keyword) and I copied it intact to broadcast_reduce_op.h.
Also, removing
inline
breaks the compile with a 'multiple definitions' error. One shouldn't put the definition of a stand-alone function in a header file that's part of multiple translation units without the inline keyword.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course I know that. The question is why isn't declared on the header and defined in the implementation file as usual. Seems like a big function to inline. Which adds bloat.