tf.extract_image_patches的实现 [英] Implementation of tf.extract_image_patches
问题描述
tf.extract_image_patches
的实现在哪里?我检查了我找不到的tensorflow存储库。
Where is the implementation of tf.extract_image_patches
? I checked the tensorflow repository I could not find it.
文件 tensorflow / core / kernels / extract_image_patches_op.cc
推荐答案
这是一个有趣的问题。路径如下:
That's an interesting question. The path is as follows:
-
Python
tf.extract_image_patches
函数在生成的文件tensorflow / python / ops /中实现gen_array_ops.py
,它调用ExtractImagePatches
本机操作。
Python
tf.extract_image_patches
function is implemented in the generated filetensorflow/python/ops/gen_array_ops.py
, which invokes"ExtractImagePatches"
native op.
此操作由 core / kernels / extract_image_patches_op.cc
。主要调用是 functor :: ExtractImagePatchesForward
...
This op is implemented by ExtractImagePatchesOp
in core/kernels/extract_image_patches_op.cc
for both CPU and GPU devices. The main call is functor::ExtractImagePatchesForward
...
...,它在< a href = https://github.com/tensorflow/tensorflow/blob/5e855c56c2657128ff793b83442edc9886808922/tensorflow/core/kernels/extract_image_patches_op.h#L26 rel = noreferrer> core / kernels / extract_image_patches_op。 h
。实际的逻辑委托给输入张量的 :: extract_image_patches()
方法。张量的类型是 TTypes< T,4> :: ConstTensor
,它是 Eigen :: TensorMap
< a href = https://github.com/tensorflow/tensorflow/blob/5e855c56c2657128ff793b83442edc9886808922/tensorflow/core/framework/tensor_types.h#L29 rel = noreferrer>> $code> core / framework / tensor_types。 h 。
... which is defined in core/kernels/extract_image_patches_op.h
. The actual logic is delegated to the ::extract_image_patches()
method of the input tensor. The tensor's type is TTypes<T, 4>::ConstTensor
, which is a typedef of Eigen::TensorMap
core/framework/tensor_types.h
.
此时,它已脱离张量流源基本,因为 Eigen
来自第三方特征库( GitHub镜像)。它的源代码有些轻松下载并链接到tensorflow ,但是现在我们对 Eigen :: TensorMap :: extract_image_patches()
函数。
At this point, it's getting out of tensorflow source base, because Eigen
is from the third-party eigen library (GitHub mirror). 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.
-
它在
eigen / unsupported / Eigen / CXX11 / src / Tensor / TensorBase.h
文件并应用TensorImagePatchOp
...
...可以在 eigen / unsupported / Eigen / CXXens /TensorImagePatch.h
。最后,此函子不再进一步委托它,即实际的实现。
... which can be found in eigen/unsupported/Eigen/CXX11/src/Tensor/TensorImagePatch.h
. Finally, this functor doesn't delegate it further, i.e. the actual implementation.
请注意, Eigen
库的特定版本可能有所不同在不同版本的tensorflow中,您应该在bazel配置中进行检查。
Note that particular version of Eigen
library may be different in different builds of tensorflow, which you should check in the bazel config.
这篇关于tf.extract_image_patches的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!