Skip to content

Commit

Permalink
[Diagnostics][Relay][InferType] Refactor InferType to work on whole m…
Browse files Browse the repository at this point in the history
…odule, and use new diagnostics. (apache#6274)

* Refactor the type checker to use diagnostics

Although this patch is very large and seemingly disjoint the
fixes are required to get it working for the entire stack.
I started with first changing InferType to use the diagnostics,
these weren't yet in the pass manager so this required changes
to module and module pass. InferType wasn't actually written
correctly as a pass requring refactoring there, then in order
to add spans to AST it required turning on AnnotateSpans which
in term required changes to the parser, and module to make
it possible to use the errors. These changes to parse and module
required changes to diagnostics and InferType. Althought seemingly
disconnected there are hidden cycles between the components which
require simultaneous change in order to remove the old error
reporting.

A huge change due to this patch is that the module no longer
implicitly type checks functions which are added.

* Apply suggestions from code review

Co-authored-by: Robert Kimball <bobkimball@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>

* Apply suggestions from code review

Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>

* Clean up parser

* CR feedback

* Apply Bobs suggestions

* Fix up Python interface for diagnostics

* Fix test_ir_parser and formatting

* Fix cpplint

* Fix lint

* Fix format

* More lint

* Fix format

* Kill dead doc comment

* Fix documentation comment

* Rebase fixups

* Add docs for type.h

* Fix parser.cc

* Fix unittests

* Fix black

* Skip previously typechecked functions

* fix ACL

* Fix numerous issues

* Add repr method

* Fix issue with Pytest, I am ready to cry

* Fix the rest of tests

* Kill dead code

* Fix dignostic tests

* Fix more tests

* fix more tests (#11)

* Fix diagnostic.py deinit bug

* Fix deinit issue

* Format

* Tweak disabling of override

* Format

* Fix BYOC

* Fix TensorArray stuff

* Fix PyTorch

* Format

* Format

Co-authored-by: Robert Kimball <bobkimball@gmail.com>
Co-authored-by: Junru Shao <junrushao1994@gmail.com>
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
Co-authored-by: Zhi <5145158+zhiics@users.noreply.github.com>
  • Loading branch information
6 people authored and trevor-m committed Oct 19, 2020
1 parent 79d558b commit e1b3923
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 179 deletions.
179 changes: 0 additions & 179 deletions src/parser/diagnostic.h

This file was deleted.

1 change: 1 addition & 0 deletions src/relay/op/nn/convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ bool Conv3DRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
<< "Conv3D: shape of weight is inconsistent with channels, "
<< " channels=" << param->channels << " wshape=" << wshape;
}

if (!dshape_ncdhw[1].as<tir::AnyNode>() && !wshape[1].as<tir::AnyNode>()) {
CHECK(reporter->AssertEQ(indexdiv(dshape_ncdhw[1], param->groups), wshape[1]));
}
Expand Down
1 change: 1 addition & 0 deletions tests/python/relay/test_ir_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ def test_op_string_attr():
nn.conv2d(%x, %y, data_layout="NHWC", kernel_layout="HWIO")
"""
)

assert isinstance(call.op, tvm.ir.Op)
assert call.op.name == "nn.conv2d"
assert call.attrs.data_layout == "NHWC"
Expand Down

0 comments on commit e1b3923

Please sign in to comment.