summaryrefslogtreecommitdiff
path: root/caffe2/operators/tan_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/tan_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/tan_op.h')
-rw-r--r--caffe2/operators/tan_op.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/caffe2/operators/tan_op.h b/caffe2/operators/tan_op.h
new file mode 100644
index 0000000000..579a20d12f
--- /dev/null
+++ b/caffe2/operators/tan_op.h
@@ -0,0 +1,34 @@
+#ifndef CAFFE2_OPERATORS_TAN_OP_H_
+#define CAFFE2_OPERATORS_TAN_OP_H_
+
+#include <vector>
+
+#include "caffe2/operators/elementwise_ops.h"
+#include "caffe2/utils/math.h"
+
+namespace caffe2 {
+
+template <class Context>
+struct TanFunctor {
+ template <typename T>
+ bool operator()(const int N, const T* X, T* Y, Context* context) const {
+ math::Tan(N, X, Y, context);
+ return true;
+ }
+};
+
+template <class Context>
+struct TanGradientFunctor {
+ template <typename T>
+ bool Forward(
+ const std::vector<int>& dY_dims,
+ const std::vector<int>& X_dims,
+ const T* dY,
+ const T* X,
+ T* dX,
+ Context* context) const;
+};
+
+} // namespace caffe2
+
+#endif // CAFFE2_OPERATORS_TAN_OP_H_