summaryrefslogtreecommitdiff
path: root/caffe2/operators/negative_op.h
diff options
context:
space:
mode:
authorXiaomeng Yang <bit.yangxm@gmail.com>2018-06-05 15:49:16 -0700
committerGitHub <noreply@github.com>2018-06-05 15:49:16 -0700
commit9243b64bff082307da33a418b61d27f3d2a9e449 (patch)
tree60ca7c7bf5f48f43d79fa711ee0bacd9741f289c /caffe2/operators/negative_op.h
parent051762351700a34d7b2a20c227064889d28572c7 (diff)
downloadpytorch-9243b64bff082307da33a418b61d27f3d2a9e449.tar.gz
pytorch-9243b64bff082307da33a418b61d27f3d2a9e449.tar.bz2
pytorch-9243b64bff082307da33a418b61d27f3d2a9e449.zip
[Caffe2] Update elementwise ops to support numpy style boradcast (#8070)
* Update elementwise ops to support numpy style boradcast Update elementwise ops to support numpy style boradcast * Fix sqrt_op * Fix compare ops * Fix gradient test * Fix optimizer legacy broadcast * Fix legacy broadcast for elementwise ops * Skip flaky test * Fix eigen simple binary op * Fix attention test * Fix rnn test * Fix LSTM test * Fix tan grad * Fix schema check
Diffstat (limited to 'caffe2/operators/negative_op.h')
-rw-r--r--caffe2/operators/negative_op.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/caffe2/operators/negative_op.h b/caffe2/operators/negative_op.h
new file mode 100644
index 0000000000..876a837323
--- /dev/null
+++ b/caffe2/operators/negative_op.h
@@ -0,0 +1,20 @@
+#ifndef CAFFE2_OPERATORS_NEGATIVE_OP_H_
+#define CAFFE2_OPERATORS_NEGATIVE_OP_H_
+
+#include "caffe2/operators/elementwise_ops.h"
+#include "caffe2/utils/math.h"
+
+namespace caffe2 {
+
+template <class Context>
+struct NegativeFunctor {
+ template <typename T>
+ bool operator()(const int N, const T* X, T* Y, Context* context) const {
+ math::Neg(N, X, Y, context);
+ return true;
+ }
+};
+
+} // namespace caffe2
+
+#endif // CAFFE2_OPERATORS_NEGATIVE_OP_H_