-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-978] Higher Order Gradient Support arctan
, arctanh
, radians
.
#15531
Changes from 7 commits
05a47e3
6d44738
af60dfe
e6a1d68
b3fe6bd
97b5fb7
8b8ab2a
7c21aca
51742b7
0e4f592
ef01b9f
f6292ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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 node_op_util.h | ||
* \brief abstraction for commonly nnvm::Node operations. | ||
*/ | ||
#ifndef MXNET_OPERATOR_TENSOR_UTIL_NODE_OP_UTIL_H_ | ||
#define MXNET_OPERATOR_TENSOR_UTIL_NODE_OP_UTIL_H_ | ||
#include <mxnet/base.h> | ||
#include <string> | ||
#include <unordered_map> | ||
#include "../../elemwise_op_common.h" | ||
|
||
namespace mxnet { | ||
namespace util { | ||
|
||
class NodeOp { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @larroy @apeforest @marcoabreu ,
It might be possible that I have missed something. Let me know what you think, will move forward from there or reset the commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me, indeed reduces noise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, I'll also update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @apeforest Do review this part. If it looks good, I'll update all other PRs to use this machinery once this is in.
kshitij12345 marked this conversation as resolved.
Show resolved
Hide resolved
kshitij12345 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private: | ||
const nnvm::NodePtr &dependent_node; | ||
apeforest marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public: | ||
explicit NodeOp(const nnvm::NodePtr &dependent_node) : dependent_node{dependent_node} {} | ||
|
||
nnvm::NodeEntry mul(const nnvm::NodeEntry &lhs, const nnvm::NodeEntry &rhs) { | ||
apeforest marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return nnvm::NodeEntry{mxnet::op::MakeNode("elemwise_mul", | ||
dependent_node->attrs.name + "_mul", | ||
{lhs, rhs}, nullptr, &dependent_node)}; | ||
} | ||
|
||
nnvm::NodeEntry mul(const nnvm::NodeEntry &x, double scalar) { | ||
const std::unordered_map<std::string, std::string> scalar_dict = | ||
{{"scalar", std::to_string(scalar)}}; | ||
return nnvm::NodeEntry{mxnet::op::MakeNode("_mul_scalar", | ||
dependent_node->attrs.name + "_mul_scalar", | ||
{x}, &scalar_dict, &dependent_node)}; | ||
} | ||
|
||
nnvm::NodeEntry mul(double scalar, const nnvm::NodeEntry &x) { | ||
apeforest marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return NodeOp::mul(x, scalar); | ||
} | ||
|
||
nnvm::NodeEntry div(const nnvm::NodeEntry &lhs, const nnvm::NodeEntry &rhs) { | ||
return nnvm::NodeEntry{mxnet::op::MakeNode("elemwise_div", | ||
dependent_node->attrs.name + "_div", | ||
{lhs, rhs}, nullptr, &dependent_node)}; | ||
} | ||
|
||
nnvm::NodeEntry square(const nnvm::NodeEntry &x) { | ||
return nnvm::NodeEntry{mxnet::op::MakeNode("square", | ||
dependent_node->attrs.name + "_square", | ||
{x}, nullptr, &dependent_node)}; | ||
} | ||
}; | ||
|
||
} // namespace util | ||
} // namespace mxnet | ||
|
||
#endif // MXNET_OPERATOR_TENSOR_UTIL_NODE_OP_UTIL_H_ |
Uh oh!
There was an error while loading. Please reload this page.