检查 Tensorflow 中的广播兼容性 - C++ API
Check for broadcasting compatibility in Tensorflow - C++ API
我正在 TensorFlow 中实现逐元素操作。许多 TensorFlow 操作,例如添加,支持广播(from numpy)。如果遵守以下规则,则可以进行广播:
When operating on two tensors, their shapes should be compared element-wise. The procedure starts with the trailing dimensions, and works its way forward. Two dimensions are compatible when they are equal, or one of them is 1. If these conditions are not met, an exception is thrown, indicating that the tensors have incompatible shapes. The size of the resulting tensor is the maximum size along each dimension of the input arrays.
TensorFlow C++ API 是否提供任何方法来比较两个张量的兼容性?或者,哪种方法最快?
TensorFlow 中所有逐元素二元运算的内核实现都源自 BinaryOpShared
class, that does the compatibility checking via the helper class BinaryOpState
。也许,您可以简单地从 BinaryOpShared
派生内核 class 并免费获得兼容性检查。
我正在 TensorFlow 中实现逐元素操作。许多 TensorFlow 操作,例如添加,支持广播(from numpy)。如果遵守以下规则,则可以进行广播:
When operating on two tensors, their shapes should be compared element-wise. The procedure starts with the trailing dimensions, and works its way forward. Two dimensions are compatible when they are equal, or one of them is 1. If these conditions are not met, an exception is thrown, indicating that the tensors have incompatible shapes. The size of the resulting tensor is the maximum size along each dimension of the input arrays.
TensorFlow C++ API 是否提供任何方法来比较两个张量的兼容性?或者,哪种方法最快?
TensorFlow 中所有逐元素二元运算的内核实现都源自 BinaryOpShared
class, that does the compatibility checking via the helper class BinaryOpState
。也许,您可以简单地从 BinaryOpShared
派生内核 class 并免费获得兼容性检查。