重命名 pt2tf 为 pt2pb

This commit is contained in:
zhutian
2020-10-14 08:55:07 +08:00
committed by Gitee
parent 324ab60a5d
commit 90ae190559
407 changed files with 0 additions and 0 deletions
@@ -0,0 +1,22 @@
import tensorflow as tf
from onnx_tf.handlers.backend_handler import BackendHandler
from onnx_tf.handlers.handler import onnx_op
@onnx_op("Expand")
class Expand(BackendHandler):
@classmethod
def version_8(cls, node, **kwargs):
tensor_dict = kwargs["tensor_dict"]
x, shape = tensor_dict[node.inputs[0]], tensor_dict[node.inputs[1]]
# tf.math.multiply does not support bool therefore use int8
if x.dtype is tf.bool:
ones = tf.ones(shape, dtype=tf.int8)
r = tf.cast(x, tf.int8) * ones
return [tf.cast(r, tf.bool)]
else:
ones = tf.ones(shape, dtype=x.dtype)
return [x * ones]