text
stringlengths 0
2.2M
|
---|
->check_count("aten::div", 2, /*exactly=*/true)
|
->run(*g);
|
test_only_remove_entry("aten::_test_serialization_subcmul");
|
test_only_remove_upgraders(test_upgraders);
|
}
|
TEST(OpReplacementTest, ReplaceDivInNestedFunction) {
|
const auto graph_string = R"IR(
|
graph(%0 : Tensor,
|
%1 : Tensor,
|
%8 : bool):
|
%9 : bool = prim::Constant[value=1]()
|
%7 : bool = prim::If(%8)
|
block0():
|
-> (%9)
|
block1():
|
%2 : Tensor = aten::add(%0, %1)
|
%3 : Tensor = aten::div(%2, %1)
|
%4 : Tensor = aten::add(%3, %0)
|
%10 : bool = aten::is_floating_point(%4)
|
-> (%10)
|
return (%7))IR";
|
auto g = std::make_shared<Graph>();
|
test_only_populate_upgraders(test_upgraders);
|
torch::jit::parseIR(graph_string, g.get());
|
g->set_op_version(2);
|
ReplaceOldOperatorsWithUpgraders(g);
|
testing::FileCheck()
|
.check("prim::If")
|
->check_count("aten::add", 2, false)
|
->run(*g);
|
testing::FileCheck()
|
.check("prim::If")
|
->check_count("aten::div", 2, false)
|
->run(*g);
|
test_only_remove_upgraders(test_upgraders);
|
}
|
TEST(OpReplacementTest, ReplaceTestSubcmulInSimpleFunction) {
|
const auto graph_string = R"IR(
|
graph(%0 : Tensor,
|
%1 : Tensor):
|
%3 : int = prim::Constant[value=1]()
|
%2 : Tensor = aten::_test_serialization_subcmul(%0, %1, %3)
|
return (%2))IR";
|
auto g = std::make_shared<Graph>();
|
test_only_populate_upgraders(test_upgraders);
|
UpgraderEntry test_entry{
|
3,
|
"_test_serialization_subcmul_0_2",
|
"aten::_test_serialization_subcmul(Tensor self, Tensor other, Scalar alpha=2) -> Tensor"};
|
test_only_add_entry("aten::_test_serialization_subcmul", test_entry);
|
torch::jit::parseIR(graph_string, g.get());
|
g->set_op_version(2);
|
ReplaceOldOperatorsWithUpgraders(g);
|
testing::FileCheck().check_count("aten::mul", 1, false)->run(*g);
|
testing::FileCheck().check_count("aten::sub", 1, false)->run(*g);
|
test_only_remove_upgraders(test_upgraders);
|
test_only_remove_entry("aten::_test_serialization_subcmul");
|
}
|
} // namespace jit
|
} // namespace torch
|
#include <torch/torch.h>
|
#include <chrono>
|
#include <condition_variable>
|
#include <mutex>
|
class Baton {
|
public:
|
void post() {
|
std::unique_lock<std::mutex> l(lock_);
|
done_ = true;
|
cv_.notify_all();
|
}
|
void wait() {
|
std::unique_lock<std::mutex> l(lock_);
|
while (!done_) {
|
cv_.wait(l);
|
}
|
}
|
private:
|
std::mutex lock_;
|
std::condition_variable cv_;
|
bool done_{false};
|
};
|
void AtLaunch_Base(int32_t numIters) {
|
struct Helper {
|
explicit Helper(int32_t lim) : limit_(lim) {}
|
void operator()() {
|
if (++val_ == limit_) {
|
done.post();
|
} else {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.