mindspore/tests/ut/cpp/optimizer/renormalize_test.cc

62 lines
2.1 KiB
C++

/**
* Copyright 2022 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>
#include <memory>
#include "common/common_test.h"
#include "common/py_func_graph_fetcher.h"
#include "ir/anf.h"
#include "ir/visitor.h"
#include "ir/func_graph_cloner.h"
#include "frontend/optimizer/optimizer.h"
#include "frontend/optimizer/opt.h"
#include "frontend/optimizer/anf_visitor.h"
#include "frontend/optimizer/irpass.h"
#include "frontend/optimizer/irpass/arithmetic_simplify.h"
#include "pipeline/jit/action.h"
#include "include/common/debug/draw.h"
#include "frontend/operator/ops.h"
#include "include/common/utils/cse.h"
#include "include/common/utils/convert_utils.h"
namespace mindspore {
namespace opt {
class TestRenormalize : public UT::Common {
public:
TestRenormalize() : getPyFun("gtest_input.optimizer.renormalize_test", true) {}
void SetUp() {}
public:
UT::PyFuncGraphFetcher getPyFun;
};
// Feature: Specialize.
// Description: If a poly node's parent are not specialized, poly node should be delay specialized.
// Expectation: graph can be executed and no exception raised.
TEST_F(TestRenormalize, TestPolyDelaySpecialize) {
FuncGraphPtr test_graph = getPyFun.CallAndParseRet("test_renormalize", "test_poly_delay_specialize_ut");
ASSERT_TRUE(nullptr != test_graph);
pipeline::ResourcePtr res = std::make_shared<pipeline::Resource>();
std::vector<AbstractBasePtr> args_spec;
pipeline::Renormalize(res, test_graph, args_spec);
abstract::AnalysisResultCacheMgr::GetInstance().Clear();
abstract::AnalysisContext::ClearContext();
}
} // namespace opt
} // namespace mindspore