forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PaddlePaddle#22 from Superjomn/fea/placeholder-dsl
initialize placeholder dsl
- Loading branch information
Showing
63 changed files
with
364 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "cinn/common/context.h" | ||
|
||
namespace cinn { | ||
namespace common {} // namespace common | ||
} // namespace cinn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace cinn { | ||
namespace common { | ||
|
||
struct ID { | ||
size_t id() const { return cur_; } | ||
size_t New() { return ++cur_; } | ||
void Reset() { cur_ = 0; } | ||
|
||
private: | ||
size_t cur_; | ||
}; | ||
|
||
struct NameGenerator { | ||
std::string New(const std::string& name_hint) { return name_hint + "_" + std::to_string(id_.New()); } | ||
|
||
private: | ||
ID id_; | ||
}; | ||
|
||
class Context { | ||
public: | ||
static Context& Global() { | ||
static Context x; | ||
return x; | ||
} | ||
/** | ||
* Generate a new unique name. | ||
* @param name_hint The prefix. | ||
*/ | ||
std::string NewName(const std::string& name_hint) { return name_generator_.New(name_hint); } | ||
|
||
private: | ||
Context() = default; | ||
NameGenerator name_generator_; | ||
}; | ||
|
||
} // namespace common | ||
} // namespace cinn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "cinn/common/common.h" | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/common/pod_value.h" | ||
|
||
#include "cinn/ir/node.h" | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#pragma once | ||
#include <glog/logging.h> | ||
|
||
#include <boost/variant/get.hpp> | ||
#include <boost/variant/variant.hpp> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/common/pod_value.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
#include "cinn/common/shared.h" | ||
|
||
#include <glog/logging.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include "cinn/common/object.h" | ||
#include "cinn/common/shared.h" | ||
|
||
namespace cinn { | ||
namespace common { | ||
|
||
class A : public Object {}; | ||
struct A : public Object { | ||
const char *type_info() const override { return "A"; } | ||
}; | ||
class B : public Object {}; | ||
|
||
TEST(Shared, test) {} | ||
TEST(Shared, test) { | ||
Shared<A> a_ref(make_shared<A>()); | ||
ASSERT_EQ(ref_count(a_ref.get()).val(), 1); | ||
|
||
{ // local copy | ||
Shared<A> b = a_ref; | ||
EXPECT_EQ(ref_count(a_ref.get()).val(), 2); | ||
ASSERT_EQ(ref_count(b.get()).val(), 2); | ||
} | ||
|
||
ASSERT_EQ(ref_count(a_ref.get()).val(), 1); | ||
} | ||
|
||
} // namespace common | ||
} // namespace cinn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "cinn/ir/buffer.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <vector> | ||
|
||
#include "cinn/common/common.h" | ||
|
||
namespace cinn { | ||
namespace ir { | ||
|
||
TEST(Buffer, basic) { | ||
Var ptr("buff", Float(32)); | ||
std::vector<Expr> shape({Expr(100), Expr(20)}); | ||
Var i("i"), j("j"); | ||
std::vector<Expr> strides({Expr(0), Expr(0)}); | ||
auto buffer = _Buffer_::Make(ptr, ptr->type(), shape, strides, Expr(0), "buf", "", 0, 0); | ||
|
||
// Check shared | ||
ASSERT_EQ(ref_count(buffer.get()).val(), 1); | ||
|
||
{ | ||
auto buffer1 = buffer; | ||
ASSERT_EQ(ref_count(buffer.get()).val(), 2); | ||
ASSERT_EQ(ref_count(buffer1.get()).val(), 2); | ||
} | ||
|
||
ASSERT_EQ(ref_count(buffer.get()).val(), 1); | ||
} | ||
|
||
} // namespace ir | ||
} // namespace cinn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "cinn/ir/ir.h" | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/ir/function.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/ir/ir_operators.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#include "cinn/ir/ir_printer.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <sstream> | ||
|
||
namespace cinn { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "cinn/ir/ir.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "cinn/utils/string.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.