未验证 提交 70a009ee 编写于 作者: M Minner Wang 提交者: GitHub

Mingyan.w (#56065)

Fixed a bug in the if (!id_hint.empty()) code block by adding missing code to correctly modify id_hint.
上级 faeb0239
...@@ -253,12 +253,8 @@ NETBUILDER_REDUCE_OP_DEF(ReduceAny, reduce_any) ...@@ -253,12 +253,8 @@ NETBUILDER_REDUCE_OP_DEF(ReduceAny, reduce_any)
Placeholder NetBuilder::CreateInput(const Type& type, Placeholder NetBuilder::CreateInput(const Type& type,
const std::vector<int>& shape, const std::vector<int>& shape,
const std::string& id_hint) { const std::string& id_hint) {
if (!id_hint.empty()) { std::string id = id_hint.empty() ? Context::Global().NewName("placeholder")
cinn::utils::TransValidVarName(id_hint); : cinn::utils::TransValidVarName(id_hint);
}
std::string id =
id_hint.empty() ? Context::Global().NewName("placeholder") : id_hint;
inputs_.emplace_back(id); inputs_.emplace_back(id);
auto& var = inputs_.back(); auto& var = inputs_.back();
var->type = type; var->type = type;
......
...@@ -76,6 +76,16 @@ TEST(net_build, basic) { ...@@ -76,6 +76,16 @@ TEST(net_build, basic) {
} }
} }
TEST(net_build, TestTransValidVarName) {
std::string a_val_id = "A";
std::string b_val_id = "B___";
frontend::NetBuilder builder("net_builder");
auto a = builder.CreateInput(Float(32), {1, 64, 112, 112}, "@A");
auto b = builder.CreateInput(Float(32), {64}, "B/");
EXPECT_EQ(a.id(), a_val_id);
EXPECT_EQ(b.id(), b_val_id);
}
TEST(net_build, program_execute_multi_elementwise_add) { TEST(net_build, program_execute_multi_elementwise_add) {
auto program = CreateAddProgram(); auto program = CreateAddProgram();
#ifdef CINN_WITH_CUDA #ifdef CINN_WITH_CUDA
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册