[TF FE] Set single input tensor names in TF1 formats. (#22503)
Description: Change setting of names in TF1 to make single input tensor. Ticket: 129457 Code: * [x] Comments * [x] Code style (PEP8) * [x] Transformation generates reshape-able IR * [x] Transformation preserves original framework node names * [x] Transformation preserves tensor names Validation: * [x] Unit tests * [x] Framework operation tests * [x] Transformation tests Documentation: * [x] Supported frameworks operations list * [x] Guide on how to convert the **public** model * [x] User guide update --------- Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>
This commit is contained in:
parent
069bd84f60
commit
4f3474abf6
|
|
@ -42,7 +42,7 @@ class GraphIteratorTFGraph(GraphIterator):
|
|||
inp_names = []
|
||||
if hasattr(self.m_graph, 'inputs') and self.m_graph.inputs:
|
||||
for inp in self.m_graph.inputs:
|
||||
inp_names.append(inp.op.name)
|
||||
inp_names.append(inp.name)
|
||||
return inp_names
|
||||
for inp in inp_ops:
|
||||
assert isinstance(inp, tf.Operation), "Unknown node type. Expected tf.Operation, got {}".format(type(inp))
|
||||
|
|
|
|||
|
|
@ -284,6 +284,16 @@ def type_supported_by_tf_fe(input_model):
|
|||
return False
|
||||
|
||||
|
||||
def is_variable(func_input, captures):
|
||||
import tensorflow as tf
|
||||
if func_input.dtype == tf.resource:
|
||||
return True
|
||||
for capture in captures:
|
||||
if id(func_input) == id(capture[1]):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def create_tf_graph_iterator(input_model, placeholder_shapes, placeholder_data_types, example_input, share_weights):
|
||||
input_model = trace_tf_model_if_needed(input_model, placeholder_shapes, placeholder_data_types, example_input)
|
||||
|
||||
|
|
@ -300,7 +310,7 @@ def create_tf_graph_iterator(input_model, placeholder_shapes, placeholder_data_t
|
|||
if hasattr(input_model, 'inputs') and hasattr(input_model, 'structured_input_signature'):
|
||||
internal_tensor_names = []
|
||||
for func_input in input_model.inputs:
|
||||
if func_input.dtype == tf.resource:
|
||||
if is_variable(func_input, input_model.graph.captures):
|
||||
continue
|
||||
internal_tensor_names.append(func_input.name)
|
||||
if len(input_model.structured_input_signature) > 0 and \
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public:
|
|||
|
||||
std::vector<std::shared_ptr<OpPlace>> get_op_places();
|
||||
std::map<std::string, std::shared_ptr<TensorPlace>> get_tensor_places() const {
|
||||
return m_tensor_places;
|
||||
return m_default_places;
|
||||
}
|
||||
std::map<std::string, Output<Node>> get_tensor_values() const {
|
||||
return m_tensor_values;
|
||||
|
|
@ -98,7 +98,7 @@ private:
|
|||
|
||||
std::vector<std::shared_ptr<OpPlace>> m_op_places;
|
||||
std::map<std::string, std::shared_ptr<OpPlace>> m_op_places_map;
|
||||
mutable std::map<std::string, std::shared_ptr<TensorPlace>> m_tensor_places;
|
||||
mutable std::map<std::string, std::shared_ptr<TensorPlace>> m_default_places;
|
||||
std::vector<ov::frontend::Place::Ptr> m_inputs;
|
||||
std::vector<ov::frontend::Place::Ptr> m_outputs;
|
||||
std::map<std::string, Output<Node>> m_tensor_values;
|
||||
|
|
@ -181,15 +181,15 @@ void InputModel::InputModelTFImpl::load_places() {
|
|||
// put places for all inputs of a model into m_inputs
|
||||
if (op_type == "Placeholder" || op_type == "PlaceholderWithDefault") {
|
||||
if (m_input_names.size() > 0 &&
|
||||
std::find(m_input_names.begin(), m_input_names.end(), op_name) == m_input_names.end()) {
|
||||
std::find(m_input_names.begin(), m_input_names.end(), op_name + ":0") == m_input_names.end()) {
|
||||
// this is a body graph since it contains non-empty m_input_names
|
||||
// such node not included into m_input_names should be skipped
|
||||
continue;
|
||||
}
|
||||
|
||||
// in case Placeholder we put created TensorPlace to both m_tensor_places container and m_inputs
|
||||
// in case Placeholder we put created TensorPlace to both m_default_places container and m_inputs
|
||||
// since they can be used if user does not override them
|
||||
// in case PlaceholderWithDefault we put created TensorPlace only to m_tensor_places container
|
||||
// in case PlaceholderWithDefault we put created TensorPlace only to m_default_places container
|
||||
// so that we know its shape and type for a case of custom input
|
||||
// by default, PlaceholderWithDefault is replaced by Constant with the default value
|
||||
auto pshape = ov::PartialShape::dynamic();
|
||||
|
|
@ -220,16 +220,10 @@ void InputModel::InputModelTFImpl::load_places() {
|
|||
if (dtype_any.is<ov::element::Type>()) {
|
||||
type = dtype_any.as<ov::element::Type>();
|
||||
}
|
||||
std::vector<std::string> names = {op_name};
|
||||
std::vector<std::string> names = {op_name + ":0"};
|
||||
auto tensor_place = std::make_shared<TensorPlace>(m_input_model, pshape, type, names);
|
||||
|
||||
// In Model Optimizer user can refer to model inputs by a name of Placeholder
|
||||
// and its output port, for example, using `input_name` and `input_name:0`
|
||||
// Also, SavedModel format contains a signature that maps external input names to internal ones with port
|
||||
// index like `input_name` maps to `serving_default_input_name:0`.
|
||||
// So we have to store with `:0` as well to get its tensor by `get_place_by_tensor_name` method
|
||||
m_tensor_places[op_name] = tensor_place;
|
||||
m_tensor_places[op_name + ":0"] = tensor_place;
|
||||
m_default_places[op_name + ":0"] = tensor_place;
|
||||
|
||||
if (op_type == "Placeholder") {
|
||||
// by default, PlaceholderWithDefault is NOT used as input
|
||||
|
|
@ -276,7 +270,7 @@ void InputModel::InputModelTFImpl::load_places() {
|
|||
ov::PartialShape({}),
|
||||
ov::element::dynamic,
|
||||
std::vector<std::string>{output_internal_tensor_name});
|
||||
m_tensor_places[output_internal_tensor_name] = output_place;
|
||||
m_default_places[output_internal_tensor_name] = output_place;
|
||||
m_outputs.push_back(output_place);
|
||||
}
|
||||
return;
|
||||
|
|
@ -297,7 +291,7 @@ void InputModel::InputModelTFImpl::load_places() {
|
|||
ov::element::dynamic,
|
||||
std::vector<std::string>{output_name + ":0"});
|
||||
// TODO: Create tensor places for each ouput port, ticket-129464
|
||||
m_tensor_places[output_name + ":0"] = output_place;
|
||||
m_default_places[output_name + ":0"] = output_place;
|
||||
m_outputs.push_back(output_place);
|
||||
}
|
||||
return;
|
||||
|
|
@ -307,7 +301,7 @@ void InputModel::InputModelTFImpl::load_places() {
|
|||
ov::PartialShape({}),
|
||||
ov::element::dynamic,
|
||||
std::vector<std::string>{output_name});
|
||||
m_tensor_places[output_name] = output_place;
|
||||
m_default_places[output_name] = output_place;
|
||||
m_outputs.push_back(output_place);
|
||||
}
|
||||
}
|
||||
|
|
@ -429,16 +423,16 @@ std::vector<std::shared_ptr<OpPlace>> InputModel::InputModelTFImpl::topologicall
|
|||
// 1. check if the current node is pruned by its input port
|
||||
bool is_input = false;
|
||||
std::string input_port_name = std::to_string(input_port_idx) + ":" + current_operation_name;
|
||||
if (m_tensor_places.find(input_port_name) != m_tensor_places.end()) {
|
||||
const auto& tensor_place = m_tensor_places[input_port_name];
|
||||
if (m_default_places.find(input_port_name) != m_default_places.end()) {
|
||||
const auto& tensor_place = m_default_places[input_port_name];
|
||||
is_input |= tensor_place->is_input();
|
||||
m_found_inputs.insert(input_port_name);
|
||||
}
|
||||
|
||||
// 2. check if the producer node is pruned by its output port
|
||||
std::string output_port_name = producer_name + ":" + std::to_string(producer_output_port_idx);
|
||||
if (m_tensor_places.find(output_port_name) != m_tensor_places.end()) {
|
||||
const auto& tensor_place = m_tensor_places[output_port_name];
|
||||
if (m_default_places.find(output_port_name) != m_default_places.end()) {
|
||||
const auto& tensor_place = m_default_places[output_port_name];
|
||||
is_input |= tensor_place->is_input();
|
||||
m_found_inputs.insert(output_port_name);
|
||||
}
|
||||
|
|
@ -447,8 +441,8 @@ std::vector<std::shared_ptr<OpPlace>> InputModel::InputModelTFImpl::topologicall
|
|||
FRONT_END_GENERAL_CHECK(m_op_places_map.count(producer_name),
|
||||
"There is no operation node with name: " + producer_name);
|
||||
const auto& producer_operation_place = m_op_places_map.at(producer_name);
|
||||
if (m_tensor_places.find(producer_name) != m_tensor_places.end()) {
|
||||
const auto& tensor_place = m_tensor_places[producer_name];
|
||||
if (m_default_places.find(producer_name) != m_default_places.end()) {
|
||||
const auto& tensor_place = m_default_places[producer_name];
|
||||
is_input |= tensor_place->is_input();
|
||||
m_found_inputs.insert(producer_name);
|
||||
}
|
||||
|
|
@ -570,7 +564,7 @@ ov::frontend::Place::Ptr InputModel::InputModelTFImpl::get_place_by_tensor_name(
|
|||
std::string internal_tensor_name = tensorName;
|
||||
|
||||
// For SavedModel format, an user can work with external input names, namely, without `serving_default_` prefix
|
||||
// so we have to map it into the internal name to find the tensor in the tensor pool m_tensor_places.
|
||||
// so we have to map it into the internal name to find the tensor in the tensor pool m_default_places.
|
||||
// m_saved_model_input_names contains a map from external name to the internal name with port ':0'
|
||||
// for example, `input_mask` maps to `serving_default_input_mask:0`
|
||||
if (m_saved_model_input_names) {
|
||||
|
|
@ -591,8 +585,17 @@ ov::frontend::Place::Ptr InputModel::InputModelTFImpl::get_place_by_tensor_name(
|
|||
}
|
||||
}
|
||||
|
||||
if (m_tensor_places.find(internal_tensor_name) != m_tensor_places.end()) {
|
||||
return m_tensor_places.at(internal_tensor_name);
|
||||
if (m_default_places.find(internal_tensor_name) != m_default_places.end()) {
|
||||
return m_default_places.at(internal_tensor_name);
|
||||
} else if (m_default_places.find(internal_tensor_name + ":0") != m_default_places.end()) {
|
||||
auto default_place = m_default_places.at(internal_tensor_name + ":0");
|
||||
std::vector<std::string> names = {internal_tensor_name};
|
||||
auto new_place = std::make_shared<TensorPlace>(m_input_model,
|
||||
default_place->get_partial_shape(),
|
||||
default_place->get_element_type(),
|
||||
names);
|
||||
m_default_places[internal_tensor_name] = new_place;
|
||||
return new_place;
|
||||
}
|
||||
|
||||
// check that operation node exists for which this place is specified
|
||||
|
|
@ -606,7 +609,7 @@ ov::frontend::Place::Ptr InputModel::InputModelTFImpl::get_place_by_tensor_name(
|
|||
std::vector<std::string> names = {internal_tensor_name};
|
||||
auto m_var_place =
|
||||
std::make_shared<TensorPlace>(m_input_model, ov::PartialShape::dynamic(), ov::element::dynamic, names);
|
||||
m_tensor_places[internal_tensor_name] = m_var_place;
|
||||
m_default_places[internal_tensor_name] = m_var_place;
|
||||
return m_var_place;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -446,7 +446,8 @@ void TranslateSession::translate_graph(const ov::frontend::InputModel::Ptr& inpu
|
|||
}
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(input_type, input_shape);
|
||||
set_node_name(input_name, param);
|
||||
param->set_friendly_name(input_name);
|
||||
set_out_name(input_name, param);
|
||||
params.push_back(param);
|
||||
(*ov_tensors_map)[input_name] = {NamedOutput(param)};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -773,7 +773,7 @@ TEST_F(FrontEndConversionWithReferenceTestsF, TF1IfWithNonExistentOpInBranch) {
|
|||
{},
|
||||
{},
|
||||
{},
|
||||
{"cond"},
|
||||
{"cond:0"},
|
||||
{&cond_value});
|
||||
}
|
||||
{
|
||||
|
|
|
|||
|
|
@ -27,9 +27,13 @@ OutputVector translate_identity_op(const NodeContext& node) {
|
|||
default_op_checks(node, 1, supported_ops, true);
|
||||
auto input = node.get_input(0);
|
||||
|
||||
// set only tensor names
|
||||
// no need to change node name since Identity node is skipped
|
||||
set_out_name(node.get_name() + ":" + "0", input);
|
||||
// We do not add tensor name, if producer node is Parameter
|
||||
// to prevent multiple names on model inputs
|
||||
if (!as_type_ptr<ov::op::v0::Parameter>(input.get_node_shared_ptr())) {
|
||||
// set only tensor names
|
||||
// no need to change node name since Identity node is skipped
|
||||
set_out_name(node.get_name() + ":" + "0", input);
|
||||
}
|
||||
return {input};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,6 @@ namespace tensorflow {
|
|||
void set_node_name(const string& node_name, const shared_ptr<Node>& node) {
|
||||
const auto& outputs = node->outputs();
|
||||
node->set_friendly_name(node_name);
|
||||
// TODO: Remove this and set single tensor names for model inputs, ticket - 129457
|
||||
if (outputs.size() == 1 && as_type_ptr<v0::Parameter>(node)) {
|
||||
set_out_name(node_name, outputs[0]);
|
||||
}
|
||||
for (size_t idx = 0; idx < outputs.size(); ++idx) {
|
||||
set_out_name({node_name + ":" + to_string(idx)}, outputs[idx]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,8 +168,12 @@ class CommonLayerTest:
|
|||
from common.utils.common_utils import allclose
|
||||
for framework_out_name in framework_res:
|
||||
ie_out_name = framework_out_name
|
||||
if ie_out_name not in infer_res and len(infer_res) == 1:
|
||||
ie_res = list(infer_res.values())[0]
|
||||
else:
|
||||
ie_res = infer_res[ie_out_name]
|
||||
|
||||
if not allclose(infer_res[ie_out_name], framework_res[framework_out_name],
|
||||
if not allclose(ie_res, framework_res[framework_out_name],
|
||||
atol=framework_eps,
|
||||
rtol=framework_eps):
|
||||
is_ok = False
|
||||
|
|
|
|||
|
|
@ -151,33 +151,33 @@ class TestComplexParams(CommonMOConvertTest):
|
|||
'params_ref': {'input': "Relu1[3 2]{i32},Relu2[3..10 2..]{i32},Relu3[3 2]{i32}"}},
|
||||
{'params_test': {'output': ["Sigmoid_0", "Sigmoid_2"]},
|
||||
'params_ref': {'output': "Sigmoid_0,Sigmoid_2"}},
|
||||
{'params_test': {'mean_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]},
|
||||
{'params_test': {'mean_values': {'Input1:0': [0.5,1.3,0.67], 'Input2:0':[4.2, 6.7, 3.15], 'Input3:0':[0.757, 4.6, 7.3]},
|
||||
'compress_to_fp16': True},
|
||||
'params_ref': {'mean_values': "Input1[0.5,1.3,0.67],Input2[4.2,6.7,3.15],Input3[0.757,4.6,7.3]"}},
|
||||
'params_ref': {'mean_values': "Input1:0[0.5,1.3,0.67],Input2:0[4.2,6.7,3.15],Input3:0[0.757,4.6,7.3]"}},
|
||||
{'params_test': {
|
||||
'mean_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'compress_to_fp16': True},
|
||||
'params_ref': {'mean_values': "[0.5,1.3,0.67],[4.2,6.7,3.15],[0.757,4.6,7.3]"}},
|
||||
{'params_test': {'scale_values': {'Input1': [0.5,1.3,0.67], 'Input2':[4.2, 6.7, 3.15], 'Input3':[0.757, 4.6, 7.3]},
|
||||
{'params_test': {'scale_values': {'Input1:0': [0.5,1.3,0.67], 'Input2:0':[4.2, 6.7, 3.15], 'Input3:0':[0.757, 4.6, 7.3]},
|
||||
'compress_to_fp16': True},
|
||||
'params_ref': {'scale_values': "Input1[0.5,1.3,0.67],Input2[4.2,6.7,3.15],Input3[0.757,4.6,7.3]"}},
|
||||
'params_ref': {'scale_values': "Input1:0[0.5,1.3,0.67],Input2:0[4.2,6.7,3.15],Input3:0[0.757,4.6,7.3]"}},
|
||||
{'params_test': {
|
||||
'scale_values': [[0.5, 1.3, 0.67], [4.2, 6.7, 3.15], [0.757, 4.6, 7.3]], 'compress_to_fp16': True},
|
||||
'params_ref': {'scale_values': "[0.5,1.3,0.67],[4.2,6.7,3.15],[0.757,4.6,7.3]"}},
|
||||
{'params_test': {
|
||||
'source_layout': {'Input1': Layout("nchw"), 'Input2': "nchw", 'Input3': "nc??"}, 'compress_to_fp16': True},
|
||||
'params_ref': {'source_layout': "Input1(nchw),Input2(nchw),Input3(nc??)"}},
|
||||
'source_layout': {'Input1:0': Layout("nchw"), 'Input2:0': "nchw", 'Input3:0': "nc??"}, 'compress_to_fp16': True},
|
||||
'params_ref': {'source_layout': "Input1:0(nchw),Input2:0(nchw),Input3:0(nc??)"}},
|
||||
{'params_test': {
|
||||
'target_layout': {'Input1': Layout("nhwc"), 'Input2': "nhwc", 'Input3': "n??c"}, 'compress_to_fp16': True},
|
||||
'params_ref': {'target_layout': "Input1(nhwc),Input2(nhwc),Input3(n??c)"}},
|
||||
'target_layout': {'Input1:0': Layout("nhwc"), 'Input2:0': "nhwc", 'Input3:0': "n??c"}, 'compress_to_fp16': True},
|
||||
'params_ref': {'target_layout': "Input1:0(nhwc),Input2:0(nhwc),Input3:0(n??c)"}},
|
||||
{'params_test': {
|
||||
'layout': {'Input1': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"),
|
||||
'Input2': LayoutMap(source_layout="nc??", target_layout=Layout("n??c")),
|
||||
'Input3': LayoutMap(source_layout="abcd", target_layout="acdb")}, 'compress_to_fp16': True},
|
||||
'params_ref': {'layout': "Input1(nchw->nhwc),Input2(nc??->n??c),Input3(abcd->acdb)"}},
|
||||
'layout': {'Input1:0': LayoutMap(source_layout=Layout("nchw"), target_layout="nhwc"),
|
||||
'Input2:0': LayoutMap(source_layout="nc??", target_layout=Layout("n??c")),
|
||||
'Input3:0': LayoutMap(source_layout="abcd", target_layout="acdb")}, 'compress_to_fp16': True},
|
||||
'params_ref': {'layout': "Input1:0(nchw->nhwc),Input2:0(nc??->n??c),Input3:0(abcd->acdb)"}},
|
||||
{'params_test': {'input': [PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)]]},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1:0,Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': [np.int32, Type(np.int32), np.int32]},
|
||||
'params_ref': {'input': 'Input1{i32},Input2{i32},Input3{i32}'}},
|
||||
'params_ref': {'input': 'Input1:0{i32},Input2:0{i32},Input3:0{i32}'}},
|
||||
{'params_test': {'input': [InputCutInfo(shape=[1], type=np.int32, value=[10]),
|
||||
InputCutInfo(shape=[1], type=np.int32, value=[20]),
|
||||
InputCutInfo(shape=[1], type=np.int32, value=[30])]},
|
||||
|
|
@ -206,13 +206,13 @@ class TestComplexParams(CommonMOConvertTest):
|
|||
{'params_test': {'input': [PartialShape([Dimension(-1), 5, 6]), [-1, 5, 6]],
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'},
|
||||
|
||||
'params_ref': {'input': 'Input1[?,5,6],Input2[?,5,6]',
|
||||
'params_ref': {'input': 'Input1:0[?,5,6],Input2:0[?,5,6]',
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'}},
|
||||
{'params_test': {'input': [np.float16, np.float16],
|
||||
'input_shape': [[10, 20], [10, 20]],
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'},
|
||||
|
||||
'params_ref': {'input': 'Input1{f16},Input2{f16}',
|
||||
'params_ref': {'input': 'Input1:0{f16},Input2:0{f16}',
|
||||
'input_shape': "[10,20],[10,20]",
|
||||
'freeze_placeholder_with_value': 'Input3->[1]'}},
|
||||
|
||||
|
|
@ -283,27 +283,27 @@ class TestComplexParams(CommonMOConvertTest):
|
|||
{'params_test': {'layout': Layout("nchw"), 'compress_to_fp16': True},
|
||||
'params_ref': {'layout': "nchw"}},
|
||||
{'params_test': {'input': [3, 2]},
|
||||
'params_ref': {'input': "Input[3 2]"}},
|
||||
'params_ref': {'input': "Input:0[3 2]"}},
|
||||
{'params_test': {'input': [Dimension(3,10), 2]},
|
||||
'params_ref': {'input': "Input[3..10 2]"}},
|
||||
'params_ref': {'input': "Input:0[3..10 2]"}},
|
||||
{'params_test': {'input': (-1, 10)},
|
||||
'params_ref': {'input': "Input[?,10]"}},
|
||||
'params_ref': {'input': "Input:0[?,10]"}},
|
||||
{'params_test': {'input': PartialShape([-1, 10])},
|
||||
'params_ref': {'input': "Input[?,10]"}},
|
||||
'params_ref': {'input': "Input:0[?,10]"}},
|
||||
{'params_test': {'input': np.int32},
|
||||
'params_ref': {'input': "Input{i32}"}},
|
||||
'params_ref': {'input': "Input:0{i32}"}},
|
||||
{'params_test': {'input': InputCutInfo(shape=[1], type=np.int32, value=[10])},
|
||||
'params_ref': {'input': "Input[1]{i32}->[10]"}},
|
||||
'params_ref': {'input': "Input:0[1]{i32}->[10]"}},
|
||||
{'params_test': {'input': (np.int32, [1, 2, 3])},
|
||||
'params_ref': {'input': "Input[1,2,3]{i32}"}},
|
||||
'params_ref': {'input': "Input:0[1,2,3]{i32}"}},
|
||||
{'params_test': {'input_shape': [Dimension(3, 10), 10, -1], 'compress_to_fp16': True},
|
||||
'params_ref': {'input_shape': '[3..10,10,?]'}},
|
||||
{'params_test': {'input': [Dimension(3, 10), 10, -1]},
|
||||
'params_ref': {'input': 'Input[3..10,10,?]'}},
|
||||
'params_ref': {'input': 'Input:0[3..10,10,?]'}},
|
||||
{'params_test': {'input': PartialShape([1, 100, 100, 3]), 'mean_values': [0.5, 1.3, 0.67], 'compress_to_fp16': True},
|
||||
'params_ref': {'input': "Input[1,100,100,3]", 'mean_values': "[0.5,1.3,0.67]"}},
|
||||
'params_ref': {'input': "Input:0[1,100,100,3]", 'mean_values': "[0.5,1.3,0.67]"}},
|
||||
{'params_test': {'input': [1, 100, 100, 3], 'scale_values': [0.5, 1.3, 0.67], 'compress_to_fp16': True},
|
||||
'params_ref': {'input': "Input[1,100,100,3]", 'scale_values': "[0.5,1.3,0.67]"}},
|
||||
'params_ref': {'input': "Input:0[1,100,100,3]", 'scale_values': "[0.5,1.3,0.67]"}},
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
# Copyright (C) 2018-2023 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import unittest
|
||||
|
||||
import numpy as np
|
||||
import openvino.runtime as ov
|
||||
import pytest
|
||||
import tempfile
|
||||
import unittest
|
||||
from openvino.runtime import PartialShape, Model, Dimension
|
||||
from pathlib import Path
|
||||
|
||||
from common.mo_convert_test_class import CommonMOConvertTest
|
||||
from common import constants
|
||||
from common.layer_test_class import CommonLayerTest
|
||||
from common.mo_convert_test_class import CommonMOConvertTest
|
||||
from common.tf_layer_test_class import save_to_pb
|
||||
|
||||
|
||||
def create_tf_graph_def(tmp_dir):
|
||||
|
|
@ -985,3 +988,112 @@ class TestTFLoadByModel(unittest.TestCase):
|
|||
fe = fem.load_by_model(model)
|
||||
assert fe is not None
|
||||
assert fe.get_name() == "tf"
|
||||
|
||||
|
||||
class TestInputTensorName(unittest.TestCase):
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.precommit
|
||||
def test_tf1_from_file_single_input_name(self):
|
||||
import tensorflow as tf
|
||||
tf.keras.backend.clear_session()
|
||||
tf.compat.v1.reset_default_graph()
|
||||
Path(constants.out_path).mkdir(parents=True, exist_ok=True)
|
||||
tmp_dir = tempfile.TemporaryDirectory(dir=constants.out_path).name
|
||||
from openvino.tools.mo import convert_model
|
||||
|
||||
model, _, _ = create_tf_graph_def(None)
|
||||
path = save_to_pb(model, tmp_dir)
|
||||
|
||||
ov_model = convert_model(path)
|
||||
|
||||
ref_inputs = ["Input:0", "Input_1:0"]
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
ov_model = convert_model(path, input=["Input:0", "Input_1:0"])
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
ref_inputs = ["Input", "Input_1"]
|
||||
ov_model = convert_model(path, input=["Input", "Input_1"])
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.precommit
|
||||
def test_tf1_from_memory_single_input_name(self):
|
||||
import tensorflow as tf
|
||||
tf.keras.backend.clear_session()
|
||||
tf.compat.v1.reset_default_graph()
|
||||
from openvino.tools.mo import convert_model
|
||||
|
||||
model, _, _ = create_tf_graph_def(None)
|
||||
|
||||
ov_model = convert_model(model)
|
||||
|
||||
ref_inputs = ["Input:0", "Input_1:0"]
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
ov_model = convert_model(model, input=["Input:0", "Input_1:0"])
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
ref_inputs = ["Input", "Input_1"]
|
||||
ov_model = convert_model(model, input=["Input", "Input_1"])
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.precommit
|
||||
def test_tf1_input_with_identity(self):
|
||||
import tensorflow as tf
|
||||
tf.keras.backend.clear_session()
|
||||
tf.compat.v1.reset_default_graph()
|
||||
from openvino.tools.mo import convert_model
|
||||
|
||||
with tf.compat.v1.Session() as sess:
|
||||
x = tf.compat.v1.placeholder(tf.float32, [2], 'x')
|
||||
y = tf.compat.v1.placeholder(tf.float32, [2], 'y')
|
||||
input1 = tf.identity(x, name="x_identity")
|
||||
input2 = tf.identity(y, name="y_identity")
|
||||
add = tf.add(input1, input2, name="add")
|
||||
|
||||
tf.compat.v1.global_variables_initializer()
|
||||
model = sess.graph_def
|
||||
|
||||
ov_model = convert_model(model)
|
||||
|
||||
assert ov_model.inputs[0].get_names() == {"x:0"}
|
||||
assert ov_model.inputs[1].get_names() == {"y:0"}
|
||||
|
||||
|
||||
ov_model = convert_model(model, input=["x", "y"])
|
||||
|
||||
assert ov_model.inputs[0].get_names() == {"x"}
|
||||
assert ov_model.inputs[1].get_names() == {"y"}
|
||||
|
|
|
|||
|
|
@ -76,35 +76,35 @@ class TestComplexParams(CommonMOConvertTest):
|
|||
{'params_test': {'output': ["Sigmoid_0:0"]},
|
||||
'params_ref': {'output': "Sigmoid_0"}},
|
||||
{'params_test': {'input': [PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)]]},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1:0,Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': [PartialShape([1, 3, -1, -1]), [1, 3, -1, -1]]},
|
||||
'params_ref': {'input_shape': "[1,3,?,?],[1,3,?,?]", 'input': 'Input1,Input2'}},
|
||||
'params_ref': {'input_shape': "[1,3,?,?],[1,3,?,?]", 'input': 'Input1:0,Input2:0'}},
|
||||
{'params_test': {'input': [(2, 3, 4), [2, 3, 4], (Dimension(2), Dimension(3), Dimension(4))]},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
|
||||
{'params_test': {'input': {"Input1": PartialShape([2, 3, 4]), "Input2": [2, 3, 4],
|
||||
"Input3": [Dimension(2), Dimension(3), Dimension(4)]}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
|
||||
{'params_test': {'input': {"Input2": [1, -1, -1, -1],
|
||||
"Input3": [Dimension(1), Dimension(-1), Dimension(-1), Dimension(-1)]}},
|
||||
'params_ref': {'input_shape': "[1,?,?,?],[1,?,?,?]", 'input': 'Input2,Input3'}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1:0,Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': {"Input1:0": PartialShape([2, 3, 4]), "Input2:0": [2, 3, 4],
|
||||
"Input3:0": [Dimension(2), Dimension(3), Dimension(4)]}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1:0,Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': {"Input2:0": [1, -1, -1, -1],
|
||||
"Input3:0": [Dimension(1), Dimension(-1), Dimension(-1), Dimension(-1)]}},
|
||||
'params_ref': {'input_shape': "[1,?,?,?],[1,?,?,?]", 'input': 'Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': [np.int32, Type(np.int32), np.int32]},
|
||||
'params_ref': {'input': 'Input1{i32},Input2{i32},Input3{i32}'}},
|
||||
'params_ref': {'input': 'Input1:0{i32},Input2:0{i32},Input3:0{i32}'}},
|
||||
{'params_test': {'input': [ov.Type.f32, ov.Type.f32]},
|
||||
'params_ref': {'input': 'Input1{f32},Input2{f32}'}},
|
||||
'params_ref': {'input': 'Input1:0{f32},Input2:0{f32}'}},
|
||||
{'params_test': {'input': [([1, 3, -1, -1], ov.Type.i32), ov.Type.i32, ov.Type.i32]},
|
||||
'params_ref': {'input': 'Input1[1,3,?,?]{i32},Input2{i32},Input3{i32}'}},
|
||||
'params_ref': {'input': 'Input1:0[1,3,?,?]{i32},Input2:0{i32},Input3:0{i32}'}},
|
||||
{'params_test': {'input': (PartialShape([2, 3, 4]), [2, 3, 4], [Dimension(2), Dimension(3), Dimension(4)])},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1:0,Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': (PartialShape([1, 3, -1, -1]), [1, 3, -1, -1])},
|
||||
'params_ref': {'input_shape': "[1,3,?,?],[1,3,?,?]", 'input': 'Input1,Input2'}},
|
||||
'params_ref': {'input_shape': "[1,3,?,?],[1,3,?,?]", 'input': 'Input1:0,Input2:0'}},
|
||||
{'params_test': {'input': ((2, 3, 4), [2, 3, 4], (Dimension(2), Dimension(3), Dimension(4)))},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1,Input2,Input3'}},
|
||||
'params_ref': {'input_shape': "[2,3,4],[2,3,4],[2,3,4]", 'input': 'Input1:0,Input2:0,Input3:0'}},
|
||||
{'params_test': {'input': (np.int32, Type(np.int32), np.int32)},
|
||||
'params_ref': {'input': 'Input1{i32},Input2{i32},Input3{i32}'}},
|
||||
'params_ref': {'input': 'Input1:0{i32},Input2:0{i32},Input3:0{i32}'}},
|
||||
{'params_test': {'input': (ov.Type.f32, ov.Type.f32)},
|
||||
'params_ref': {'input': 'Input1{f32},Input2{f32}'}},
|
||||
'params_ref': {'input': 'Input1:0{f32},Input2:0{f32}'}},
|
||||
{'params_test': {'input': (([1, 3, -1, -1], ov.Type.i32), ov.Type.i32, ov.Type.i32)},
|
||||
'params_ref': {'input': 'Input1[1,3,?,?]{i32},Input2{i32},Input3{i32}'}}
|
||||
'params_ref': {'input': 'Input1:0[1,3,?,?]{i32},Input2:0{i32},Input3:0{i32}'}}
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data)
|
||||
|
|
@ -120,30 +120,30 @@ class TestComplexParams(CommonMOConvertTest):
|
|||
self._test(temp_dir, test_params, ref_params)
|
||||
|
||||
test_data = [
|
||||
{'params_test': {'input': {"Input": ([3, 2], ov.Type.i32)}},
|
||||
'params_ref': {'input': "Input[3,2]{i32}"}},
|
||||
{'params_test': {'input': {"Input": ov.Type.i32}},
|
||||
'params_ref': {'input': "Input{i32}"}},
|
||||
{'params_test': {'input': {"Input": [3, 2]}},
|
||||
'params_ref': {'input': "Input[3,2]"}},
|
||||
{'params_test': {'input': {"Input:0": ([3, 2], ov.Type.i32)}},
|
||||
'params_ref': {'input': "Input:0[3,2]{i32}"}},
|
||||
{'params_test': {'input': {"Input:0": ov.Type.i32}},
|
||||
'params_ref': {'input': "Input:0{i32}"}},
|
||||
{'params_test': {'input': {"Input:0": [3, 2]}},
|
||||
'params_ref': {'input': "Input:0[3,2]"}},
|
||||
{'params_test': {'input': (3, 2)},
|
||||
'params_ref': {'input': "Input[3,2]"}},
|
||||
'params_ref': {'input': "Input:0[3,2]"}},
|
||||
{'params_test': {'input': (3, Dimension(2))},
|
||||
'params_ref': {'input': "Input[3,2]"}},
|
||||
'params_ref': {'input': "Input:0[3,2]"}},
|
||||
{'params_test': {'input': [3, 2]},
|
||||
'params_ref': {'input': "Input[3 2]"}},
|
||||
'params_ref': {'input': "Input:0[3 2]"}},
|
||||
{'params_test': {'input': [Dimension(3, 10), 2]},
|
||||
'params_ref': {'input': "Input[3..10 2]"}},
|
||||
'params_ref': {'input': "Input:0[3..10 2]"}},
|
||||
{'params_test': {'input': (-1, 10)},
|
||||
'params_ref': {'input': "Input[?,10]"}},
|
||||
'params_ref': {'input': "Input:0[?,10]"}},
|
||||
{'params_test': {'input': PartialShape([-1, 10])},
|
||||
'params_ref': {'input': "Input[?,10]"}},
|
||||
'params_ref': {'input': "Input:0[?,10]"}},
|
||||
{'params_test': {'input': np.int32},
|
||||
'params_ref': {'input': "Input{i32}"}},
|
||||
'params_ref': {'input': "Input:0{i32}"}},
|
||||
{'params_test': {'input': (np.int32, [1, 2, 3])},
|
||||
'params_ref': {'input': "Input[1,2,3]{i32}"}},
|
||||
'params_ref': {'input': "Input:0[1,2,3]{i32}"}},
|
||||
{'params_test': {'input': [Dimension(3, 10), 10, -1]},
|
||||
'params_ref': {'input': 'Input[3..10,10,?]'}},
|
||||
'params_ref': {'input': 'Input:0[3..10,10,?]'}},
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data)
|
||||
|
|
|
|||
|
|
@ -978,7 +978,7 @@ class TFGraphDefNames(unittest.TestCase):
|
|||
tf.import_graph_def(tf_model, name='')
|
||||
for op in graph.get_operations():
|
||||
if op.type == "Placeholder":
|
||||
input_list.append(op.name)
|
||||
input_list.append(op.name + ":0")
|
||||
|
||||
for input in input_list:
|
||||
found = False
|
||||
|
|
@ -1205,3 +1205,85 @@ class TestOutputTensorName(unittest.TestCase):
|
|||
|
||||
assert ov_model.outputs[0].get_names() == {"result1:0", "result2:0", "add:0"}
|
||||
assert ov_model.outputs[1].get_names() == {"result1:0", "result2:0", "add:0"}
|
||||
|
||||
|
||||
class TestInputTensorName(unittest.TestCase):
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.precommit
|
||||
def test_tf1_from_file_single_input_name(self):
|
||||
tf.keras.backend.clear_session()
|
||||
tf.compat.v1.reset_default_graph()
|
||||
Path(constants.out_path).mkdir(parents=True, exist_ok=True)
|
||||
tmp_dir = tempfile.TemporaryDirectory(dir=constants.out_path).name
|
||||
from openvino import convert_model
|
||||
|
||||
model, _, _ = create_tf_graph_def(None)
|
||||
path = save_to_pb(model, tmp_dir)
|
||||
|
||||
ov_model = convert_model(path)
|
||||
|
||||
ref_inputs = ["Input:0", "Input_1:0"]
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
ov_model = convert_model(path, input=["Input:0", "Input_1:0"])
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.precommit
|
||||
def test_tf1_from_memory_single_input_name(self):
|
||||
tf.keras.backend.clear_session()
|
||||
tf.compat.v1.reset_default_graph()
|
||||
from openvino import convert_model
|
||||
|
||||
model, _, _ = create_tf_graph_def(None)
|
||||
|
||||
ov_model = convert_model(model)
|
||||
|
||||
ref_inputs = ["Input:0", "Input_1:0"]
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
ov_model = convert_model(model, input=["Input:0", "Input_1:0"])
|
||||
for idx, output in enumerate(ov_model.inputs):
|
||||
tensors = output.get_names()
|
||||
|
||||
assert len(tensors) == 1
|
||||
out_tensor = list(tensors)[0]
|
||||
assert out_tensor == ref_inputs[idx]
|
||||
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.precommit
|
||||
def test_tf1_input_with_identity(self):
|
||||
tf.keras.backend.clear_session()
|
||||
tf.compat.v1.reset_default_graph()
|
||||
from openvino.tools.ovc import convert_model
|
||||
|
||||
with tf.compat.v1.Session() as sess:
|
||||
x = tf.compat.v1.placeholder(tf.float32, [2], 'x')
|
||||
y = tf.compat.v1.placeholder(tf.float32, [2], 'y')
|
||||
input1 = tf.identity(x, name="x_identity")
|
||||
input2 = tf.identity(y, name="y_identity")
|
||||
add = tf.add(input1, input2, name="add")
|
||||
|
||||
tf.compat.v1.global_variables_initializer()
|
||||
model = sess.graph_def
|
||||
|
||||
ov_model = convert_model(model)
|
||||
|
||||
assert ov_model.inputs[0].get_names() == {"x:0"}
|
||||
assert ov_model.inputs[1].get_names() == {"y:0"}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,15 @@ rng = np.random.default_rng()
|
|||
|
||||
class TestAddTypes(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
if np.issubdtype(self.input_type, np.floating):
|
||||
inputs_data['x'] = rng.uniform(-5.0, 5.0, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.uniform(-5.0, 5.0, x_shape).astype(self.input_type)
|
||||
elif np.issubdtype(self.input_type, np.signedinteger):
|
||||
inputs_data['x'] = rng.integers(-8, 8, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.integers(-8, 8, x_shape).astype(self.input_type)
|
||||
else:
|
||||
inputs_data['x'] = rng.integers(0, 8, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.integers(0, 8, x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_add_types_net(self, const_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestAdjustContrastv2(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'images' in inputs_info
|
||||
images_shape = inputs_info['images']
|
||||
assert 'images:0' in inputs_info
|
||||
images_shape = inputs_info['images:0']
|
||||
inputs_data = {}
|
||||
inputs_data['images'] = np.random.rand(*images_shape).astype(self.input_type)
|
||||
inputs_data['contrast_factor'] = np.random.rand()
|
||||
inputs_data['images:0'] = np.random.rand(*images_shape).astype(self.input_type)
|
||||
inputs_data['contrast_factor:0'] = np.random.rand()
|
||||
return inputs_data
|
||||
|
||||
def create_adjust_contrast_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ OPS = {
|
|||
|
||||
class TestArgMinMax(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['input'] = rng.integers(-8, 8, input_shape).astype(self.input_type)
|
||||
inputs_data['input:0'] = rng.integers(-8, 8, input_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_argmin_max_net(self, input_shape, dimension, input_type, output_type, op_type):
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@ OPS = {
|
|||
|
||||
class TestAssignOps(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
if np.issubdtype(self.input_type, np.floating):
|
||||
inputs_data['x'] = rng.uniform(-2.0, 2.0, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.uniform(-2.0, 2.0, x_shape).astype(self.input_type)
|
||||
elif np.issubdtype(self.input_type, np.signedinteger):
|
||||
inputs_data['x'] = rng.integers(-8, 8, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.integers(-8, 8, x_shape).astype(self.input_type)
|
||||
else:
|
||||
inputs_data['x'] = rng.integers(0, 8, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.integers(0, 8, x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_assign_net(self, const_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ rng = np.random.default_rng()
|
|||
|
||||
class TestAssignVariableOps(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = rng.uniform(-2.0, 2.0, x_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = rng.uniform(-2.0, 2.0, x_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_assign_variable_ops_net(self, const_shape):
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestAtan2(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'y' in inputs_info
|
||||
assert 'x' in inputs_info
|
||||
y_shape = inputs_info['y']
|
||||
x_shape = inputs_info['x']
|
||||
assert 'y:0' in inputs_info
|
||||
assert 'x:0' in inputs_info
|
||||
y_shape = inputs_info['y:0']
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['y'] = np.random.rand(*y_shape).astype(self.input_type) - np.random.rand(*y_shape).astype(self.input_type)
|
||||
inputs_data['x'] = np.random.rand(*x_shape).astype(self.input_type) - np.random.rand(*x_shape).astype(self.input_type)
|
||||
inputs_data['y:0'] = np.random.rand(*y_shape).astype(self.input_type) - np.random.rand(*y_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.rand(*x_shape).astype(self.input_type) - np.random.rand(*x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_atan2_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestBroadcastArgs(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 's0' in inputs_info, "Test error: inputs_info must contain `s0`"
|
||||
assert 's1' in inputs_info, "Test error: inputs_info must contain `s1`"
|
||||
s0_shape = inputs_info['s0']
|
||||
s1_shape = inputs_info['s1']
|
||||
assert 's0:0' in inputs_info, "Test error: inputs_info must contain `s0`"
|
||||
assert 's1:0' in inputs_info, "Test error: inputs_info must contain `s1`"
|
||||
s0_shape = inputs_info['s0:0']
|
||||
s1_shape = inputs_info['s1:0']
|
||||
inputs_data = {}
|
||||
inputs_data['s0'] = np.random.randint(1, 6, s0_shape)
|
||||
inputs_data['s1'] = np.random.randint(1, 6, s1_shape)
|
||||
inputs_data['s0:0'] = np.random.randint(1, 6, s0_shape)
|
||||
inputs_data['s1:0'] = np.random.randint(1, 6, s1_shape)
|
||||
# compute mask where we need to change dimension size in s1
|
||||
# so that s1 will be broadcastable to s0
|
||||
non_one_mask = inputs_data['s0'] != 1
|
||||
diff_size = len(inputs_data['s1']) - len(inputs_data['s0'])
|
||||
non_one_mask = inputs_data['s0:0'] != 1
|
||||
diff_size = len(inputs_data['s1:0']) - len(inputs_data['s0:0'])
|
||||
if diff_size > 0:
|
||||
# pad False elements to non_one_mask to the begin
|
||||
pad = np.full([diff_size], False, dtype=bool)
|
||||
|
|
@ -29,9 +29,8 @@ class TestBroadcastArgs(CommonTFLayerTest):
|
|||
diff_size = abs(diff_size)
|
||||
non_one_mask = non_one_mask[diff_size:]
|
||||
update_inds = np.argwhere(non_one_mask)
|
||||
inputs_data['s1'][update_inds] = 1
|
||||
inputs_data['s1:0'][update_inds] = 1
|
||||
|
||||
print("inputs_data = ", inputs_data)
|
||||
return inputs_data
|
||||
|
||||
def create_broadcast_args_net(self, s0_shape, s1_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestBucketize(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
input_shape = inputs_info['input:0']
|
||||
input_type = self.input_type
|
||||
inputs_data = {}
|
||||
input_data = np.random.randint(-20, 20, input_shape).astype(input_type)
|
||||
inputs_data['input'] = input_data
|
||||
inputs_data['input:0'] = input_data
|
||||
return inputs_data
|
||||
|
||||
def create_bucketize_net(self, input_shape, input_type, boundaries_size):
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ OPS = {
|
|||
|
||||
class TestCheckNumerics(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'y' in inputs_info
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
assert 'y:0' in inputs_info
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y'] = np.random.randint(-10, 10, y_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y:0'] = np.random.randint(-10, 10, y_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_check_numerics_net(self, input_shape, input_type, op):
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestClipByValue(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 't' in inputs_info, "Test error: inputs_info must contain `t`"
|
||||
t_shape = inputs_info['t']
|
||||
clip_value_min_shape = inputs_info['clip_value_min']
|
||||
clip_value_max_shape = inputs_info['clip_value_max']
|
||||
assert 't:0' in inputs_info, "Test error: inputs_info must contain `t`"
|
||||
t_shape = inputs_info['t:0']
|
||||
clip_value_min_shape = inputs_info['clip_value_min:0']
|
||||
clip_value_max_shape = inputs_info['clip_value_max:0']
|
||||
inputs_data = {}
|
||||
inputs_data['t'] = np.random.randint(-10, 10, t_shape).astype(np.float32)
|
||||
inputs_data['clip_value_min'] = np.random.randint(-10, 10, clip_value_min_shape).astype(np.float32)
|
||||
inputs_data['clip_value_max'] = np.random.randint(-10, 10, clip_value_max_shape).astype(np.float32)
|
||||
inputs_data['t:0'] = np.random.randint(-10, 10, t_shape).astype(np.float32)
|
||||
inputs_data['clip_value_min:0'] = np.random.randint(-10, 10, clip_value_min_shape).astype(np.float32)
|
||||
inputs_data['clip_value_max:0'] = np.random.randint(-10, 10, clip_value_max_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_clip_by_value_net(self, t_shape):
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ OPS = {
|
|||
class TestComplexFFT(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape = inputs_info['param_real']
|
||||
param_imag_shape = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape = inputs_info['param_real:0']
|
||||
param_imag_shape = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_fft_net(self, input_shape, shift_roll, axis_roll, fft_op):
|
||||
|
|
@ -88,13 +88,13 @@ class TestComplexFFT(CommonTFLayerTest):
|
|||
class TestComplexAbs(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape = inputs_info['param_real']
|
||||
param_imag_shape = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape = inputs_info['param_real:0']
|
||||
param_imag_shape = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_abs_net(self, input_shape):
|
||||
|
|
@ -131,10 +131,10 @@ class TestComplexAbs(CommonTFLayerTest):
|
|||
class TestComplexRFFT(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param' in inputs_info
|
||||
param_shape = inputs_info['param']
|
||||
assert 'param:0' in inputs_info
|
||||
param_shape = inputs_info['param:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param'] = 4 * rng.random(param_shape).astype(np.float32) - 2
|
||||
inputs_data['param:0'] = 4 * rng.random(param_shape).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_rfft_net(self, input_shape, fft_length, rfft_op):
|
||||
|
|
@ -175,13 +175,13 @@ class TestComplexRFFT(CommonTFLayerTest):
|
|||
class TestComplexIRFFT(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape = inputs_info['param_real']
|
||||
param_imag_shape = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape = inputs_info['param_real:0']
|
||||
param_imag_shape = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_irfft_net(self, input_shape, fft_length, irfft_op):
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ class TestComplexConjugate(CommonTFLayerTest):
|
|||
def _prepare_input(self, inputs_info):
|
||||
|
||||
rng = np.random.default_rng()
|
||||
assert 'real_part' in inputs_info
|
||||
real_part_shape = inputs_info['real_part']
|
||||
assert 'imag_part' in inputs_info
|
||||
imag_part_shape = inputs_info['imag_part']
|
||||
assert 'real_part:0' in inputs_info
|
||||
real_part_shape = inputs_info['real_part:0']
|
||||
assert 'imag_part:0' in inputs_info
|
||||
imag_part_shape = inputs_info['imag_part:0']
|
||||
|
||||
inputs_data = {}
|
||||
inputs_data['real_part'] = 4 * rng.random(real_part_shape).astype(np.float32) - 2
|
||||
inputs_data['imag_part'] = 4 * rng.random(imag_part_shape).astype(np.float32) - 2
|
||||
inputs_data['real_part:0'] = 4 * rng.random(real_part_shape).astype(np.float32) - 2
|
||||
inputs_data['imag_part:0'] = 4 * rng.random(imag_part_shape).astype(np.float32) - 2
|
||||
|
||||
return inputs_data
|
||||
def create_complex_conjugate_net(self, input_shape):
|
||||
|
|
|
|||
|
|
@ -15,14 +15,14 @@ class TestComplexConjugateTranspose(CommonTFLayerTest):
|
|||
def _prepare_input(self, inputs_info):
|
||||
|
||||
rng = np.random.default_rng()
|
||||
assert 'real_part' in inputs_info
|
||||
real_part_shape = inputs_info['real_part']
|
||||
assert 'imag_part' in inputs_info
|
||||
imag_part_shape = inputs_info['imag_part']
|
||||
assert 'real_part:0' in inputs_info
|
||||
real_part_shape = inputs_info['real_part:0']
|
||||
assert 'imag_part:0' in inputs_info
|
||||
imag_part_shape = inputs_info['imag_part:0']
|
||||
|
||||
inputs_data = {}
|
||||
inputs_data['real_part'] = 4 * rng.random(real_part_shape).astype(np.float32) - 2
|
||||
inputs_data['imag_part'] = 4 * rng.random(imag_part_shape).astype(np.float32) - 2
|
||||
inputs_data['real_part:0'] = 4 * rng.random(real_part_shape).astype(np.float32) - 2
|
||||
inputs_data['imag_part:0'] = 4 * rng.random(imag_part_shape).astype(np.float32) - 2
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
@ -75,11 +75,11 @@ class TestConjugateTranspose(CommonTFLayerTest):
|
|||
|
||||
def _prepare_input(self, inputs_info):
|
||||
|
||||
assert 'input' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.default_rng().random(input_shape).astype(np.float32)
|
||||
inputs_data['input:0'] = np.random.default_rng().random(input_shape).astype(np.float32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestCropAndResize(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'image' in inputs_info, "Test error: inputs_info must contain `image`"
|
||||
assert 'image:0' in inputs_info, "Test error: inputs_info must contain `image`"
|
||||
inputs_data = {}
|
||||
image_shape = inputs_info['image']
|
||||
inputs_data['image'] = np.random.randint(-10, 10, image_shape).astype(np.float32)
|
||||
image_shape = inputs_info['image:0']
|
||||
inputs_data['image:0'] = np.random.randint(-10, 10, image_shape).astype(np.float32)
|
||||
|
||||
if 'boxes' in inputs_info:
|
||||
boxes_shape = inputs_info['boxes']
|
||||
inputs_data['boxes'] = np.random.randint(0, 1.2, boxes_shape).astype(np.float32)
|
||||
if 'box_ind' in inputs_info:
|
||||
box_ind_shape = inputs_info['box_ind']
|
||||
inputs_data['box_ind'] = np.random.randint(0, image_shape[0], box_ind_shape).astype(np.int32)
|
||||
if 'boxes:0' in inputs_info:
|
||||
boxes_shape = inputs_info['boxes:0']
|
||||
inputs_data['boxes:0'] = np.random.randint(0, 1.2, boxes_shape).astype(np.float32)
|
||||
if 'box_ind:0' in inputs_info:
|
||||
box_ind_shape = inputs_info['box_ind:0']
|
||||
inputs_data['box_ind:0'] = np.random.randint(0, image_shape[0], box_ind_shape).astype(np.int32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestDiv(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
# generate x and y
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y'] = np.random.randint(1, 10, y_shape)*np.random.choice([-1,1], y_shape)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y:0'] = np.random.randint(1, 10, y_shape)*np.random.choice([-1,1], y_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_div_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestDivNoNan(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
# generate y in way to have zeros
|
||||
inputs_data['y'] = np.random.randint(-10, 10, y_shape).astype(self.input_type) * \
|
||||
inputs_data['y:0'] = np.random.randint(-10, 10, y_shape).astype(self.input_type) * \
|
||||
np.random.randint(0, 2, y_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestDynamicPartition(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
assert 'partitions' in inputs_info, "Test error: inputs_info must contain `partitions`"
|
||||
data_shape = inputs_info['data']
|
||||
partitions_shape = inputs_info['partitions']
|
||||
assert 'data:0' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
assert 'partitions:0' in inputs_info, "Test error: inputs_info must contain `partitions`"
|
||||
data_shape = inputs_info['data:0']
|
||||
partitions_shape = inputs_info['partitions:0']
|
||||
inputs_data = {}
|
||||
inputs_data['data'] = np.random.randint(-50, 50, data_shape)
|
||||
inputs_data['data:0'] = np.random.randint(-50, 50, data_shape)
|
||||
# segment_ids data must be sorted according to TensorFlow SegmentSum specification
|
||||
inputs_data['partitions'] = np.random.randint(0, 5, partitions_shape)
|
||||
inputs_data['partitions:0'] = np.random.randint(0, 5, partitions_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_dynamic_partition_net(self, data_shape, partitions_shape, num_partitions, data_type):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestEnsureShape(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'tensor' in inputs_info
|
||||
tensor_shape = inputs_info['tensor']
|
||||
assert 'tensor:0' in inputs_info
|
||||
tensor_shape = inputs_info['tensor:0']
|
||||
inputs_data = {}
|
||||
inputs_data['tensor'] = np.random.randint(-10, 10, tensor_shape).astype(self.input_type)
|
||||
inputs_data['tensor:0'] = np.random.randint(-10, 10, tensor_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_ensure_shape_net(self, input_shape, input_type, target_shape):
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
class TestExpandDims(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
# generate elements so that the input tensor may contain repeating elements
|
||||
assert 'input' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
x_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
x_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-10, 10, x_shape).astype(np.float32)
|
||||
inputs_data['input:0'] = np.random.randint(-10, 10, x_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_expand_dims_net(self, input_shape, axis):
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
class TestExtractImagePatches(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
# generate elements so that the input tensor may contain repeating elements
|
||||
assert 'images' in inputs_info, "Test error: inputs_info must contain `images`"
|
||||
images_shape = inputs_info['images']
|
||||
assert 'images:0' in inputs_info, "Test error: inputs_info must contain `images`"
|
||||
images_shape = inputs_info['images:0']
|
||||
inputs_data = {}
|
||||
inputs_data['images'] = np.random.randint(-10, 10, images_shape).astype(np.float32)
|
||||
inputs_data['images:0'] = np.random.randint(-10, 10, images_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_extract_image_patches_net(self, images_shape, ksizes, strides, rates, padding):
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ OPS = {
|
|||
class TestFakeQuantWithMinMaxVars(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
# generate elements so that the input tensor may contain repeating elements
|
||||
assert 'inputs' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
inputs_shape = inputs_info['inputs']
|
||||
assert 'inputs:0' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
inputs_shape = inputs_info['inputs:0']
|
||||
inputs_data = {}
|
||||
inputs_data['inputs'] = np.random.randint(-10, 10, inputs_shape).astype(np.float32)
|
||||
inputs_data['inputs:0'] = np.random.randint(-10, 10, inputs_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_fake_quant_with_min_max_vars_net(self, inputs_shape, min_value, max_value, num_bits, narrow_range,
|
||||
|
|
|
|||
|
|
@ -12,18 +12,18 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
class TestFusedBatchNorm(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
inputs_data = {}
|
||||
x_shape = inputs_info['x']
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape)
|
||||
scale_shape = inputs_info['scale']
|
||||
inputs_data['scale'] = np.random.randint(-10, 10, scale_shape)
|
||||
offset_shape = inputs_info['offset']
|
||||
inputs_data['offset'] = np.random.randint(-10, 10, offset_shape)
|
||||
if 'mean' in inputs_info:
|
||||
mean_shape = inputs_info['mean']
|
||||
inputs_data['mean'] = np.random.randint(-10, 10, mean_shape)
|
||||
if 'variance' in inputs_info:
|
||||
variance_shape = inputs_info['variance']
|
||||
inputs_data['variance'] = np.random.randint(0, 10, variance_shape)
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape)
|
||||
scale_shape = inputs_info['scale:0']
|
||||
inputs_data['scale:0'] = np.random.randint(-10, 10, scale_shape)
|
||||
offset_shape = inputs_info['offset:0']
|
||||
inputs_data['offset:0'] = np.random.randint(-10, 10, offset_shape)
|
||||
if 'mean:0' in inputs_info:
|
||||
mean_shape = inputs_info['mean:0']
|
||||
inputs_data['mean:0'] = np.random.randint(-10, 10, mean_shape)
|
||||
if 'variance:0' in inputs_info:
|
||||
variance_shape = inputs_info['variance:0']
|
||||
inputs_data['variance:0'] = np.random.randint(0, 10, variance_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_fused_batch_norm_net(self, x_shape, epsilon, exponential_avg_factor, data_format, is_training,
|
||||
|
|
|
|||
|
|
@ -11,17 +11,17 @@ rng = np.random.default_rng()
|
|||
|
||||
class TestGather(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'params' in inputs_info
|
||||
assert 'indices' in inputs_info
|
||||
params_shape = inputs_info['params']
|
||||
indices_shape = inputs_info['indices']
|
||||
assert 'params:0' in inputs_info
|
||||
assert 'indices:0' in inputs_info
|
||||
params_shape = inputs_info['params:0']
|
||||
indices_shape = inputs_info['indices:0']
|
||||
inputs_data = {}
|
||||
if self.params_type == str or self.params_type == np.str_:
|
||||
strings_dictionary = ['first', 'second sentence', ' sentence 3 three', '34ferf466 23435* ']
|
||||
inputs_data['params'] = rng.choice(strings_dictionary, params_shape)
|
||||
inputs_data['params:0'] = rng.choice(strings_dictionary, params_shape)
|
||||
else:
|
||||
inputs_data['params'] = rng.integers(-50, 50, params_shape).astype(self.params_type)
|
||||
inputs_data['indices'] = rng.integers(0, self.max_index, indices_shape).astype(self.indices_type)
|
||||
inputs_data['params:0'] = rng.integers(-50, 50, params_shape).astype(self.params_type)
|
||||
inputs_data['indices:0'] = rng.integers(0, self.max_index, indices_shape).astype(self.indices_type)
|
||||
return inputs_data
|
||||
|
||||
def create_gather_net(self, params_shape, params_type, indices_shape, indices_type, axis_value, batch_dims,
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestGatherNd(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'params' in inputs_info
|
||||
assert 'indices' in inputs_info
|
||||
params_shape = inputs_info['params']
|
||||
indices_shape = list(inputs_info['indices'])
|
||||
assert 'params:0' in inputs_info
|
||||
assert 'indices:0' in inputs_info
|
||||
params_shape = inputs_info['params:0']
|
||||
indices_shape = list(inputs_info['indices:0'])
|
||||
inputs_data = {}
|
||||
inputs_data['params'] = np.random.randint(-50, 50, params_shape).astype(self.params_type)
|
||||
inputs_data['params:0'] = np.random.randint(-50, 50, params_shape).astype(self.params_type)
|
||||
# generate indices for each slice and concatenate
|
||||
indices_slices = []
|
||||
for idx in range(self.index_length):
|
||||
|
|
@ -22,7 +22,7 @@ class TestGatherNd(CommonTFLayerTest):
|
|||
self.indices_type)
|
||||
indices_slices.append(indices_slice)
|
||||
indices_slice_rank = len(indices_slices[0].shape)
|
||||
inputs_data['indices'] = np.concatenate(indices_slices, axis=indices_slice_rank - 1)
|
||||
inputs_data['indices:0'] = np.concatenate(indices_slices, axis=indices_slice_rank - 1)
|
||||
return inputs_data
|
||||
|
||||
def create_gather_nd_net(self, params_shape, params_type, indices_shape, indices_type):
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestIfFloat(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'cond' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond']
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'cond:0' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond:0']
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['cond'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x'] = np.random.randint(1, 10, x_shape).astype(np.float32)
|
||||
inputs_data['y'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
inputs_data['cond:0'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x:0'] = np.random.randint(1, 10, x_shape).astype(np.float32)
|
||||
inputs_data['y:0'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_if_net(self, x_shape, y_shape, lower_control_flow):
|
||||
|
|
@ -82,16 +82,16 @@ class TestIfFloat(CommonTFLayerTest):
|
|||
|
||||
class TestIfInt(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'cond' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'ind' in inputs_info, "Test error: inputs_info must contain `ind`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond']
|
||||
ind_shape = inputs_info['ind']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'cond:0' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'ind:0' in inputs_info, "Test error: inputs_info must contain `ind`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond:0']
|
||||
ind_shape = inputs_info['ind:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['cond'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['ind'] = np.random.randint(1, 10, ind_shape).astype(np.int32)
|
||||
inputs_data['y'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
inputs_data['cond:0'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['ind:0'] = np.random.randint(1, 10, ind_shape).astype(np.int32)
|
||||
inputs_data['y:0'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_if_net(self, ind_shape, y_shape, lower_control_flow):
|
||||
|
|
@ -154,16 +154,16 @@ class TestIfInt(CommonTFLayerTest):
|
|||
|
||||
class TestNestedIf(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'z' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
z_shape = inputs_info['z']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'z:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
z_shape = inputs_info['z:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(0, 6, x_shape).astype(np.int32)
|
||||
inputs_data['y'] = np.random.randint(1, 10, y_shape).astype(np.float32)
|
||||
inputs_data['z'] = np.random.randint(-50, 50, z_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = np.random.randint(0, 6, x_shape).astype(np.int32)
|
||||
inputs_data['y:0'] = np.random.randint(1, 10, y_shape).astype(np.float32)
|
||||
inputs_data['z:0'] = np.random.randint(-50, 50, z_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_if_net(self, y_shape, z_shape, lower_control_flow):
|
||||
|
|
@ -234,16 +234,16 @@ class TestNestedIf(CommonTFLayerTest):
|
|||
|
||||
class TestSequantialIfs(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'cond' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond']
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'cond:0' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond:0']
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['cond'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x'] = np.random.randint(1, 10, x_shape).astype(np.float32)
|
||||
inputs_data['y'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
inputs_data['cond:0'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x:0'] = np.random.randint(1, 10, x_shape).astype(np.float32)
|
||||
inputs_data['y:0'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_sequential_ifs_net(self, x_shape, y_shape, lower_control_flow):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestInv(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.choice([-5, -4, -3, -2, -1, 1, 2, 3, 4, 5], x_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = np.random.choice([-5, -4, -3, -2, -1, 1, 2, 3, 4, 5], x_shape).astype(np.float32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestInvertPermutation(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
rng = np.random.default_rng()
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = rng.permutation(x_shape[0]).astype(self.input_type)
|
||||
inputs_data['x:0'] = rng.permutation(x_shape[0]).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_invert_permutation_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ from common.utils.tf_utils import mix_array_with_value
|
|||
|
||||
class TestIsFinite(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
data = np.random.randint(-50, 50, x_shape).astype(np.float32)
|
||||
# mix data with np.inf and np.nan
|
||||
data = mix_array_with_value(data, np.nan)
|
||||
inputs_data['x'] = mix_array_with_value(data, np.inf)
|
||||
inputs_data['x:0'] = mix_array_with_value(data, np.inf)
|
||||
return inputs_data
|
||||
|
||||
def create_is_finite_net(self, x_shape, x_type):
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ from common.utils.tf_utils import mix_array_with_value
|
|||
|
||||
class TestIsInf(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
data = np.random.randint(-50, 50, x_shape).astype(np.float32)
|
||||
inputs_data['x'] = mix_array_with_value(data, np.inf)
|
||||
inputs_data['x:0'] = mix_array_with_value(data, np.inf)
|
||||
return inputs_data
|
||||
|
||||
def create_is_inf_net(self, x_shape, x_type):
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ from common.utils.tf_utils import mix_array_with_value
|
|||
|
||||
class TestIsNan(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
data = np.random.randint(-50, 50, x_shape).astype(np.float32)
|
||||
# mix data with np.inf and np.nan
|
||||
data = mix_array_with_value(data, np.nan)
|
||||
inputs_data['x'] = mix_array_with_value(data, np.inf)
|
||||
inputs_data['x:0'] = mix_array_with_value(data, np.inf)
|
||||
return inputs_data
|
||||
|
||||
def create_is_nan_net(self, x_shape, x_type):
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestListDiff(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-5, 5, x_shape)
|
||||
inputs_data['y'] = np.random.randint(-5, 5, y_shape)
|
||||
inputs_data['x:0'] = np.random.randint(-5, 5, x_shape)
|
||||
inputs_data['y:0'] = np.random.randint(-5, 5, y_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_list_diff_net(self, x_shape, y_shape, out_idx):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestLog1p(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-0.9, 5, x_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = np.random.randint(-0.9, 5, x_shape).astype(np.float32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ rng = np.random.default_rng()
|
|||
|
||||
class TestLookupTableFindOps(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'keys' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
keys_shape = inputs_info['keys']
|
||||
assert 'keys:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
keys_shape = inputs_info['keys:0']
|
||||
inputs_data = {}
|
||||
if np.issubdtype(self.keys_type, np.integer):
|
||||
data = rng.choice(self.all_keys, keys_shape)
|
||||
inputs_data['keys'] = mix_array_with_value(data, self.invalid_key)
|
||||
inputs_data['keys:0'] = mix_array_with_value(data, self.invalid_key)
|
||||
else:
|
||||
raise "Unsupported type {}".format(self.keys_type)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestMatrixDiag(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'diagonal' in inputs_info
|
||||
diagonal_shape = inputs_info['diagonal']
|
||||
assert 'diagonal:0' in inputs_info
|
||||
diagonal_shape = inputs_info['diagonal:0']
|
||||
inputs_data = {}
|
||||
inputs_data['diagonal'] = np.random.randint(-50, 50, diagonal_shape).astype(self.diagonal_type)
|
||||
inputs_data['diagonal:0'] = np.random.randint(-50, 50, diagonal_shape).astype(self.diagonal_type)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestMaxPoolWithArgmax(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-5, 5, input_shape).astype(self.input_type)
|
||||
inputs_data['input:0'] = np.random.randint(-5, 5, input_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_max_pool_with_argmax_net(self, input_shape, ksize, strides, input_type, padding, targmax,
|
||||
|
|
|
|||
|
|
@ -218,19 +218,19 @@ class TestMul(CommonTFLayerTest):
|
|||
class TestComplexMul(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real_1' in inputs_info
|
||||
assert 'param_imag_1' in inputs_info
|
||||
assert 'param_real_2' in inputs_info
|
||||
assert 'param_imag_2' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real_1']
|
||||
param_imag_shape_1 = inputs_info['param_imag_1']
|
||||
param_real_shape_2 = inputs_info['param_real_2']
|
||||
param_imag_shape_2 = inputs_info['param_imag_2']
|
||||
assert 'param_real_1:0' in inputs_info
|
||||
assert 'param_imag_1:0' in inputs_info
|
||||
assert 'param_real_2:0' in inputs_info
|
||||
assert 'param_imag_2:0' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real_1:0']
|
||||
param_imag_shape_1 = inputs_info['param_imag_1:0']
|
||||
param_real_shape_2 = inputs_info['param_real_2:0']
|
||||
param_imag_shape_2 = inputs_info['param_imag_2:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real_1'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag_1'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real_2'] = 4 * rng.random(param_real_shape_2).astype(np.float32) - 2
|
||||
inputs_data['param_imag_2'] = 4 * rng.random(param_imag_shape_2).astype(np.float32) - 2
|
||||
inputs_data['param_real_1:0'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag_1:0'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real_2:0'] = 4 * rng.random(param_real_shape_2).astype(np.float32) - 2
|
||||
inputs_data['param_imag_2:0'] = 4 * rng.random(param_imag_shape_2).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_mul_net(self, input_shape):
|
||||
|
|
|
|||
|
|
@ -9,15 +9,15 @@ from common.utils.tf_utils import mix_array_with_value
|
|||
|
||||
class TestMulNoNan(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x'] = mix_array_with_value(inputs_data['x'], np.inf)
|
||||
inputs_data['x'] = mix_array_with_value(inputs_data['x'], np.nan)
|
||||
inputs_data['y'] = np.random.randint(-10, 10, y_shape).astype(self.input_type) * \
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = mix_array_with_value(inputs_data['x:0'], np.inf)
|
||||
inputs_data['x:0'] = mix_array_with_value(inputs_data['x:0'], np.nan)
|
||||
inputs_data['y:0'] = np.random.randint(-10, 10, y_shape).astype(self.input_type) * \
|
||||
np.random.choice([0.0], y_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import numpy as np
|
|||
|
||||
class TestMultinomial(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_dict, kwargs):
|
||||
inputs_dict["num_samples"] = np.array(kwargs["num_samples"], dtype=np.int32)
|
||||
inputs_dict["probs"] = kwargs["input"]
|
||||
inputs_dict["num_samples:0"] = np.array(kwargs["num_samples:0"], dtype=np.int32)
|
||||
inputs_dict["probs:0"] = kwargs["input:0"]
|
||||
return inputs_dict
|
||||
|
||||
def create_tf_multinomial_net_shape(
|
||||
|
|
@ -138,5 +138,5 @@ class TestMultinomial(CommonTFLayerTest):
|
|||
temp_dir=temp_dir,
|
||||
ir_version=ir_version,
|
||||
use_legacy_frontend=use_legacy_frontend,
|
||||
kwargs_to_prepare_input={"input": input, "num_samples": num_samples},
|
||||
kwargs_to_prepare_input={"input:0": input, "num_samples:0": num_samples},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,10 +14,9 @@ class TestNonMaxSuppression(CommonTFLayerTest):
|
|||
|
||||
# overload inputs generation to suit NMS use case
|
||||
def _prepare_input(self, inputs_dict):
|
||||
channel = ':0' if not self.use_legacy_frontend else ''
|
||||
input_data = {}
|
||||
for input in inputs_dict.keys():
|
||||
input_data[input + channel] = np.random.uniform(low=0, high=1,
|
||||
input_data[input] = np.random.uniform(low=0, high=1,
|
||||
size=inputs_dict[input]).astype(np.float32)
|
||||
return input_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestOnesLike(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['x'] = rng.integers(-10, 10, x_shape).astype(self.x_type)
|
||||
inputs_data['x:0'] = rng.integers(-10, 10, x_shape).astype(self.x_type)
|
||||
return inputs_data
|
||||
|
||||
def create_ones_like_net(self, x_shape, x_type):
|
||||
|
|
|
|||
|
|
@ -48,13 +48,13 @@ class TestPad(CommonTFLayerTest):
|
|||
class TestComplexPad(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape = inputs_info['param_real']
|
||||
param_imag_shape = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape = inputs_info['param_real:0']
|
||||
param_imag_shape = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_pad_complex_net(self, input_shape, pads_values):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class TestParallelDynamicStitch(CommonTFLayerTest):
|
|||
assert len(inputs_info) % 2 == 0, "Number of inputs should be divisible by 2."
|
||||
data_input_cnt = len(inputs_info)//2
|
||||
for i in range(1, data_input_cnt + 1):
|
||||
indices_in_name = "indices{}".format(i)
|
||||
indices_in_name = "indices{}:0".format(i)
|
||||
assert indices_in_name in inputs_info, "Test error: inputs_info must contain `{}`".format(indices_in_name)
|
||||
indices_shape = inputs_info[indices_in_name]
|
||||
num_elements = num_elements + np.prod(indices_shape, dtype=int)
|
||||
|
|
@ -28,8 +28,8 @@ class TestParallelDynamicStitch(CommonTFLayerTest):
|
|||
|
||||
idx = 0
|
||||
for i in range(1, data_input_cnt + 1):
|
||||
data_in_name = "data{}".format(i)
|
||||
indices_in_name = "indices{}".format(i)
|
||||
data_in_name = "data{}:0".format(i)
|
||||
indices_in_name = "indices{}:0".format(i)
|
||||
assert data_in_name in inputs_info, "Test error: inputs_info must contain `{}`".format(data_in_name)
|
||||
data_shape = inputs_info[data_in_name]
|
||||
indices_shape = inputs_info[indices_in_name]
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class TestPlaceholder(CommonTFLayerTest):
|
|||
# Create the graph and model
|
||||
with tf.compat.v1.Session() as sess:
|
||||
x = tf.raw_ops.Placeholder(dtype=dtype, shape=input_shape, name='x')
|
||||
tf.raw_ops.Identity(input=x, name='Identityrfefef')
|
||||
tf.compat.v1.global_variables_initializer()
|
||||
tf_net = sess.graph_def
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ class TestRange(CommonTFLayerTest):
|
|||
def _prepare_input(self, inputs_info):
|
||||
inputs_data = {}
|
||||
if self.negative_delta:
|
||||
inputs_data['start'] = np.random.randint(1, 10, []).astype(self.input_type)
|
||||
inputs_data['limit'] = np.random.randint(-10, 0, []).astype(self.input_type)
|
||||
inputs_data['delta'] = np.random.randint(-5, -1, []).astype(self.input_type)
|
||||
inputs_data['start:0'] = np.random.randint(1, 10, []).astype(self.input_type)
|
||||
inputs_data['limit:0'] = np.random.randint(-10, 0, []).astype(self.input_type)
|
||||
inputs_data['delta:0'] = np.random.randint(-5, -1, []).astype(self.input_type)
|
||||
else:
|
||||
inputs_data['start'] = np.random.randint(1, 10, []).astype(self.input_type)
|
||||
inputs_data['limit'] = np.random.randint(10, 30, []).astype(self.input_type)
|
||||
inputs_data['delta'] = np.random.randint(1, 5, []).astype(self.input_type)
|
||||
inputs_data['start:0'] = np.random.randint(1, 10, []).astype(self.input_type)
|
||||
inputs_data['limit:0'] = np.random.randint(10, 30, []).astype(self.input_type)
|
||||
inputs_data['delta:0'] = np.random.randint(1, 5, []).astype(self.input_type)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestReciprocal(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(1, 30, x_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = np.random.randint(1, 30, x_shape).astype(np.float32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestReduceArithmeticOps(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
x_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
x_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-10, 10, x_shape).astype(np.float32)
|
||||
inputs_data['input:0'] = np.random.randint(-10, 10, x_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_reduce_net(self, shape, axis, operation, keep_dims, ir_version, use_legacy_frontend):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestReshape(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'tensor' in inputs_info
|
||||
tensor_shape = inputs_info['tensor']
|
||||
assert 'tensor:0' in inputs_info
|
||||
tensor_shape = inputs_info['tensor:0']
|
||||
inputs_data = {}
|
||||
inputs_data['tensor'] = np.random.randint(-10, 10, tensor_shape).astype(self.input_type)
|
||||
inputs_data['tensor:0'] = np.random.randint(-10, 10, tensor_shape).astype(self.input_type)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
@ -53,13 +53,13 @@ class TestReshape(CommonTFLayerTest):
|
|||
class TestComplexReshape(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real']
|
||||
param_imag_shape_1 = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real:0']
|
||||
param_imag_shape_1 = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_transpose_net(self, input_shape, target_shape):
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ OPS = {
|
|||
|
||||
class TestResize(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'images' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
images_shape = inputs_info['images']
|
||||
assert 'images:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
images_shape = inputs_info['images:0']
|
||||
inputs_data = {}
|
||||
inputs_data['images'] = np.random.randint(0, 10, images_shape)
|
||||
inputs_data['images:0'] = np.random.randint(0, 10, images_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_resize_net(self, images_shape, images_type, size_value, align_corners, half_pixel_centers,
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestReverseSequence(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
assert 'seq_lengths' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
seq_lengths_shape = inputs_info['seq_lengths']
|
||||
assert 'input:0' in inputs_info
|
||||
assert 'seq_lengths:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
seq_lengths_shape = inputs_info['seq_lengths:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-50, 50, input_shape).astype(self.input_type)
|
||||
inputs_data['seq_lengths'] = np.random.randint(0, self.max_seq_length + 1, seq_lengths_shape).astype(
|
||||
inputs_data['input:0'] = np.random.randint(-50, 50, input_shape).astype(self.input_type)
|
||||
inputs_data['seq_lengths:0'] = np.random.randint(0, self.max_seq_length + 1, seq_lengths_shape).astype(
|
||||
self.seq_lengths_type)
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSegmentSum(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
assert 'segment_ids' in inputs_info, "Test error: inputs_info must contain `segment_ids`"
|
||||
data_shape = inputs_info['data']
|
||||
segment_ids_shape = inputs_info['segment_ids']
|
||||
assert 'data:0' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
assert 'segment_ids:0' in inputs_info, "Test error: inputs_info must contain `segment_ids`"
|
||||
data_shape = inputs_info['data:0']
|
||||
segment_ids_shape = inputs_info['segment_ids:0']
|
||||
inputs_data = {}
|
||||
inputs_data['data'] = np.random.randint(-50, 50, data_shape)
|
||||
inputs_data['data:0'] = np.random.randint(-50, 50, data_shape)
|
||||
# segment_ids data must be sorted according to TensorFlow SegmentSum specification
|
||||
inputs_data['segment_ids'] = np.sort(np.random.randint(0, 20, segment_ids_shape))
|
||||
inputs_data['segment_ids:0'] = np.sort(np.random.randint(0, 20, segment_ids_shape))
|
||||
return inputs_data
|
||||
|
||||
def create_segment_sum_net(self, data_shape, segment_ids_shape, data_type, segment_ids_type):
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSelect(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'cond' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond']
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'cond:0' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond:0']
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['cond'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x'] = np.random.randint(-100, 100, x_shape).astype(np.float32)
|
||||
inputs_data['y'] = np.random.randint(-100, 100, y_shape).astype(np.float32)
|
||||
inputs_data['cond:0'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x:0'] = np.random.randint(-100, 100, x_shape).astype(np.float32)
|
||||
inputs_data['y:0'] = np.random.randint(-100, 100, y_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_select_net(self, cond_shape, x_shape, y_shape):
|
||||
|
|
|
|||
|
|
@ -9,16 +9,16 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSelectV2(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'cond' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond']
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'cond:0' in inputs_info, "Test error: inputs_info must contain `cond`"
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
cond_shape = inputs_info['cond:0']
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['cond'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x'] = np.random.randint(-100, 100, x_shape).astype(np.float32)
|
||||
inputs_data['y'] = np.random.randint(-100, 100, y_shape).astype(np.float32)
|
||||
inputs_data['cond:0'] = np.random.randint(0, 2, cond_shape).astype(bool)
|
||||
inputs_data['x:0'] = np.random.randint(-100, 100, x_shape).astype(np.float32)
|
||||
inputs_data['y:0'] = np.random.randint(-100, 100, y_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_select_v2_net(self, cond_shape, x_shape, y_shape):
|
||||
|
|
|
|||
|
|
@ -9,17 +9,17 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestShape(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
if self.input_type == str or self.input_type == np.str_:
|
||||
strings_dictionary = ['first', 'second sentence', ' sentence 3 three', '34ferf466 23435* ', '汉语句子',
|
||||
'Oferta polska',
|
||||
'предложение по-русски']
|
||||
inputs_data['input'] = rng.choice(strings_dictionary, input_shape)
|
||||
inputs_data['input:0'] = rng.choice(strings_dictionary, input_shape)
|
||||
else:
|
||||
inputs_data['input'] = rng.integers(-10, 10, size=input_shape).astype(self.input_type)
|
||||
inputs_data['input:0'] = rng.integers(-10, 10, size=input_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_shape_net(self, input_shape, input_type, out_type):
|
||||
|
|
@ -62,13 +62,13 @@ class TestShape(CommonTFLayerTest):
|
|||
class TestComplexShape(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real']
|
||||
param_imag_shape_1 = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real:0']
|
||||
param_imag_shape_1 = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_shape_net(self, input_shape):
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSize(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
input_type = self.input_type
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-50, 50, input_shape).astype(input_type)
|
||||
inputs_data['input:0'] = np.random.randint(-50, 50, input_shape).astype(input_type)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSoftmax(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'logits' in inputs_info
|
||||
logits_shape = inputs_info['logits']
|
||||
assert 'logits:0' in inputs_info
|
||||
logits_shape = inputs_info['logits:0']
|
||||
inputs_data = {}
|
||||
inputs_data['logits'] = np.random.randint(-5, 5, logits_shape).astype(np.float32)
|
||||
inputs_data['logits:0'] = np.random.randint(-5, 5, logits_shape).astype(np.float32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSqueeze(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-50, 50, input_shape).astype(self.input_type)
|
||||
inputs_data['input:0'] = np.random.randint(-50, 50, input_shape).astype(self.input_type)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
@ -114,13 +114,13 @@ class TestSqueeze(CommonTFLayerTest):
|
|||
class TestComplexSqueeze(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real']
|
||||
param_imag_shape_1 = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real:0']
|
||||
param_imag_shape_1 = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_squeeze_net(self, input_shape, axis):
|
||||
|
|
|
|||
|
|
@ -123,13 +123,13 @@ class TestComplexStridedSlice(CommonTFLayerTest):
|
|||
def _prepare_input(self, inputs_info):
|
||||
import numpy as np
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real']
|
||||
param_imag_shape_1 = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real:0']
|
||||
param_imag_shape_1 = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_strided_slice_net(self, input_shape, begin_value, end_value, strides_value, begin_mask, end_mask,
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestSwitchMerge(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['x'] = rng.integers(-10, 10, x_shape).astype(self.x_type)
|
||||
inputs_data['x:0'] = rng.integers(-10, 10, x_shape).astype(self.x_type)
|
||||
return inputs_data
|
||||
|
||||
def merge_eliminating_several_cond_flows_net(self, x_shape, x_type, cond_value):
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ def create_tensor_array(data_shape, data_type):
|
|||
|
||||
class TestTensorArraySizeV3(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info
|
||||
assert 'indices' in inputs_info
|
||||
data_shape = inputs_info['data']
|
||||
assert 'data:0' in inputs_info
|
||||
assert 'indices:0' in inputs_info
|
||||
data_shape = inputs_info['data:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['data'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['indices'] = rng.permutation(self.size).astype(np.int32)
|
||||
inputs_data['data:0'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['indices:0'] = rng.permutation(self.size).astype(np.int32)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_array_size_v3(self, data_shape, data_type):
|
||||
|
|
@ -60,14 +60,14 @@ class TestTensorArraySizeV3(CommonTFLayerTest):
|
|||
|
||||
class TestTensorArrayReadV3(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info
|
||||
assert 'indices' in inputs_info
|
||||
data_shape = inputs_info['data']
|
||||
assert 'data:0' in inputs_info
|
||||
assert 'indices:0' in inputs_info
|
||||
data_shape = inputs_info['data:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['data'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['index_to_read'] = rng.integers(0, data_shape[0], []).astype(np.int32)
|
||||
inputs_data['indices'] = rng.permutation(self.size).astype(np.int32)
|
||||
inputs_data['data:0'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['index_to_read:0'] = rng.integers(0, data_shape[0], []).astype(np.int32)
|
||||
inputs_data['indices:0'] = rng.permutation(self.size).astype(np.int32)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_array_read_v3(self, data_shape, data_type):
|
||||
|
|
@ -104,17 +104,17 @@ class TestTensorArrayReadV3(CommonTFLayerTest):
|
|||
|
||||
class TestTensorArrayWriteGatherV3(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info
|
||||
assert 'indices' in inputs_info
|
||||
assert 'value_to_write' in inputs_info
|
||||
data_shape = inputs_info['data']
|
||||
value_shape = inputs_info['value_to_write']
|
||||
assert 'data:0' in inputs_info
|
||||
assert 'indices:0' in inputs_info
|
||||
assert 'value_to_write:0' in inputs_info
|
||||
data_shape = inputs_info['data:0']
|
||||
value_shape = inputs_info['value_to_write:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['data'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['value_to_write'] = rng.integers(-10, 10, value_shape).astype(self.data_type)
|
||||
inputs_data['data:0'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['value_to_write:0'] = rng.integers(-10, 10, value_shape).astype(self.data_type)
|
||||
indices_data = rng.permutation(self.size).astype(np.int32)
|
||||
inputs_data['indices'] = np.delete(indices_data, np.where(indices_data == self.index_to_write))
|
||||
inputs_data['indices:0'] = np.delete(indices_data, np.where(indices_data == self.index_to_write))
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_array_write_v3(self, size, data_shape, data_type, index_to_write, indices_to_gather,
|
||||
|
|
@ -170,13 +170,13 @@ class TestTensorArrayWriteGatherV3(CommonTFLayerTest):
|
|||
|
||||
class TestTensorArrayConcatV3(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info
|
||||
assert 'indices' in inputs_info
|
||||
data_shape = inputs_info['data']
|
||||
assert 'data:0' in inputs_info
|
||||
assert 'indices:0' in inputs_info
|
||||
data_shape = inputs_info['data:0']
|
||||
inputs_data = {}
|
||||
rng = np.random.default_rng()
|
||||
inputs_data['data'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['indices'] = rng.permutation(self.size).astype(np.int32)
|
||||
inputs_data['data:0'] = rng.integers(-10, 10, data_shape).astype(self.data_type)
|
||||
inputs_data['indices:0'] = rng.permutation(self.size).astype(np.int32)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_array_concat_v3(self, data_shape, data_type):
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestTensorListConcatV2(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_list_resize(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestTensorListLength(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_list_length(self, input_shape, input_type):
|
||||
|
|
@ -51,7 +51,7 @@ class TestTensorListLength(CommonTFLayerTest):
|
|||
class TestTensorListLengthEmptyList(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
inputs_data = {}
|
||||
inputs_data['tensor_list_size'] = np.array([self.tensor_list_size], dtype=np.int32)
|
||||
inputs_data['tensor_list_size:0'] = np.array([self.tensor_list_size], dtype=np.int32)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_list_length_empty_list(self, tensor_list_size, element_shape):
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestTensorListResize(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_tensor_list_resize(self, input_shape, input_type, new_size):
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestTile(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'input' in inputs_info
|
||||
assert 'multiples' in inputs_info
|
||||
input_shape = inputs_info['input']
|
||||
multiples_shape = inputs_info['multiples']
|
||||
assert 'input:0' in inputs_info
|
||||
assert 'multiples:0' in inputs_info
|
||||
input_shape = inputs_info['input:0']
|
||||
multiples_shape = inputs_info['multiples:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-50, 50, input_shape).astype(np.float32)
|
||||
inputs_data['multiples'] = np.random.randint(1, 4, multiples_shape).astype(np.int32)
|
||||
inputs_data['input:0'] = np.random.randint(-50, 50, input_shape).astype(np.float32)
|
||||
inputs_data['multiples:0'] = np.random.randint(1, 4, multiples_shape).astype(np.int32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestToBool(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(np.float32)
|
||||
|
||||
return inputs_data
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
class TestTopKV2(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
# generate elements so that the input tensor may contain repeating elements
|
||||
assert 'input' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
x_shape = inputs_info['input']
|
||||
assert 'input:0' in inputs_info, "Test error: inputs_info must contain `input`"
|
||||
x_shape = inputs_info['input:0']
|
||||
inputs_data = {}
|
||||
inputs_data['input'] = np.random.randint(-10, 10, x_shape)
|
||||
inputs_data['input:0'] = np.random.randint(-10, 10, x_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_topk_v2_net(self, input_shape, input_type, k, sorted, is_first_output, is_second_output):
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ class TestComplexTranspose(CommonTFLayerTest):
|
|||
def _prepare_input(self, inputs_info):
|
||||
import numpy as np
|
||||
rng = np.random.default_rng()
|
||||
assert 'param_real' in inputs_info
|
||||
assert 'param_imag' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real']
|
||||
param_imag_shape_1 = inputs_info['param_imag']
|
||||
assert 'param_real:0' in inputs_info
|
||||
assert 'param_imag:0' in inputs_info
|
||||
param_real_shape_1 = inputs_info['param_real:0']
|
||||
param_imag_shape_1 = inputs_info['param_imag:0']
|
||||
inputs_data = {}
|
||||
inputs_data['param_real'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_real:0'] = 4 * rng.random(param_real_shape_1).astype(np.float32) - 2
|
||||
inputs_data['param_imag:0'] = 4 * rng.random(param_imag_shape_1).astype(np.float32) - 2
|
||||
return inputs_data
|
||||
|
||||
def create_complex_transpose_net(self, input_shape, perm_value):
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestTruncateDiv(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
# generate x and y to ensure truncation
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y'] = np.random.randint(1, 10, y_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y:0'] = np.random.randint(1, 10, y_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_truncate_div_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestTruncateMod(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
# generate x and y to ensure truncation
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y'] = np.random.randint(1, 10, y_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['y:0'] = np.random.randint(1, 10, y_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_truncate_mod_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestUnique(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_unique_net(self, x_shape, data_type, out_idx):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestUnique(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_unique_net(self, x_shape, data_type, out_idx):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestUnpack(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
x_shape = inputs_info['x:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
inputs_data['x:0'] = np.random.randint(-10, 10, x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_unpack_net(self, input_shape, num, axis, input_type):
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestUnravelIndex(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'indices' in inputs_info
|
||||
indices_shape = inputs_info['indices']
|
||||
assert 'indices:0' in inputs_info
|
||||
indices_shape = inputs_info['indices:0']
|
||||
inputs_data = {}
|
||||
inputs_data['indices'] = np.random.randint(0, self.num_elements, indices_shape).astype(self.input_type)
|
||||
inputs_data['indices:0'] = np.random.randint(0, self.num_elements, indices_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_unravel_index_net(self, input_shape, input_type, dims_value):
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestUnsortedSegmentSum(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'data' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
assert 'segment_ids' in inputs_info, "Test error: inputs_info must contain `segment_ids`"
|
||||
data_shape = inputs_info['data']
|
||||
segment_ids_shape = inputs_info['segment_ids']
|
||||
assert 'data:0' in inputs_info, "Test error: inputs_info must contain `data`"
|
||||
assert 'segment_ids:0' in inputs_info, "Test error: inputs_info must contain `segment_ids`"
|
||||
data_shape = inputs_info['data:0']
|
||||
segment_ids_shape = inputs_info['segment_ids:0']
|
||||
inputs_data = {}
|
||||
inputs_data['data'] = np.random.randint(-50, 50, data_shape).astype(self.data_type)
|
||||
inputs_data['data:0'] = np.random.randint(-50, 50, data_shape).astype(self.data_type)
|
||||
# segment_ids can have negative values
|
||||
inputs_data['segment_ids'] = np.random.randint(-self.num_segments_val, self.num_segments_val, segment_ids_shape)
|
||||
inputs_data['segment_ids:0'] = np.random.randint(-self.num_segments_val, self.num_segments_val, segment_ids_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_unsorted_segment_sum_net(self, data_shape, segment_ids_shape, num_segments_val, data_type,
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestWhere(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'condition' in inputs_info, "Test error: inputs_info must contain `condition`"
|
||||
condition_shape = inputs_info['condition']
|
||||
assert 'condition:0' in inputs_info, "Test error: inputs_info must contain `condition`"
|
||||
condition_shape = inputs_info['condition:0']
|
||||
inputs_data = {}
|
||||
inputs_data['condition'] = np.random.randint(-2, 2, condition_shape)
|
||||
inputs_data['condition:0'] = np.random.randint(-2, 2, condition_shape)
|
||||
return inputs_data
|
||||
|
||||
def create_where_net(self, condition_shape, condition_type):
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestWhile(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(1, 10, x_shape).astype(np.int32)
|
||||
inputs_data['y'] = np.random.randint(-50, 50, y_shape).astype(np.int32)
|
||||
inputs_data['x:0'] = np.random.randint(1, 10, x_shape).astype(np.int32)
|
||||
inputs_data['y:0'] = np.random.randint(-50, 50, y_shape).astype(np.int32)
|
||||
return inputs_data
|
||||
|
||||
def create_while_net(self, y_shape, data_type, lower_control_flow):
|
||||
|
|
@ -68,13 +68,13 @@ class TestWhile(CommonTFLayerTest):
|
|||
|
||||
class TestWhileShapeVariant(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(1, 10, x_shape).astype(np.int32)
|
||||
inputs_data['y'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
inputs_data['x:0'] = np.random.randint(1, 10, x_shape).astype(np.int32)
|
||||
inputs_data['y:0'] = np.random.randint(-50, 50, y_shape).astype(np.float32)
|
||||
return inputs_data
|
||||
|
||||
def create_while_net(self, y_shape, lower_control_flow):
|
||||
|
|
@ -128,13 +128,13 @@ class TestWhileShapeVariant(CommonTFLayerTest):
|
|||
|
||||
class TestWhileWithNestedIf(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info, "Test error: inputs_info must contain `x`"
|
||||
assert 'y:0' in inputs_info, "Test error: inputs_info must contain `y`"
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
inputs_data['x'] = np.random.randint(1, 10, x_shape).astype(np.int32)
|
||||
inputs_data['y'] = np.random.randint(-50, 50, y_shape).astype(np.int32)
|
||||
inputs_data['x:0'] = np.random.randint(1, 10, x_shape).astype(np.int32)
|
||||
inputs_data['y:0'] = np.random.randint(-50, 50, y_shape).astype(np.int32)
|
||||
return inputs_data
|
||||
|
||||
def create_while_with_nested_if_net(self, y_shape, data_type, lower_control_flow):
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestXlog1py(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
# x = [-3 ,3] y = [1, 2]
|
||||
# generate x in way to have zeros
|
||||
inputs_data['x'] = (6 * np.random.random(size=x_shape).astype(np.float32) - 3) * \
|
||||
inputs_data['x:0'] = (6 * np.random.random(size=x_shape).astype(np.float32) - 3) * \
|
||||
np.random.randint(2, size=x_shape).astype(np.float32)
|
||||
inputs_data['y'] = np.random.random(size=y_shape).astype(np.float32) + 1
|
||||
inputs_data['y:0'] = np.random.random(size=y_shape).astype(np.float32) + 1
|
||||
return inputs_data
|
||||
|
||||
def create_xlog1py_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -11,16 +11,16 @@ from common.tf_layer_test_class import CommonTFLayerTest
|
|||
|
||||
class TestXlogy(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'x' in inputs_info
|
||||
assert 'y' in inputs_info
|
||||
x_shape = inputs_info['x']
|
||||
y_shape = inputs_info['y']
|
||||
assert 'x:0' in inputs_info
|
||||
assert 'y:0' in inputs_info
|
||||
x_shape = inputs_info['x:0']
|
||||
y_shape = inputs_info['y:0']
|
||||
inputs_data = {}
|
||||
# x = [-3 ,3] y = [1, 2]
|
||||
# generate x in way to have zeros
|
||||
inputs_data['x'] = (6 * np.random.random(size=x_shape).astype(np.float32) - 3) * \
|
||||
inputs_data['x:0'] = (6 * np.random.random(size=x_shape).astype(np.float32) - 3) * \
|
||||
np.random.randint(2, size=x_shape).astype(np.float32)
|
||||
inputs_data['y'] = np.random.random(size=y_shape).astype(np.float32) + 1
|
||||
inputs_data['y:0'] = np.random.random(size=y_shape).astype(np.float32) + 1
|
||||
return inputs_data
|
||||
|
||||
def create_xlogy_net(self, input_shape, input_type):
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ def fe_input_user_data_repack(
|
|||
if freeze_placeholder:
|
||||
# in case freezing via freeze_placeholder_with_value option, _input_shapes can miss some frozen places
|
||||
for input_name in freeze_placeholder:
|
||||
if input_name in _input_names:
|
||||
if input_name in _input_names or input_name + ":0" in _input_names:
|
||||
continue
|
||||
node = decode_name_with_port(
|
||||
input_model, input_name, framework, IOType.Input
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ def moc_pipeline(argv: argparse.Namespace, moc_front_end: FrontEnd):
|
|||
node = None
|
||||
# look for the certain place in user_shapes
|
||||
for node_cur in user_shapes:
|
||||
if node_cur.get('input_name') == name:
|
||||
if node_cur.get('input_name') == name or node_cur.get('input_name') == name + ":0":
|
||||
node = node_cur
|
||||
break
|
||||
if node is None:
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
),
|
||||
(
|
||||
"in2{f32}->[0.0 0.0 0.0 0.0]",
|
||||
{"in1": np.array([[1.0, 2.0], [3.0, 4.0]])},
|
||||
{"in1:0": np.array([[1.0, 2.0], [3.0, 4.0]])},
|
||||
np.array([[1.0, 2.0], [3.0, 4.0]]),
|
||||
np.float32,
|
||||
),
|
||||
(
|
||||
"in2->[1.0 15.0 15.5 1.0]",
|
||||
{"in1": np.array([[2.0, 4.0], [12.0, 8.0]])},
|
||||
{"in1:0": np.array([[2.0, 4.0], [12.0, 8.0]])},
|
||||
np.array([[3.0, 19.0], [27.5, 9.0]]),
|
||||
np.float32,
|
||||
),
|
||||
|
|
@ -82,7 +82,7 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
),
|
||||
(
|
||||
"in2->[2 5 6 7 3 2]",
|
||||
{"in1": np.array([[2, 4, 1], [1, 2, 8]])},
|
||||
{"in1:0": np.array([[2, 4, 1], [1, 2, 8]])},
|
||||
np.array([[4, 20, 6], [7, 6, 16]]),
|
||||
np.int32,
|
||||
),
|
||||
|
|
@ -102,13 +102,13 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
),
|
||||
(
|
||||
"in2[2,3]->[True,True,False,True,True,False]",
|
||||
{"in1": np.array([[False, True, True], [False, True, True]], dtype=bool)},
|
||||
{"in1:0": np.array([[False, True, True], [False, True, True]], dtype=bool)},
|
||||
np.array([[False, True, False], [False, True, False]], dtype=bool),
|
||||
bool,
|
||||
),
|
||||
(
|
||||
"in2[]->True",
|
||||
{"in1": np.array([[False, True, True], [False, True, True]], dtype=bool)},
|
||||
{"in1:0": np.array([[False, True, True], [False, True, True]], dtype=bool)},
|
||||
np.array([[False, True, True], [False, True, True]], dtype=bool),
|
||||
bool,
|
||||
),
|
||||
|
|
@ -129,21 +129,21 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
),
|
||||
(
|
||||
None,
|
||||
{"in1": np.array([2.0, 4.0, 6.0], dtype=np.float32),
|
||||
"in2": np.array([1.0, 3.0, 5.0], dtype=np.float32)},
|
||||
{"in1:0": np.array([2.0, 4.0, 6.0], dtype=np.float32),
|
||||
"in2:0": np.array([1.0, 3.0, 5.0], dtype=np.float32)},
|
||||
np.array([2, 4, 6], dtype=np.float32),
|
||||
np.float32,
|
||||
"cond->False",
|
||||
"cond:0->False",
|
||||
None,
|
||||
True # fill a bug to investigate why compilation of this model is hang on
|
||||
),
|
||||
# case: input_shape + freeze_placeholder_with_value
|
||||
(
|
||||
None,
|
||||
{"in2": np.array([1.0, 3.0, 5.0], dtype=np.float32)},
|
||||
{"in2:0": np.array([1.0, 3.0, 5.0], dtype=np.float32)},
|
||||
np.array([2, 4, 6], dtype=np.float32),
|
||||
np.float32,
|
||||
"in1->[2.0 4.0 6.0],cond->True",
|
||||
"in1:0->[2.0 4.0 6.0],cond:0->True",
|
||||
"[3]",
|
||||
False
|
||||
),
|
||||
|
|
@ -157,15 +157,15 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
@generate(
|
||||
*[
|
||||
(
|
||||
"add:0[3],z",
|
||||
{"add:0": np.array([4, 5, 6], dtype=np.float32), "z": np.array([1, 2, 3], dtype=np.float32)},
|
||||
"add:0[3],z:0",
|
||||
{"add:0": np.array([4, 5, 6], dtype=np.float32), "z:0": np.array([1, 2, 3], dtype=np.float32)},
|
||||
np.array([4, 10, 18], dtype=np.float32),
|
||||
np.float32,
|
||||
None
|
||||
),
|
||||
(
|
||||
"add:0{i32}[3],z{i32}",
|
||||
{"add:0": np.array([4, 5, 6], dtype=np.int32), "z": np.array([1, 2, 3], dtype=np.int32)},
|
||||
"add:0{i32}[3],z:0{i32}",
|
||||
{"add:0": np.array([4, 5, 6], dtype=np.int32), "z:0": np.array([1, 2, 3], dtype=np.int32)},
|
||||
np.array([4, 10, 18], dtype=np.int32),
|
||||
np.int32,
|
||||
None
|
||||
|
|
@ -287,12 +287,12 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
@generate(
|
||||
*[
|
||||
(
|
||||
{"x": np.array([1, 2], dtype=np.int32), "y": np.array([4], dtype=np.int32)},
|
||||
{"x:0": np.array([1, 2], dtype=np.int32), "y:0": np.array([4], dtype=np.int32)},
|
||||
np.array([-3, -2], dtype=np.int32),
|
||||
np.int32,
|
||||
),
|
||||
(
|
||||
{"x": np.array([20, 25], dtype=np.int32), "y": np.array([10], dtype=np.int32)},
|
||||
{"x:0": np.array([20, 25], dtype=np.int32), "y:0": np.array([10], dtype=np.int32)},
|
||||
np.array([30, 35], dtype=np.int32),
|
||||
np.int32,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ class TestBasicConversion(unittest.TestCase):
|
|||
ckpt_file.write(bytes(checkpoint_byte_stream))
|
||||
ckpt_file.close()
|
||||
basic_check(input_model="model_with_variable_v1.pbtxt", argv_input=None,
|
||||
input_data={'input1': np.array([[1]], dtype=np.int64)},
|
||||
input_data={'input1:0': np.array([[1]], dtype=np.int64)},
|
||||
expected_dtype=np.int64, expected_value=np.array([[14108583]], dtype=np.int64),
|
||||
use_new_frontend=True, use_legacy_frontend=False, input_checkpoint=ckpt_file.name)
|
||||
|
|
|
|||
|
|
@ -48,16 +48,16 @@ class TestConversionWithBatchAndLayout(unittest.TestCase):
|
|||
@generate(
|
||||
*[
|
||||
(
|
||||
"model_fp32.pbtxt", 5, "in1(cn),in2(cn)",
|
||||
{"in1": PartialShape([2, 5]), "in2": PartialShape([2, 5])},
|
||||
"model_fp32.pbtxt", 5, "in1:0(cn),in2:0(cn)",
|
||||
{"in1:0": PartialShape([2, 5]), "in2:0": PartialShape([2, 5])},
|
||||
),
|
||||
(
|
||||
"model_fp32.pbtxt", 9, "in1(nc),in2(nc)",
|
||||
{"in1": PartialShape([9, 2]), "in2": PartialShape([9, 2])},
|
||||
"model_fp32.pbtxt", 9, "in1:0(nc),in2:0(nc)",
|
||||
{"in1:0": PartialShape([9, 2]), "in2:0": PartialShape([9, 2])},
|
||||
),
|
||||
(
|
||||
"model_fp32.pbtxt", 7, "in1(?c),in2(?c)",
|
||||
{"in1": PartialShape([2, 2]), "in2": PartialShape([2, 2])},
|
||||
"model_fp32.pbtxt", 7, "in1:0(?c),in2:0(?c)",
|
||||
{"in1:0": PartialShape([2, 2]), "in2:0": PartialShape([2, 2])},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
@ -67,14 +67,14 @@ class TestConversionWithBatchAndLayout(unittest.TestCase):
|
|||
@generate(
|
||||
*[
|
||||
(
|
||||
"model_with_convolution_dynamic_rank.pbtxt", 7, "x(n???),kernel(????)",
|
||||
{"x": PartialShape([7, Dimension.dynamic(), Dimension.dynamic(), 3]),
|
||||
"kernel": PartialShape([2, 2, 3, 1])},
|
||||
"model_with_convolution_dynamic_rank.pbtxt", 7, "x:0(n???),kernel:0(????)",
|
||||
{"x:0": PartialShape([7, Dimension.dynamic(), Dimension.dynamic(), 3]),
|
||||
"kernel:0": PartialShape([2, 2, 3, 1])},
|
||||
),
|
||||
(
|
||||
"model_with_convolution_dynamic_rank.pbtxt", 3, "x(???n),kernel(??n?)",
|
||||
{"x": PartialShape([Dimension.dynamic(), Dimension.dynamic(), Dimension.dynamic(), 3]),
|
||||
"kernel": PartialShape([2, 2, 3, 1])},
|
||||
"model_with_convolution_dynamic_rank.pbtxt", 3, "x:0(???n),kernel:0(??n?)",
|
||||
{"x:0": PartialShape([Dimension.dynamic(), Dimension.dynamic(), Dimension.dynamic(), 3]),
|
||||
"kernel:0": PartialShape([2, 2, 3, 1])},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
# None
|
||||
# ),
|
||||
(
|
||||
"x",
|
||||
{"x": np.array([[-3, 20, 1]], dtype=np.int32)},
|
||||
"x:0",
|
||||
{"x:0": np.array([[-3, 20, 1]], dtype=np.int32)},
|
||||
np.array([[-2, 22, 4], [1, 25, 7]], dtype=np.int32),
|
||||
np.int32,
|
||||
None
|
||||
|
|
@ -125,12 +125,12 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
@generate(
|
||||
*[
|
||||
(
|
||||
{"x": np.array([1, 2], dtype=np.int32), "y": np.array([4], dtype=np.int32)},
|
||||
{"x:0": np.array([1, 2], dtype=np.int32), "y:0": np.array([4], dtype=np.int32)},
|
||||
np.array([-3, -2], dtype=np.int32),
|
||||
np.int32,
|
||||
),
|
||||
(
|
||||
{"x": np.array([20, 25], dtype=np.int32), "y": np.array([10], dtype=np.int32)},
|
||||
{"x:0": np.array([20, 25], dtype=np.int32), "y:0": np.array([10], dtype=np.int32)},
|
||||
np.array([30, 35], dtype=np.int32),
|
||||
np.int32,
|
||||
)
|
||||
|
|
@ -144,15 +144,15 @@ class TestMoFreezePlaceholderTFFE(unittest.TestCase):
|
|||
# new frontend
|
||||
(
|
||||
"model_add_with_undefined_constant.pbtxt",
|
||||
("x", [2, 3]),
|
||||
{"x": np.array([[12, 13, 10], [11, 14, 16]], dtype=np.float32)},
|
||||
("x:0", [2, 3]),
|
||||
{"x:0": np.array([[12, 13, 10], [11, 14, 16]], dtype=np.float32)},
|
||||
np.array([[12, 13, 10], [11, 14, 16]], dtype=np.float32),
|
||||
np.float32
|
||||
),
|
||||
(
|
||||
"model_mul_with_undefined_constant.pbtxt",
|
||||
("x", [2]),
|
||||
{"x": np.array([11, -12], dtype=np.int32)},
|
||||
("x:0", [2]),
|
||||
{"x:0": np.array([11, -12], dtype=np.int32)},
|
||||
np.array([0, 0], dtype=np.int32),
|
||||
np.int32
|
||||
),
|
||||
|
|
|
|||
|
|
@ -37,5 +37,5 @@ class TestBasicConversion(unittest.TestCase):
|
|||
ckpt_file.write(bytes(checkpoint_byte_stream))
|
||||
ckpt_file.close()
|
||||
basic_check(input_model=["model_with_variable_v1.pbtxt", ckpt_file.name], argv_input=None,
|
||||
input_data={'input1': np.array([[1]], dtype=np.int64)},
|
||||
input_data={'input1:0': np.array([[1]], dtype=np.int64)},
|
||||
expected_dtype=np.int64, expected_value=np.array([[14108583]], dtype=np.int64))
|
||||
|
|
|
|||
Loading…
Reference in New Issue