Where is the implementation of tf.extract_image_patches
? I checked the tensorflow repository I could not find it.
The file tensorflow/core/kernels/extract_image_patches_op.cc
does not contain an implementation.
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.
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
...
... 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
.
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.
It's defined in eigen/unsupported/Eigen/CXX11/src/Tensor/TensorBase.h
file and applies TensorImagePatchOp
...
... 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.
Note that particular version of Eigen
library may be different in different builds of tensorflow, which you should check in the bazel config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With