Unverified Commit f6fe6aca authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Restore constant folding for DynReshape until users are converted to … (#4164)

* Restore constant folding for DynReshape until users are converted to v1 Reshape

* Disbale test when no serialization
Co-authored-by: 's avatarbaojun <32073718+baojun-nervana@users.noreply.github.com>
parent ef553de3
......@@ -17,6 +17,7 @@
#include <numeric>
#include "constant_folding.hpp"
#include "ngraph/op/experimental/dyn_reshape.hpp"
#include "ngraph/op/reshape.hpp"
#include "ngraph/runtime/reference/reshape.hpp"
#include "ngraph/type/element_type.hpp"
......@@ -24,9 +25,9 @@
using namespace std;
using namespace ngraph;
template <class T>
template <typename T, typename R>
shared_ptr<op::Constant> fold_constant_dyn_reshape(shared_ptr<op::Constant> constant_data,
shared_ptr<op::v1::Reshape> dyn_reshape)
R dyn_reshape)
{
const Shape& out_shape = dyn_reshape->get_shape();
runtime::AlignedBuffer buffer(shape_size(out_shape) * sizeof(T));
......@@ -44,18 +45,102 @@ shared_ptr<op::Constant> fold_constant_dyn_reshape(shared_ptr<op::Constant> cons
return make_shared<op::Constant>(dyn_reshape->get_element_type(), out_shape, data_ptr);
}
template <typename R>
std::shared_ptr<Node> do_fold(R dyn_reshape_match, shared_ptr<op::Constant> constant_data_match)
{
std::shared_ptr<Node> replacement;
auto type = dyn_reshape_match->get_element_type();
switch (type)
{
case element::Type_t::undefined:
NGRAPH_CHECK(false,
"Encountered 'undefined' element type in constant_dyn_reshape_callback");
break;
case element::Type_t::dynamic:
NGRAPH_CHECK(false, "Encountered 'dynamic' element type in constant_dyn_reshape_callback");
break;
case element::Type_t::u1:
NGRAPH_CHECK(false, "Encountered 'u1' element type in constant_dyn_reshape_callback");
break;
case element::Type_t::boolean:
replacement = fold_constant_dyn_reshape<char>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::bf16:
replacement = fold_constant_dyn_reshape<bfloat16>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::f16:
replacement = fold_constant_dyn_reshape<float16>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::f32:
replacement = fold_constant_dyn_reshape<float>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::f64:
replacement = fold_constant_dyn_reshape<double>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i8:
replacement = fold_constant_dyn_reshape<int8_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i16:
replacement = fold_constant_dyn_reshape<int16_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i32:
replacement = fold_constant_dyn_reshape<int32_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i64:
replacement = fold_constant_dyn_reshape<int64_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u8:
replacement = fold_constant_dyn_reshape<uint8_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u16:
replacement = fold_constant_dyn_reshape<uint16_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u32:
replacement = fold_constant_dyn_reshape<uint32_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u64:
replacement = fold_constant_dyn_reshape<uint64_t>(constant_data_match, dyn_reshape_match);
break;
}
return replacement;
}
void pass::ConstantFolding::construct_constant_dyn_reshape()
{
auto constant_data_label = make_shared<pattern::op::Label>(
element::f32, Shape{2, 4}, pattern::has_class<op::Constant>());
auto constant_shape_label =
make_shared<pattern::op::Label>(element::i64, Shape{1}, pattern::has_class<op::Constant>());
auto dyn_reshape =
auto reshape_v1 =
make_shared<op::v1::Reshape>(constant_data_label, constant_shape_label, false);
auto dyn_reshape =
make_shared<op::v0::DynReshape>(constant_data_label, constant_shape_label, false);
// Note: No need to capture or consider constant_shape_label, because
// shape propagation will have transferred the info to dyn_reshape's
// output.
auto constant_reshape_v1_callback = [constant_data_label](pattern::Matcher& m) {
NGRAPH_DEBUG << "In callback for constant_reshape_v1_callback against node = "
<< m.get_match_root()->get_name();
auto pattern_map = m.get_pattern_map();
auto constant_data_match =
static_pointer_cast<op::Constant>(pattern_map[constant_data_label]);
auto match_root = m.get_match_root();
NGRAPH_CHECK(revalidate_and_ensure_static(match_root));
shared_ptr<Node> replacement;
replacement =
do_fold(static_pointer_cast<op::v1::Reshape>(match_root), constant_data_match);
replace_node(m.get_match_root(), replacement);
return true;
};
auto reshape_v1_matcher =
make_shared<pattern::Matcher>(reshape_v1, "ConstantFolding.ConstantReshapev1");
this->add_matcher(
reshape_v1_matcher, constant_reshape_v1_callback, PassProperty::CHANGE_DYNAMIC_STATE);
auto constant_dyn_reshape_callback = [constant_data_label](pattern::Matcher& m) {
NGRAPH_DEBUG << "In callback for constant_dyn_reshape_callback against node = "
<< m.get_match_root()->get_name();
......@@ -64,75 +149,11 @@ void pass::ConstantFolding::construct_constant_dyn_reshape()
auto constant_data_match =
static_pointer_cast<op::Constant>(pattern_map[constant_data_label]);
auto dyn_reshape_match = static_pointer_cast<op::v1::Reshape>(m.get_match_root());
NGRAPH_CHECK(revalidate_and_ensure_static(dyn_reshape_match));
std::shared_ptr<Node> replacement;
auto type = dyn_reshape_match->get_element_type();
switch (type)
{
case element::Type_t::undefined:
NGRAPH_CHECK(false,
"Encountered 'undefined' element type in constant_dyn_reshape_callback");
break;
case element::Type_t::dynamic:
NGRAPH_CHECK(false,
"Encountered 'dynamic' element type in constant_dyn_reshape_callback");
break;
case element::Type_t::u1:
NGRAPH_CHECK(false, "Encountered 'u1' element type in constant_dyn_reshape_callback");
break;
case element::Type_t::boolean:
replacement = fold_constant_dyn_reshape<char>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::bf16:
replacement =
fold_constant_dyn_reshape<bfloat16>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::f16:
replacement =
fold_constant_dyn_reshape<float16>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::f32:
replacement = fold_constant_dyn_reshape<float>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::f64:
replacement = fold_constant_dyn_reshape<double>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i8:
replacement = fold_constant_dyn_reshape<int8_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i16:
replacement =
fold_constant_dyn_reshape<int16_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i32:
replacement =
fold_constant_dyn_reshape<int32_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::i64:
replacement =
fold_constant_dyn_reshape<int64_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u8:
replacement =
fold_constant_dyn_reshape<uint8_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u16:
replacement =
fold_constant_dyn_reshape<uint16_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u32:
replacement =
fold_constant_dyn_reshape<uint32_t>(constant_data_match, dyn_reshape_match);
break;
case element::Type_t::u64:
replacement =
fold_constant_dyn_reshape<uint64_t>(constant_data_match, dyn_reshape_match);
break;
}
auto match_root = m.get_match_root();
NGRAPH_CHECK(revalidate_and_ensure_static(match_root));
shared_ptr<Node> replacement;
replacement =
do_fold(static_pointer_cast<op::v0::DynReshape>(match_root), constant_data_match);
replace_node(m.get_match_root(), replacement);
return true;
};
......
......@@ -14,10 +14,13 @@
// limitations under the License.
//*****************************************************************************
#include "ngraph/pass/dyn_elimination.hpp"
#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
#include "ngraph/pass/constant_folding.hpp"
#include "ngraph/pass/dyn_elimination.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/opset0_downgrade.hpp"
#include "util/all_close_f.hpp"
#include "util/test_tools.hpp"
......@@ -266,3 +269,25 @@ TEST(dyn_elimination, range_f64)
ASSERT_TRUE(test::all_close_f(
vals, vector<double>{-0.5, -0.25, 0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75}));
}
#ifndef NGRAPH_JSON_DISABLE
TEST(dyn_elimination, paddlepaddle_transpose)
{
string model = "paddlepaddle/transpose.json";
const string json_path = file_util::path_join(SERIALIZED_ZOO, model);
const string json_string = file_util::read_file_to_string(json_path);
shared_ptr<Function> f = ngraph::deserialize(json_string);
vector<element::Type> arg_element_types = {element::f64, element::f64};
vector<PartialShape> arg_shapes = {{3, 4}, {4, 3}};
std::vector<void*> arg_value_base_pointers = {nullptr, nullptr};
auto clone = specialize_function(f, arg_element_types, arg_shapes, arg_value_base_pointers);
pass::Manager passes;
passes.register_pass<pass::ConstantFolding>();
passes.register_pass<pass::DynElimination>();
passes.register_pass<pass::Opset0Downgrade>(); // Converts dynamic v1 variants to v0 ops
passes.set_per_pass_validation(false);
passes.run_passes(clone);
}
#endif
[
{
"name": "Function_0",
"ops": [
{
"cacheable": false,
"element_type": "double",
"name": "Parameter_1",
"op": "Parameter",
"op_version": 0,
"outputs": [
"Parameter_1_0"
],
"shape": null,
"type_info": {
"name": "Parameter",
"version": 0
}
},
{
"cacheable": false,
"element_type": "double",
"name": "Parameter_0",
"op": "Parameter",
"op_version": 0,
"outputs": [
"Parameter_0_0"
],
"shape": null,
"type_info": {
"name": "Parameter",
"version": 0
}
},
{
"inputs": [
"Parameter_0"
],
"name": "ShapeOf_80",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_80_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_84",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_84_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"element_type": "int64_t",
"name": "Constant_79",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_79_0"
],
"shape": [],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"element_type": "int64_t",
"name": "Constant_82",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_82_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"inputs": [
"Constant_79",
"Constant_82"
],
"name": "DynReshape_85",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_85_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"element_type": "int64_t",
"name": "Constant_83",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_83_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_80",
"Constant_84",
"DynReshape_85",
"Constant_83"
],
"lower_bounds_mask": [],
"name": "DynSlice_86",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_86_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_88",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_88_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_86",
"Constant_88"
],
"name": "Product_89",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_89_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_89"
],
"name": "Reshape_90",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_90_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"inputs": [
"ShapeOf_80"
],
"name": "ShapeOf_81",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_81_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_80",
"DynReshape_85",
"ShapeOf_81",
"Constant_83"
],
"lower_bounds_mask": [],
"name": "DynSlice_87",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_87_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_91",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_91_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_87",
"Constant_91"
],
"name": "Product_92",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_92_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_92"
],
"name": "Reshape_93",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_93_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"axis": 0,
"inputs": [
"Reshape_90",
"Reshape_93"
],
"name": "Concat_94",
"op": "Concat",
"op_version": 0,
"outputs": [
"Concat_94_0"
],
"type_info": {
"name": "Concat",
"version": 0
}
},
{
"inputs": [
"Parameter_0",
"Concat_94"
],
"name": "DynReshape_95",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_95_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"element_type": "int64_t",
"name": "Constant_113",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_113_0"
],
"shape": [
2
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1",
"0"
]
},
{
"inputs": [
"DynReshape_95",
"Constant_113"
],
"name": "Transpose_114",
"op": "Transpose",
"op_version": 0,
"outputs": [
"Transpose_114_0"
],
"type_info": {
"name": "Transpose",
"version": 0
}
},
{
"element_type": "double",
"name": "Constant_63",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_63_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"input_order": [
0
],
"inputs": [
"Constant_63"
],
"name": "Reshape_68",
"op": "Reshape",
"op_version": 0,
"output_shape": [],
"outputs": [
"Reshape_68_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"inputs": [
"Parameter_0"
],
"name": "ShapeOf_11",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_11_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_15",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_15_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"element_type": "int64_t",
"name": "Constant_10",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_10_0"
],
"shape": [],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"element_type": "int64_t",
"name": "Constant_13",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_13_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"inputs": [
"Constant_10",
"Constant_13"
],
"name": "DynReshape_16",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_16_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"element_type": "int64_t",
"name": "Constant_14",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_14_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_11",
"Constant_15",
"DynReshape_16",
"Constant_14"
],
"lower_bounds_mask": [],
"name": "DynSlice_17",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_17_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_19",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_19_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_17",
"Constant_19"
],
"name": "Product_20",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_20_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_20"
],
"name": "Reshape_21",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_21_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"inputs": [
"ShapeOf_11"
],
"name": "ShapeOf_12",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_12_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_11",
"DynReshape_16",
"ShapeOf_12",
"Constant_14"
],
"lower_bounds_mask": [],
"name": "DynSlice_18",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_18_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_22",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_22_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_18",
"Constant_22"
],
"name": "Product_23",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_23_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_23"
],
"name": "Reshape_24",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_24_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"axis": 0,
"inputs": [
"Reshape_21",
"Reshape_24"
],
"name": "Concat_25",
"op": "Concat",
"op_version": 0,
"outputs": [
"Concat_25_0"
],
"type_info": {
"name": "Concat",
"version": 0
}
},
{
"inputs": [
"Parameter_0",
"Concat_25"
],
"name": "DynReshape_26",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_26_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"inputs": [
"Parameter_1"
],
"name": "ShapeOf_28",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_28_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_32",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_32_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"element_type": "int64_t",
"name": "Constant_27",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_27_0"
],
"shape": [],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"element_type": "int64_t",
"name": "Constant_30",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_30_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"inputs": [
"Constant_27",
"Constant_30"
],
"name": "DynReshape_33",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_33_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"element_type": "int64_t",
"name": "Constant_31",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_31_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_28",
"Constant_32",
"DynReshape_33",
"Constant_31"
],
"lower_bounds_mask": [],
"name": "DynSlice_34",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_34_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_36",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_36_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_34",
"Constant_36"
],
"name": "Product_37",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_37_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_37"
],
"name": "Reshape_38",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_38_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"inputs": [
"ShapeOf_28"
],
"name": "ShapeOf_29",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_29_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_28",
"DynReshape_33",
"ShapeOf_29",
"Constant_31"
],
"lower_bounds_mask": [],
"name": "DynSlice_35",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_35_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_39",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_39_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_35",
"Constant_39"
],
"name": "Product_40",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_40_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_40"
],
"name": "Reshape_41",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_41_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"axis": 0,
"inputs": [
"Reshape_38",
"Reshape_41"
],
"name": "Concat_42",
"op": "Concat",
"op_version": 0,
"outputs": [
"Concat_42_0"
],
"type_info": {
"name": "Concat",
"version": 0
}
},
{
"inputs": [
"Parameter_1",
"Concat_42"
],
"name": "DynReshape_43",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_43_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"inputs": [
"DynReshape_26",
"DynReshape_43"
],
"name": "Dot_44",
"op": "Dot",
"op_version": 0,
"outputs": [
"Dot_44_0"
],
"reduction_axes_count": 1,
"type_info": {
"name": "Dot",
"version": 0
}
},
{
"inputs": [
"Parameter_0"
],
"name": "ShapeOf_7",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_7_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"inputs": [
"ShapeOf_7"
],
"lower_bounds": [
0
],
"name": "Slice_46",
"op": "Slice",
"op_version": 0,
"outputs": [
"Slice_46_0"
],
"strides": [
1
],
"type_info": {
"name": "Slice",
"version": 0
},
"upper_bounds": [
1
]
},
{
"inputs": [
"Parameter_1"
],
"name": "ShapeOf_8",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_8_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_47",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_47_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"inputs": [
"ShapeOf_8"
],
"name": "ShapeOf_9",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_9_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_45",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_45_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_8",
"Constant_47",
"ShapeOf_9",
"Constant_45"
],
"lower_bounds_mask": [],
"name": "DynSlice_48",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_48_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"axis": 0,
"inputs": [
"Slice_46",
"DynSlice_48"
],
"name": "Concat_49",
"op": "Concat",
"op_version": 0,
"outputs": [
"Concat_49_0"
],
"type_info": {
"name": "Concat",
"version": 0
}
},
{
"inputs": [
"Dot_44",
"Concat_49"
],
"name": "DynReshape_50",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_50_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"inputs": [
"DynReshape_50"
],
"name": "ShapeOf_64",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_64_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_65",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_65_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"ShapeOf_64",
"Constant_65"
],
"name": "Product_66",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_66_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"inputs": [
"Product_66"
],
"name": "Convert_67",
"op": "Convert",
"op_version": 0,
"outputs": [
"Convert_67_0"
],
"target_type": "double",
"type_info": {
"name": "Convert",
"version": 0
}
},
{
"inputs": [
"Reshape_68",
"Convert_67"
],
"name": "Divide_69",
"op": "Divide",
"op_version": 0,
"outputs": [
"Divide_69_0"
],
"pythondiv": true,
"type_info": {
"name": "Divide",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_73",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_73_0"
],
"shape": [],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"ShapeOf_64"
],
"name": "ShapeOf_70",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_70_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"input_order": [
0
],
"inputs": [
"ShapeOf_70"
],
"name": "Reshape_71",
"op": "Reshape",
"op_version": 0,
"output_shape": [],
"outputs": [
"Reshape_71_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_72",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_72_0"
],
"shape": [],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"inputs": [
"Constant_73",
"Reshape_71",
"Constant_72"
],
"name": "Range_74",
"op": "Range",
"op_version": 0,
"outputs": [
"Range_74_0"
],
"type_info": {
"name": "Range",
"version": 0
}
},
{
"inputs": [
"Divide_69",
"ShapeOf_64",
"Range_74"
],
"name": "DynBroadcast_75",
"op": "DynBroadcast",
"op_version": 0,
"outputs": [
"DynBroadcast_75_0"
],
"type_info": {
"name": "DynBroadcast",
"version": 0
}
},
{
"inputs": [
"DynReshape_95"
],
"name": "ShapeOf_117",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_117_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"inputs": [
"ShapeOf_117"
],
"lower_bounds": [
0
],
"name": "Slice_118",
"op": "Slice",
"op_version": 0,
"outputs": [
"Slice_118_0"
],
"strides": [
1
],
"type_info": {
"name": "Slice",
"version": 0
},
"upper_bounds": [
1
]
},
{
"inputs": [
"Parameter_1"
],
"name": "ShapeOf_97",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_97_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"element_type": "int64_t",
"name": "Constant_101",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_101_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"element_type": "int64_t",
"name": "Constant_96",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_96_0"
],
"shape": [],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"element_type": "int64_t",
"name": "Constant_99",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_99_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"inputs": [
"Constant_96",
"Constant_99"
],
"name": "DynReshape_102",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_102_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"element_type": "int64_t",
"name": "Constant_100",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_100_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"1"
]
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_97",
"Constant_101",
"DynReshape_102",
"Constant_100"
],
"lower_bounds_mask": [],
"name": "DynSlice_103",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_103_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_105",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_105_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_103",
"Constant_105"
],
"name": "Product_106",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_106_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_106"
],
"name": "Reshape_107",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_107_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"inputs": [
"ShapeOf_97"
],
"name": "ShapeOf_98",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_98_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"ellipsis_mask": [],
"inputs": [
"ShapeOf_97",
"DynReshape_102",
"ShapeOf_98",
"Constant_100"
],
"lower_bounds_mask": [],
"name": "DynSlice_104",
"new_axis": [],
"op": "DynSlice",
"op_version": 0,
"outputs": [
"DynSlice_104_0"
],
"shrink_axis": [],
"type_info": {
"name": "DynSlice",
"version": 0
},
"upper_bounds_mask": []
},
{
"element_type": "int64_t",
"name": "Constant_108",
"op": "Constant",
"op_version": 0,
"outputs": [
"Constant_108_0"
],
"shape": [
1
],
"type_info": {
"name": "Constant",
"version": 0
},
"value": [
"0"
]
},
{
"inputs": [
"DynSlice_104",
"Constant_108"
],
"name": "Product_109",
"op": "Product",
"op_version": 0,
"outputs": [
"Product_109_0"
],
"reduction_axes": [
0
],
"type_info": {
"name": "Product",
"version": 0
}
},
{
"input_order": [],
"inputs": [
"Product_109"
],
"name": "Reshape_110",
"op": "Reshape",
"op_version": 0,
"output_shape": [
1
],
"outputs": [
"Reshape_110_0"
],
"type_info": {
"name": "Reshape",
"version": 0
}
},
{
"axis": 0,
"inputs": [
"Reshape_107",
"Reshape_110"
],
"name": "Concat_111",
"op": "Concat",
"op_version": 0,
"outputs": [
"Concat_111_0"
],
"type_info": {
"name": "Concat",
"version": 0
}
},
{
"inputs": [
"Parameter_1",
"Concat_111"
],
"name": "DynReshape_112",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_112_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"inputs": [
"DynReshape_112"
],
"name": "ShapeOf_119",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_119_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"inputs": [
"ShapeOf_119"
],
"lower_bounds": [
1
],
"name": "Slice_120",
"op": "Slice",
"op_version": 0,
"outputs": [
"Slice_120_0"
],
"strides": [
1
],
"type_info": {
"name": "Slice",
"version": 0
},
"upper_bounds": [
2
]
},
{
"axis": 0,
"inputs": [
"Slice_118",
"Slice_120"
],
"name": "Concat_121",
"op": "Concat",
"op_version": 0,
"outputs": [
"Concat_121_0"
],
"type_info": {
"name": "Concat",
"version": 0
}
},
{
"inputs": [
"DynBroadcast_75",
"Concat_121"
],
"name": "DynReshape_122",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_122_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"inputs": [
"Transpose_114",
"DynReshape_122"
],
"name": "Dot_123",
"op": "Dot",
"op_version": 0,
"outputs": [
"Dot_123_0"
],
"reduction_axes_count": 1,
"type_info": {
"name": "Dot",
"version": 0
}
},
{
"inputs": [
"Parameter_1"
],
"name": "ShapeOf_77",
"op": "ShapeOf",
"op_version": 0,
"outputs": [
"ShapeOf_77_0"
],
"type_info": {
"name": "ShapeOf",
"version": 0
}
},
{
"inputs": [
"Dot_123",
"ShapeOf_77"
],
"name": "DynReshape_124",
"op": "DynReshape",
"op_version": 0,
"outputs": [
"DynReshape_124_0"
],
"type_info": {
"name": "DynReshape",
"version": 0
},
"zero_flag": false
},
{
"inputs": [
"DynReshape_124"
],
"name": "Result_125",
"needs_default_layout": true,
"op": "Result",
"op_version": 0,
"outputs": [
"Result_125_0"
],
"type_info": {
"name": "Result",
"version": 0
}
}
],
"parameters": [
"Parameter_0",
"Parameter_1"
],
"result": [
"Result_125"
]
}
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment