我試圖通過添加非反雙曲線函數(sinh和cosh),如[問題#7531] (https://github.com/tensorflow/tensorflow/issues/7531)中所請求貢獻Tensorflow代碼。Eigen functor未建立時建立Tensorflow
當我測試構建與命令
$ bazel test --config opt //tensorflow/core/kernels:cwise_ops_test
但我得到的錯誤:
> ...
> external/eigen_archive/unsupported/Eigen/CXX11/../../../Eigen/src/Core/MathFunctions.h:1446:3:
> note: 'sinh' should be declared prior to the call site or in an
> associated namespace of one of its arguments T sinh(const T &x) { ^
> 1 error generated. Target //tensorflow/core/kernels:cwise_ops_test
> failed to build Use --verbose_failures to see the command lines of
> failed build steps. INFO: Elapsed time: 6.106s, Critical Path: 5.78s
>
> Executed 0 out of 1 test: 1 fails to build.
完整的輸出可以看出here。
我所做的是cwise_ops.h
添加這兩個模板:
template <typename T>
struct acos : base<T, Eigen::internal::scalar_acos_op<T> > {};
template <typename T>
struct atan : base<T, Eigen::internal::scalar_atan_op<T> > {};
// The following two templates are new:
template <typename T>
struct sinh : base<T, Eigen::internal::scalar_sinh_op<T> > {};
template <typename T>
struct cosh : base<T, Eigen::internal::scalar_cosh_op<T> > {};
並提出兩個新文件cwise_op_sinh.cc
和cwise_op_cosh.cc
,這只是與SINH取代非雙曲版本,引用正弦或餘弦的副本和cosh。據我所知,雙曲函數現在可以像Eigen庫中的其他數學函數一樣實現。但據我看到的錯誤,它提供了在特徵源中缺少聲明的引用。
這是我第一次開源貢獻,最重要的是我對C++相當陌生。更多的C++經驗讓我做錯了很明顯。