c++ - 构建 Tensorflow 时未声明特征仿函数

标签 c++ tensorflow bazel

我正尝试按照 [issue #7531] 中的要求,通过添加非反双曲函数(sinh 和 cosh)来为 Tensorflow 代码做出贡献 (https://github.com/tensorflow/tensorflow/issues/7531)。

当我使用命令测试构建时

$ 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.cccwise_op_cosh.cc,它们只是非双曲线版本的拷贝,其中对 sin 或 cos 的引用替换为 sinh 和cosh,分别。据我所知,双曲函数现在的实现与 Eigen 库中的其他数学函数完全一样。但据我所知,它给出了对 Eigen 源中缺少声明的引用。

这是我的第一个开源贡献,除此之外,我对 C++ 还很陌生。如果有更多的 C++ 经验,我做错的地方可能会很明显。

最佳答案

你是否将你的“cwise_op_sinh.cc”和“cwise_op_cosh.cc”添加到相应的 BUILD 文件中?快速搜索告诉我它应该是 here但我可能是错的。不过,您绝对必须将您的新文件告诉 Bazel。

关于c++ - 构建 Tensorflow 时未声明特征仿函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42314317/

相关文章:

bazel - 为什么 Bazel 链接不足,我该如何解决?

c++ - 如何从 unordered_set 中准确获取一个元素?

c++ - 为什么编译器认为传递的是 std::string& 而不是 std:string

C++ Linux : Process PID from its path

machine-learning - 为什么 TensorFlow 的文档将 softmax 的输入称为 "logits"?

java - Bazel 卡在 java 二进制文件上

c++ - C++ 服务的 mod_gsoap 错误

tensorflow - "Anaconda can not spawn a new process..."我有崇高的文字错误

tensorflow - 如何用c++语言中的tensorflow.so和c_api.h加载图?

typescript - 通过 bazel 执行 Jasmine 测试时未找到规范