forked from apache/tvm
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Init. * Proof of concept. * Rebase on the newest branch * Move to emit_te * Update emit_te * Make RXPlaceholderOpNode as a subclass of PlaceholderOpNode * Update * run vm test_te * Update argument conversion * Reset create_primfunc * Update doc * Update test * Add error message * Update * Update * Address comment * unit test check structural and validate_te_args * raise ValueError when multiple outputs * address comments * example usage emit_te * Rename to context_mod * Handle multiple call * Address comments * Address comments * Use unique name * remove * rename args to te_args * address comments * fix TVMscript manually * spelling Co-authored-by: Andrew Liu <[email protected]>
- Loading branch information
Showing
9 changed files
with
377 additions
and
10 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
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,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
/*! | ||
* \file relax/src/ir/emit_te.cc | ||
*/ | ||
#include <tvm/relax/type.h> | ||
#include "./emit_te.h" | ||
|
||
namespace tvm { | ||
namespace relax { | ||
|
||
// RXPlaceholderOpNode | ||
TVM_STATIC_IR_FUNCTOR(ReprPrinter, vtable) | ||
.set_dispatch<RXPlaceholderOpNode>([](const ObjectRef& node, ReprPrinter* p) { | ||
auto* op = static_cast<const RXPlaceholderOpNode*>(node.get()); | ||
p->stream << "rxplaceholder(" << op->name << ", " << op << ")"; | ||
}); | ||
|
||
TVM_REGISTER_NODE_TYPE(RXPlaceholderOpNode); | ||
|
||
te::Tensor TETensor(Expr value, std::string name) { | ||
auto n = make_object<RXPlaceholderOpNode>(); | ||
n->name = name; | ||
n->value = value; | ||
|
||
Expr shape_expr = value->shape(); | ||
CHECK(shape_expr->IsInstance<ShapeExprNode>()) | ||
<< "ValueError: Expression does not have an known symbolic shape, please consider use match_shape " | ||
<< "to constrain the shape before passing into te_tensor"; | ||
Array<PrimExpr> shape = Downcast<ShapeExpr>(shape_expr)->values; | ||
n->shape = shape; | ||
Type type = value->checked_type(); | ||
ICHECK(type->IsInstance<DynTensorTypeNode>()) | ||
<< "ValueError: Expression should have a inferred DynTensorType: " | ||
<< type->GetTypeKey(); | ||
DataType dtype = Downcast<DynTensorType>(type)->dtype; | ||
n->dtype = dtype; | ||
return te::PlaceholderOp(n).output(0); | ||
} | ||
|
||
TVM_REGISTER_GLOBAL("relax.TETensor") | ||
.set_body_typed([](Expr value, std::string name) { | ||
return TETensor(value, name); | ||
}); | ||
|
||
} // namespace relax | ||
} // namespace tvm |
Oops, something went wrong.