Skip to content

Commit

Permalink
[RELAY] Fix the FoldConstant Regression for VTA (apache#6377)
Browse files Browse the repository at this point in the history
* [RELAY] Fix the FoldConstant Regression for VTA

* [CI] Fix error guard that was missed in VTA.

This PR fixes an error guard during the documentation build step.

- Temporary disables VTA frontend tutorial due to
  the regression of deploy_detection
  • Loading branch information
tqchen authored and kevinthesun committed Sep 18, 2020
1 parent 2e734f7 commit d87cb6c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
26 changes: 11 additions & 15 deletions src/relay/transforms/fold_constant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,6 @@ class ConstantFolder : public ExprMutator {
const Op& cast_op_;
const Op& ndarray_size_op_;

// Create an interpreter.
FInterpreter GetInterpreter(const IRModule& mod) {
using tvm::transform::PassContext;
DLContext ctx;
ctx.device_type = kDLCPU;
ctx.device_id = 0;
Target target = Target::Create("llvm");
// use a fresh build context
// in case we are already in a build context.
With<PassContext> fresh_build_ctx(PassContext::Create());

return CreateInterpreter(mod, ctx, target);
}

// Convert value to expression.
Expr ObjectToExpr(const ObjectRef& value) {
if (value->IsInstance<runtime::NDArray::ContainerType>()) {
Expand Down Expand Up @@ -230,7 +216,17 @@ class ConstantFolder : public ExprMutator {
auto entry_func = Downcast<Function>(mod->Lookup("main"));
expr = expr.as<FunctionNode>() == nullptr ? entry_func->body : entry_func;

FInterpreter executor = GetInterpreter(mod);
using tvm::transform::PassContext;
DLContext ctx;
ctx.device_type = kDLCPU;
ctx.device_id = 0;
Target target = Target::Create("llvm");
// use a fresh build context
// in case we are already in a build context.
// needed for both execution and creation(due to JIT)
With<PassContext> fresh_build_ctx(PassContext::Create());

FInterpreter executor = CreateInterpreter(mod, ctx, target);
return ObjectToExpr(executor(expr));
}

Expand Down
3 changes: 2 additions & 1 deletion tests/scripts/task_python_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

set -e
set -u
set -o pipefail

source tests/scripts/setup-pytest-env.sh

Expand Down Expand Up @@ -48,7 +49,7 @@ make cython3

cd docs
PYTHONPATH=`pwd`/../python make html |& tee /tmp/$$.log.txt
if grep -E "failed to execute" < /tmp/$$.log.txt; then
if grep -E "failed to execute|Segmentation fault" < /tmp/$$.log.txt; then
echo "Some of sphinx-gallery item example failed to execute."
exit 1
fi
Expand Down
File renamed without changes.

0 comments on commit d87cb6c

Please sign in to comment.