@@ -108,6 +108,183 @@ REG_OP(PartitionedCall) | |||||
.ATTR(config_proto, String, "") | .ATTR(config_proto, String, "") | ||||
.ATTR(executor_type, String, "") | .ATTR(executor_type, String, "") | ||||
.OP_END_FACTORY_REG(PartitionedCall) | .OP_END_FACTORY_REG(PartitionedCall) | ||||
REG_OP(TensorArray) | |||||
.INPUT(size, TensorType({DT_INT32})) | |||||
.OUTPUT(handle, TensorType({DT_RESOURCE})) | |||||
.OUTPUT(flow, TensorType({DT_FLOAT})) | |||||
.REQUIRED_ATTR(dtype, Type) | |||||
.ATTR(element_shape, ListInt, ge::UNKNOWN_RANK) | |||||
.ATTR(dynamic_size, Bool, false) | |||||
.ATTR(clear_after_read, Bool, true) | |||||
.ATTR(identical_element_shapes, Bool, false) | |||||
.ATTR(tensor_array_name, String, "") | |||||
.OP_END_FACTORY_REG(TensorArray) | |||||
REG_OP(TensorArrayWrite) | |||||
.INPUT(handle, TensorType({DT_RESOURCE})) | |||||
.INPUT(index, TensorType({DT_INT32})) | |||||
.INPUT(value, TensorType({DT_FLOAT, DT_FLOAT16, DT_DOUBLE, DT_INT8, | |||||
DT_INT16, DT_UINT16, DT_UINT8, DT_INT32, DT_INT64, DT_BOOL, | |||||
DT_STRING, DT_COMPLEX64, DT_COMPLEX128})) | |||||
.INPUT(flow_in, TensorType({DT_FLOAT})) | |||||
.OUTPUT(flow_out, TensorType({DT_FLOAT})) | |||||
.OP_END_FACTORY_REG(TensorArrayWrite) | |||||
REG_OP(AvgPool3DGrad) | |||||
.INPUT(orig_input_shape, TensorType({DT_INT32})) | |||||
.INPUT(grads, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) | |||||
.OUTPUT(output, TensorType({DT_FLOAT16, DT_FLOAT32, DT_DOUBLE})) | |||||
.REQUIRED_ATTR(ksize, ListInt) | |||||
.REQUIRED_ATTR(strides, ListInt) | |||||
.REQUIRED_ATTR(pads, ListInt) | |||||
.ATTR(ceil_mode, Bool, false) | |||||
.ATTR(count_include_pad, Bool, true) | |||||
.ATTR(divisor_override, Int, 0) | |||||
.ATTR(data_format, String, "NDHWC") | |||||
.OP_END_FACTORY_REG(AvgPool3DGrad) | |||||
REG_OP(Merge) | |||||
.DYNAMIC_INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OUTPUT(value_index, TensorType({DT_INT32})) | |||||
.OP_END_FACTORY_REG(Merge) | |||||
REG_OP(NoOp) | |||||
.OP_END_FACTORY_REG(NoOp) | |||||
REG_OP(VarIsInitializedOp) | |||||
.INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, | |||||
DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.OUTPUT(y, TensorType({DT_BOOL})) | |||||
.OP_END_FACTORY_REG(VarIsInitializedOp) | |||||
REG_OP(AssignVariableOp) | |||||
.INPUT(resource, TensorType({DT_RESOURCE})) | |||||
.INPUT(value, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, \ | |||||
DT_UINT16, DT_UINT8, DT_INT32, DT_INT64, DT_BOOL, DT_DOUBLE})) | |||||
.REQUIRED_ATTR(dtype, Type) | |||||
.OP_END_FACTORY_REG(AssignVariableOp) | |||||
REG_OP(ReadVariableOp) | |||||
.INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, | |||||
DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, | |||||
DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.ATTR(dtype, Int, DT_INT32) | |||||
.OP_END_FACTORY_REG(ReadVariableOp) | |||||
REG_OP(Reshape) | |||||
.INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, DT_INT32, | |||||
DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.INPUT(shape, TensorType({DT_INT32, DT_INT64})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, DT_INT32, | |||||
DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.ATTR(axis, Int, 0) | |||||
.ATTR(num_axes, Int, -1) | |||||
.OP_END_FACTORY_REG(Reshape) | |||||
REG_OP(VarHandleOp) | |||||
.ATTR(container, String, "") | |||||
.ATTR(shared_name, String, "") | |||||
.REQUIRED_ATTR(dtype, Type) | |||||
.ATTR(shape, ListInt, ge::UNKNOWN_SHAPE) | |||||
.OUTPUT(y, TensorType({DT_RESOURCE})) | |||||
.OP_END_FACTORY_REG(VarHandleOp) | |||||
REG_OP(Squeeze) | |||||
.INPUT(x, TensorType::ALL()) | |||||
.OUTPUT(y, TensorType::ALL()) | |||||
.ATTR(axis, ListInt, {}) | |||||
.OP_END_FACTORY_REG(Squeeze) | |||||
REG_OP(Fill) | |||||
.INPUT(dims, TensorType::IndexNumberType()) | |||||
.INPUT(value, TensorType({DT_FLOAT, DT_DOUBLE, DT_INT32, DT_UINT8, DT_INT16, | |||||
DT_INT8, DT_COMPLEX64, DT_INT64, DT_BOOL, DT_QINT8, | |||||
DT_QUINT8, DT_QINT32, DT_QINT16, DT_QUINT16, DT_UINT16, | |||||
DT_COMPLEX128, DT_FLOAT16, DT_UINT32, DT_UINT64})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT, DT_DOUBLE, DT_INT32, DT_UINT8, DT_INT16, | |||||
DT_INT8, DT_COMPLEX64, DT_INT64, DT_BOOL, DT_QINT8, | |||||
DT_QUINT8, DT_QINT32, DT_QINT16, DT_QUINT16, DT_UINT16, | |||||
DT_COMPLEX128, DT_FLOAT16, DT_UINT32, DT_UINT64})) | |||||
.OP_END_FACTORY_REG(Fill) | |||||
REG_OP(ShapeN) | |||||
.DYNAMIC_INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, DT_UINT8, | |||||
DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.DYNAMIC_OUTPUT(y, TensorType({DT_INT32, DT_INT64})) | |||||
.ATTR(dtype, Int, DT_INT32) | |||||
.OP_END_FACTORY_REG(ShapeN) | |||||
REG_OP(Switch) | |||||
.INPUT(data, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.INPUT(pred, TensorType({DT_BOOL})) | |||||
.OUTPUT(output_false, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OUTPUT(output_true, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OP_END_FACTORY_REG(Switch) | |||||
REG_OP(RefSwitch) | |||||
.INPUT(data, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.INPUT(pred, TensorType({DT_BOOL})) | |||||
.OUTPUT(output_false, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OUTPUT(output_true, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OP_END_FACTORY_REG(RefSwitch) | |||||
REG_OP(Enter) | |||||
.INPUT(x, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, | |||||
DT_INT8, DT_INT16, DT_INT32, DT_INT64, DT_UINT8, DT_UINT16, DT_UINT32, | |||||
DT_UINT64, DT_BOOL})) | |||||
.REQUIRED_ATTR(frame_name, String) | |||||
.REQUIRED_ATTR(is_constant, Bool) | |||||
.OP_END_FACTORY_REG(Enter) | |||||
REG_OP(VariableV2) | |||||
.INPUT(x, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \ | |||||
DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, \ | |||||
DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.ATTR(index, Int, 0) | |||||
.ATTR(value, Tensor, Tensor()) | |||||
.ATTR(container, String, "") | |||||
.ATTR(shared_name, String, "") | |||||
.OP_END_FACTORY_REG(VariableV2) | |||||
REG_OP(Constant) | |||||
.OUTPUT(y, TensorType({DT_FLOAT, DT_FLOAT16, DT_INT8, DT_INT16, DT_UINT16, | |||||
DT_UINT8, DT_INT32, DT_INT64, DT_UINT32, DT_UINT64, DT_BOOL, DT_DOUBLE})) | |||||
.ATTR(value, Tensor, Tensor()) | |||||
.OP_END_FACTORY_REG(Constant) | |||||
REG_OP(Mul) | |||||
.INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8, | |||||
DI_UINT16, DT_INT16, DT_INT32, DT_INT64, | |||||
DT_COMPLEX64, DT_COMPLEX128})) | |||||
.INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8, | |||||
DI_UINT16, DT_INT16, DT_INT32, DT_INT64, | |||||
DT_COMPLEX64, DT_COMPLEX128})) | |||||
.OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_DOUBLE, DT_UINT8, DT_INT8, | |||||
DI_UINT16, DT_INT16, DT_INT32, DT_INT64, | |||||
DT_COMPLEX64, DT_COMPLEX128})) | |||||
.OP_END_FACTORY_REG(Mul) | |||||
// for plugin | // for plugin | ||||
static Status ParseParamsStub(const google::protobuf::Message* op_src, ge::Operator& op_dest) { | static Status ParseParamsStub(const google::protobuf::Message* op_src, ge::Operator& op_dest) { | ||||
@@ -209,5 +386,36 @@ REGISTER_CUSTOM_OP("PartitionedCall") | |||||
.OriginOpType({"ai.onnx::9::Clip"}) | .OriginOpType({"ai.onnx::9::Clip"}) | ||||
.ParseParamsFn(ParseParamsClipV9Stub) | .ParseParamsFn(ParseParamsClipV9Stub) | ||||
.ParseOpToGraphFn(ParseOpToGraphClipV9Stub); | .ParseOpToGraphFn(ParseOpToGraphClipV9Stub); | ||||
REGISTER_CUSTOM_OP("TensorArray") | |||||
.FrameworkType(domi::TENSORFLOW) | |||||
.OriginOpType("TensorArrayV3") | |||||
.ParseParamsFn(ParseParamsStub); | |||||
REGISTER_CUSTOM_OP("TensorArrayWrite") | |||||
.FrameworkType(domi::TENSORFLOW) | |||||
.OriginOpType("TensorArrayWriteV3") | |||||
.ParseParamsFn(ParseParamsStub); | |||||
REGISTER_CUSTOM_OP("DynamicRNN") | |||||
.FrameworkType(domi::TENSORFLOW) | |||||
.OriginOpType("BlockLSTM") | |||||
.ParseParamsFn(ParseParamsStub); | |||||
REGISTER_CUSTOM_OP("Merge") | |||||
.FrameworkType(domi::TENSORFLOW) | |||||
.OriginOpType("HistogramSummary") | |||||
.ParseParamsFn(ParseParamsStub); | |||||
REGISTER_CUSTOM_OP("NoOp") | |||||
.FrameworkType(domi::TENSORFLOW) | |||||
.OriginOpType("NoOp") | |||||
.ParseParamsFn(ParseParamsStub); | |||||
REGISTER_CUSTOM_OP("Fill") | |||||
.FrameworkType(domi::TENSORFLOW) | |||||
.OriginOpType("Fill") | |||||
.ParseParamsFn(ParseParamsStub); | |||||
} // namespace ge | } // namespace ge | ||||
#endif // MAIN_OPS_STUB_H | #endif // MAIN_OPS_STUB_H |
@@ -0,0 +1,26 @@ | |||||
import tensorflow as tf | |||||
import os | |||||
pb_file_path = os.getcwd() | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
# NHWC | |||||
fmap_shape = [17, 101, 101, 17] | |||||
filter_size = [5, 5, 17, 1] | |||||
dy_shape = [17, 49, 49, 17] | |||||
strideh, stridew = [2, 2] | |||||
padding = 'VALID' | |||||
tensor_x1 = tf.compat.v1.placeholder(dtype="float16", shape=fmap_shape) | |||||
tensor_x2 = tf.compat.v1.placeholder(dtype="float16", shape=fmap_shape) | |||||
tensor_x = tf.add(tensor_x1, tensor_x2) | |||||
tensor_dy1 = tf.compat.v1.placeholder(dtype="float16", shape=dy_shape) | |||||
tensor_dy2 = tf.compat.v1.placeholder(dtype="float16", shape=dy_shape) | |||||
tensor_dy = tf.add(tensor_dy1, tensor_dy2) | |||||
op = tf.nn.depthwise_conv2d_backprop_filter(tensor_x, filter_size, tensor_dy, | |||||
strides=[1, strideh, stridew, 1], | |||||
padding=padding, | |||||
data_format='NHWC', | |||||
dilations=[1,1,1,1]) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_depth_wise_conv2d.pb", as_text=False) |
@@ -0,0 +1,14 @@ | |||||
import tensorflow as tf | |||||
import os | |||||
from tensorflow.python.framework import graph_util | |||||
from tensorflow.python.ops import gen_data_flow_ops | |||||
import numpy as np | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
size = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
value = tf.compat.v1.placeholder(dtype="float32", shape=(2,2)) | |||||
index = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
flow = tf.compat.v1.placeholder(dtype="float32", shape=()) | |||||
handleTensor = gen_data_flow_ops.tensor_array_v3(size= size, dtype = np.float32) | |||||
output = gen_data_flow_ops.tensor_array_write_v3(handle = handleTensor[0], index=index, value=value, flow_in=flow) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="tensor_array.pb", as_text=False) |
@@ -0,0 +1,71 @@ | |||||
{ | |||||
"node": [ | |||||
{ | |||||
"attr": [ | |||||
{ | |||||
"key": "dtype", | |||||
"value": { | |||||
"type": "DT_HALF" | |||||
} | |||||
}, | |||||
{ | |||||
"key": "shape", | |||||
"value": { | |||||
"shape": { | |||||
"dim": [ | |||||
{ | |||||
"size": 1 | |||||
} | |||||
] | |||||
} | |||||
} | |||||
} | |||||
], | |||||
"name": "Placeholder", | |||||
"op": "Placeholder" | |||||
}, | |||||
{ | |||||
"attr": [ | |||||
{ | |||||
"key": "dtype", | |||||
"value": { | |||||
"type": "DT_HALF" | |||||
} | |||||
}, | |||||
{ | |||||
"key": "shape", | |||||
"value": { | |||||
"shape": { | |||||
"dim": [ | |||||
{ | |||||
"size": 1 | |||||
} | |||||
] | |||||
} | |||||
} | |||||
} | |||||
], | |||||
"name": "Placeholder_1", | |||||
"op": "Placeholder" | |||||
}, | |||||
{ | |||||
"attr": [ | |||||
{ | |||||
"key": "T", | |||||
"value": { | |||||
"type": "DT_HALF" | |||||
} | |||||
} | |||||
], | |||||
"input": [ | |||||
"Placeholder", | |||||
"Placeholder_1" | |||||
], | |||||
"name": "add_test_1", | |||||
"op": "Add" | |||||
} | |||||
], | |||||
"versions": { | |||||
"producer": 134 | |||||
} | |||||
} |
@@ -0,0 +1,14 @@ | |||||
import tensorflow as tf | |||||
import numpy as np | |||||
def generate_VarIsInitializedOp_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
y = tf.Variable(tf.compat.v1.random_normal(shape=[4,3],mean=0,stddev=1), dtype="float32", name='y') | |||||
init = tf.compat.v1.global_variables_initializer() | |||||
sess.run(init) | |||||
op = tf.compat.v1.raw_ops.VarIsInitializedOp(resource=y, name="VarIsInitializedOp") | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_VarIsInitializedOp.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_VarIsInitializedOp_pb() |
@@ -0,0 +1,41 @@ | |||||
import tensorflow as tf | |||||
import os | |||||
import numpy as np | |||||
from tensorflow.python.framework import graph_util | |||||
pb_file_path = os.getcwd() | |||||
def generate_case_1(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
grads_1 = tf.compat.v1.placeholder(dtype="float16", shape=(1,2,2,2,1)) | |||||
grads_2 = tf.compat.v1.placeholder(dtype="float16", shape=(1,2,2,2,1)) | |||||
grads = tf.add(grads_1, grads_2) | |||||
orig_input_shape = tf.constant(np.array([1,3,3,3,1]).astype("int32")) | |||||
op = tf.raw_ops.AvgPool3DGrad(orig_input_shape=orig_input_shape, | |||||
grad=grads, | |||||
ksize=[1,2,2,2,1], | |||||
strides=[1,1,1,1,1], | |||||
padding="VALID", | |||||
data_format='NDHWC', | |||||
name='AvgPool3DGrad') | |||||
tf.io.write_graph(sess.graph, logdir="./", name="avgpool3dgrad_case_1.pb", as_text=False) | |||||
def generate_case_2(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
grads_1 = tf.compat.v1.placeholder(dtype="float16", shape=(1,1,2,2,2)) | |||||
grads_2 = tf.compat.v1.placeholder(dtype="float16", shape=(1,1,2,2,2)) | |||||
grads = tf.add(grads_1, grads_2) | |||||
orig_input_shape = tf.constant(np.array([1,1,3,3,3]).astype("int32"), ) | |||||
op = tf.raw_ops.AvgPool3DGrad(orig_input_shape=orig_input_shape, | |||||
grad=grads, | |||||
ksize=[1,1,2,2,2], | |||||
strides=[1,1,1,1,1], | |||||
padding="VALID", | |||||
data_format='NCDHW', | |||||
name='AvgPool3DGrad') | |||||
tf.io.write_graph(sess.graph, logdir="./", name="avgpool3dgrad.pb.txt", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_case_2() |
@@ -0,0 +1,34 @@ | |||||
import tensorflow as tf | |||||
import os | |||||
pb_file_path = os.getcwd() | |||||
def generate_case_0(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
input_dtype = tf.float32 | |||||
input_shape0 = [1, ] | |||||
input_shape1 = [202, 1, 768] | |||||
input_shape2 = [1, 1] | |||||
input_shape3 = [1, 1] | |||||
input_shape4 = [769, 4] | |||||
input_shape5 = [1, ] | |||||
input_shape6 = [1, ] | |||||
input_shape7 = [1, ] | |||||
input_shape8 = [4, ] | |||||
d0 = tf.compat.v1.placeholder(dtype=tf.int64, shape=input_shape0) | |||||
d1 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape1) | |||||
d2 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape2) | |||||
d3 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape3) | |||||
d4 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape4) | |||||
d5 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape5) | |||||
d6 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape6) | |||||
d7 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape7) | |||||
d8 = tf.compat.v1.placeholder(dtype=input_dtype, shape=input_shape8) | |||||
i1, cs1, f1, o1, ci1, co1, h1 = tf.raw_ops.BlockLSTM(seq_len_max=d0, x=d1, cs_prev=d2, h_prev=d3, w=d4, wci=d5, wcf=d6, wco=d7, b=d8, | |||||
forget_bias=1, cell_clip=3, use_peephole=False, name="blockLSTM") | |||||
tf.io.write_graph(sess.graph, logdir="./", name="blocklstm_case.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_case_0() |
@@ -0,0 +1,21 @@ | |||||
import tensorflow as tf | |||||
import numpy as np | |||||
from tensorflow.python.framework import graph_util | |||||
def generate_constant_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
grads_1 = tf.compat.v1.placeholder(dtype="float16", shape=(1,1,2,2,2)) | |||||
grads_2 = tf.compat.v1.placeholder(dtype="float16", shape=(1,1,2,2,2)) | |||||
grads = tf.add(grads_1, grads_2) | |||||
orig_input_shape = tf.constant(np.array([1,1,3,3,3]).astype("int32"), ) | |||||
op = tf.raw_ops.AvgPool3DGrad(orig_input_shape=orig_input_shape, | |||||
grad=grads, | |||||
ksize=[1,1,2,2,2], | |||||
strides=[1,1,1,1,1], | |||||
padding="VALID", | |||||
data_format='NCDHW', | |||||
name='AvgPool3DGrad') | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_constant.pb", as_text=False) | |||||
if __name__ == "__main__": | |||||
generate_constant_pb() |
@@ -0,0 +1,26 @@ | |||||
import tensorflow as tf | |||||
import os | |||||
from tensorflow.python.framework import graph_util | |||||
pb_file_path = os.getcwd() | |||||
def generate_conv2d_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
input_x = tf.compat.v1.placeholder(dtype="float32", shape=(1,56,56,64)) | |||||
input_filter = tf.compat.v1.placeholder(dtype="float32", shape=(3,3,64,64)) | |||||
op = tf.nn.conv2d(input_x, input_filter, strides=[1,1,1,1], padding=[[0,0],[1,1],[1,1],[0,0]], | |||||
data_format="NHWC", dilations=[1,1,1,1], name='conv2d_res') | |||||
tf.io.write_graph(sess.graph, logdir="./", name="conv2d.pb", as_text=False) | |||||
def generate_add_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(tf.int32, name='x') | |||||
y = tf.compat.v1.placeholder(tf.int32, name='y') | |||||
b = tf.Variable(1, name='b') | |||||
xy = tf.multiply(x, y) | |||||
op = tf.add(xy, b, name='op_to_store') | |||||
tf.io.write_graph(sess.graph, logdir="./", name="model.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_conv2d_pb() | |||||
generate_add_pb() |
@@ -0,0 +1,13 @@ | |||||
import tensorflow as tf | |||||
from tensorflow.python.ops import control_flow_ops | |||||
def generate_enter_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
y = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
output1 = control_flow_ops.enter(x, frame_name = "output1") | |||||
output2 = control_flow_ops.enter(y, frame_name = "output2") | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_enter.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_enter_pb() |
@@ -0,0 +1,12 @@ | |||||
import tensorflow as tf | |||||
import numpy as np | |||||
def generate_fill_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=(2,2)) | |||||
y = tf.fill([1,2], value = 5) | |||||
z = tf.add(x,y) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_fill.pb", as_text=False) | |||||
if __name__ == "__main__": | |||||
generate_fill_pb() |
@@ -0,0 +1,13 @@ | |||||
import tensorflow as tf | |||||
def generate_identity_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
x_plus_1 = tf.add(x, 1, name='x_plus') | |||||
with tf.control_dependencies([x_plus_1]): | |||||
y = x | |||||
z = tf.identity(x,name='identity') | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_identity.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_identity_pb() |
@@ -0,0 +1,18 @@ | |||||
import tensorflow as tf | |||||
from tensorflow.python.framework import graph_util | |||||
import numpy as np | |||||
def generate_merge_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
dist = tf.compat.v1.placeholder(tf.float32, [100]) | |||||
tf.compat.v1.summary.histogram(name="Merge", values=dist) | |||||
writer = tf.compat.v1.summary.FileWriter("./tf_summary_merge_pb") | |||||
op = tf.compat.v1.summary.merge_all() | |||||
for step in range(10): | |||||
mean_moving_normal = np.random.normal(loc=step, scale=1, size=[100]) | |||||
summ = sess.run(op, feed_dict = {dist : mean_moving_normal}) | |||||
writer.add_summary(summ, global_step=step) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="merge.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_merge_pb() |
@@ -0,0 +1,14 @@ | |||||
import tensorflow as tf | |||||
import numpy as np | |||||
def generate_no_op_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
y = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
add_op = tf.add(x, y) | |||||
y2 = tf.no_op(name="train") | |||||
z = tf.group([add_op, y2]) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_no_op.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_no_op_pb() |
@@ -0,0 +1,10 @@ | |||||
import tensorflow as tf | |||||
def generate_reshape_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=(2,2)) | |||||
y = tf.compat.v1.reshape(x, [2,2]) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_reshape.pb", as_text=False) | |||||
if __name__ == "__main__": | |||||
generate_reshape_pb() |
@@ -0,0 +1,13 @@ | |||||
import tensorflow as tf | |||||
import numpy as np | |||||
def generate_sequeeze_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=(2,2)) | |||||
y = tf.constant([[1,2],[2,3]]) | |||||
z = tf.add(x,y) | |||||
op = tf.squeeze(z,name = "squeeze") | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_sequeeze.pb", as_text=False) | |||||
if __name__ == "__main__": | |||||
generate_sequeeze_pb() |
@@ -0,0 +1,11 @@ | |||||
import tensorflow as tf | |||||
import numpy as np | |||||
def generate_shape_n_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=(2,2)) | |||||
y = tf.shape_n([1,2], name= "shape_n") | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_shape_n.pb", as_text=False) | |||||
if __name__ == "__main__": | |||||
generate_shape_n_pb() |
@@ -0,0 +1,13 @@ | |||||
import tensorflow as tf | |||||
from tensorflow.python.ops import control_flow_ops | |||||
def generate_switch_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
y = tf.compat.v1.placeholder(dtype="int32", shape=()) | |||||
output1 = control_flow_ops.switch(x,False) | |||||
output2 = control_flow_ops.switch(y,True) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_switch.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_switch_pb() |
@@ -0,0 +1,13 @@ | |||||
import tensorflow as tf | |||||
def generate_VariableV2_pb(): | |||||
with tf.compat.v1.Session(graph=tf.Graph()) as sess: | |||||
x = tf.compat.v1.placeholder(dtype="int32", shape=(2,3)) | |||||
op = tf.raw_ops.VariableV2(shape=[2,3], dtype="int32", name="VariableV2") | |||||
init = tf.compat.v1.global_variables_initializer() | |||||
op_add = tf.add(x,op) | |||||
sess.run(init) | |||||
tf.io.write_graph(sess.graph, logdir="./", name="test_VariableV2.pb", as_text=False) | |||||
if __name__=='__main__': | |||||
generate_VariableV2_pb() |