[英]Implementation of tf.extract_image_patches
Where is the implementation of tf.extract_image_patches
? tf.extract_image_patches
的实现在tf.extract_image_patches
? I checked the tensorflow repository I could not find it. 我检查了我找不到的tensorflow存储库。
The file tensorflow/core/kernels/extract_image_patches_op.cc
does not contain an implementation. tensorflow/core/kernels/extract_image_patches_op.cc
文件不包含实现。
That's an interesting question. 这是一个有趣的问题。 The path is as follows:
路径如下:
Python tf.extract_image_patches
function is implemented in the generated file tensorflow/python/ops/gen_array_ops.py
, which invokes "ExtractImagePatches"
native op. Python
tf.extract_image_patches
函数在生成的文件tensorflow/python/ops/gen_array_ops.py
实现,该文件调用"ExtractImagePatches"
本机操作。
This op is implemented by ExtractImagePatchesOp
in core/kernels/extract_image_patches_op.cc
for both CPU and GPU devices. 该操作由CPU / GPU设备的
core/kernels/extract_image_patches_op.cc
的ExtractImagePatchesOp
实现。 The main call is functor::ExtractImagePatchesForward
... 主要电话是
functor::ExtractImagePatchesForward
...
... which is defined in core/kernels/extract_image_patches_op.h
. ...在
core/kernels/extract_image_patches_op.h
定义。 The actual logic is delegated to the ::extract_image_patches()
method of the input tensor. 实际的逻辑委托给输入张量的
::extract_image_patches()
方法。 The tensor's type is TTypes<T, 4>::ConstTensor
, which is a typedef of Eigen::TensorMap
core/framework/tensor_types.h
. 张量的类型为
TTypes<T, 4>::ConstTensor
,这是Eigen::TensorMap
core/framework/tensor_types.h
。
At this point, it's getting out of tensorflow source base, because Eigen
is from the third-party eigen library ( GitHub mirror ). 此时,它已经脱离了tensorflow源库,因为
Eigen
来自第三方eigen库 ( GitHub镜像 )。 Its source code is somewhat non-trivially downloaded and linked to tensorflow, but right now we are interested in Eigen::TensorMap::extract_image_patches()
function. 它的源代码有些不费吹灰之力下载并链接到tensorflow,但是现在我们对
Eigen::TensorMap::extract_image_patches()
函数很感兴趣。
It's defined in eigen/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
file and applies TensorImagePatchOp
... 它在
eigen/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
文件中定义,并应用TensorImagePatchOp
...
... which can be found in eigen/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
. ...可以在
eigen/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
。 Finally, this functor doesn't delegate it further, ie the actual implementation. 最后,该函子不再进一步委托它,即实际的实现。
Note that particular version of Eigen
library may be different in different builds of tensorflow, which you should check in the bazel config. 请注意,在不同版本的tensorflow中,特定版本的
Eigen
库可能会有所不同,您应该在bazel配置中进行检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.