|
|
|
|
@ -14,6 +14,7 @@ limitations under the License. */
|
|
|
|
|
|
|
|
|
|
#include "paddle/fluid/framework/ir/graph.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include "paddle/fluid/framework/details/multi_devices_helper.h"
|
|
|
|
|
#include "paddle/fluid/framework/op_registry.h"
|
|
|
|
|
#include "paddle/fluid/framework/operator.h"
|
|
|
|
|
#include "paddle/fluid/framework/program_desc.h"
|
|
|
|
|
@ -252,5 +253,22 @@ TEST(GraphTest, TestException) {
|
|
|
|
|
}
|
|
|
|
|
ASSERT_TRUE(not_met_exception);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(GraphTest, TestAttrCopy) {
|
|
|
|
|
ProgramDesc prog;
|
|
|
|
|
ir::Graph src_g(prog);
|
|
|
|
|
ir::Graph dst_g(prog);
|
|
|
|
|
const std::string kIntValue = "int_value";
|
|
|
|
|
const std::string kFloatValue = "float_value";
|
|
|
|
|
const int INT_VALUE = 3;
|
|
|
|
|
src_g.Set<int>(kIntValue, new int(INT_VALUE));
|
|
|
|
|
details::CopyGraphAttrIfExists<int>(src_g, &dst_g, kIntValue);
|
|
|
|
|
details::CopyGraphAttrIfExists<float>(src_g, &dst_g, kFloatValue);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(dst_g.Has(kIntValue));
|
|
|
|
|
ASSERT_EQ(dst_g.Get<int>(kIntValue), INT_VALUE);
|
|
|
|
|
ASSERT_FALSE(dst_g.Has(kFloatValue));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace framework
|
|
|
|
|
} // namespace paddle
|
|
|
|
|
|