mehrdadh commented on a change in pull request #10590:
URL: https://github.com/apache/tvm/pull/10590#discussion_r828704288
##########
File path: tests/cpp/c_codegen_test.cc
##########
@@ -59,3 +59,50 @@ TEST(CCodegen, FunctionOrder) {
ICHECK(functions.back().compare(tvm_module_main) == 0);
}
+
+TEST(CCodegen, FunctionOrder) {
+ using testing::_;
+ using testing::ElementsAre;
+ using testing::StrEq;
+ using namespace tvm;
+ using namespace tvm::te;
+
+ auto target = Target("c -keys=cpu -link-params=0");
+
+ // The shape of input tensors.
+ const int n = 4;
+ Array<PrimExpr> shape{n};
+
+ auto A = placeholder(shape, DataType::Float(32), "A");
+ auto B = placeholder(shape, DataType::Float(32), "B");
+
+ auto op_1 = compute(
+ A->shape, [&A, &B](PrimExpr i) { return A[i] + B[i]; }, "op_1");
+
+ auto op_2 = compute(
+ A->shape, [&A, &B](PrimExpr i) { return A[i] - B[i]; }, "op_2");
+
+ auto fcreate_s1 = [=]() {
+ With<Target> llvm_scope(target);
+ return create_schedule({op_1->op});
+ };
+
+ auto fcreate_s2 = [=]() {
+ With<Target> llvm_scope(target);
+ return create_schedule({op_2->op});
+ };
+
+ auto args1 = Array<Tensor>({A, B, op_1});
+ auto args2 = Array<Tensor>({A, B, op_2});
+
+ std::unordered_map<Tensor, Buffer> binds;
+ auto lowered_s1 = LowerSchedule(fcreate_s1(), args1, "op_1", binds);
+ auto lowered_s2 = LowerSchedule(fcreate_s2(), args2, "op_2", binds);
+
+ // add schedules in reverse order
+ Map<tvm::Target, IRModule> inputs = {{target, lowered_s2}, {target,
lowered_s1}};
Review comment:
done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]