Uh oh!
There was an error while loading. Please reload this page.
[Ansor][AutoTVM v2.0] Phase 1: Access Analyzer - #6103
Conversation
merrymercy
commented
Jul 21, 2020
Uh oh!
There was an error while loading. Please reload this page.
It is one of the core part of the system. Will take a look later tomorrow night. |
Uh oh!
There was an error while loading. Please reload this page.
merrymercy
commented
Jul 21, 2020
ea153e2 to
56b0187Compare95ef46c to
966c3ccCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /*! \brief Store whether the operation is an output operation */ | ||
| OperationMap<bool> is_output; | ||
| /*! \brief Store the topological order of operations */ | ||
| Array<te::Operation> ops_topo_order; |
There was a problem hiding this comment.
What's the relationship between this array and ComputeDAG::ops?
There was a problem hiding this comment.
They are the same. I store it in AccessAnalyzer because it is used first here.
In the constructor of ComputeDAG, it copies ops_topo_order as its ops
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| namespace auto_scheduler { | ||
| /*! \brief Static analysis result for a ComputeDAG */ | ||
| class AccessAnalyzerNode : public Object { |
There was a problem hiding this comment.
I feel like AccessAnalyzer itself can be a much more principled and extensible component of the system, so shall we put it in a separate file instead?
There was a problem hiding this comment.
Agree. Maybe have an analysis.h to expect more analyzers in the future. On the other hand, another direction might be renaming AccessAnalyzer to ComputeDAGAnalyzer, because it provides some APIs for the ops in a compute DAG, such as NeedMultiLevelTiling, IsOutput, etc.
tqchen
commented
Jul 22, 2020
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| fail_ = true; | ||
| break; | ||
| } | ||
| cur_type_code_ = pop->output_dtype(0).code(); |
There was a problem hiding this comment.
could you elaborate why we need cur_type_code_? how do we deal with the case that computation is mixed with int8 and fp32?
There was a problem hiding this comment.
The FLOP information is only used for printing and debugging. It is okay to just give a rough estimation.
There was a problem hiding this comment.
@merrymercy I agree that it is totally okay if we can just use rough information (in fact it is highly non-trivial to get accurate info without backend info). My point is that cur_type_code_ comes from the dtype of output, but it is totally possible that a compute dag contains computation of different type code (int8, fp16)
There was a problem hiding this comment.
It is not common at all. The common case is either int8->int16/32 or fp16/fp16->fp32
comaniac
left a comment
There was a problem hiding this comment.
Overall LGTM. Agree with @junrushao1994 on most comments.
| namespace auto_scheduler { | ||
| /*! \brief Static analysis result for a ComputeDAG */ | ||
| class AccessAnalyzerNode : public Object { |
There was a problem hiding this comment.
Agree. Maybe have an analysis.h to expect more analyzers in the future. On the other hand, another direction might be renaming AccessAnalyzer to ComputeDAGAnalyzer, because it provides some APIs for the ops in a compute DAG, such as NeedMultiLevelTiling, IsOutput, etc.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| node->read_from[op] = OperationMap<std::vector<std::vector<PrimExpr>>>(); | ||
| } else if (auto cop = op.as<te::ComputeOpNode>()) { | ||
| TensorAccessExtractor extractor; | ||
| for (const auto& exp : cop->body) { |
There was a problem hiding this comment.
just curious: did we test with ComputeOp with multiple bodies?
There was a problem hiding this comment.
No. It will be addressed later.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
junrushao
left a comment
There was a problem hiding this comment.
Finally done this round of review... Thanks for the contribution!
| const Array<PrimExpr>& output_shape = op->output_shape(0); | ||
| const Array<PrimExpr>& producer_shape = producer->output_shape(0); |
There was a problem hiding this comment.
Do it only work for te::Operation with a single output? Do we have a fallback solution for operators with multiple outputs like argmax?
There was a problem hiding this comment.
Even with multiple outputs, the shape will be the same
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
99e9ab3 to
b01fcf8Comparemerrymercy
commented
Jul 23, 2020
@junrushao1994@jcf94@comaniac Most of the comments are addressed. I added more doc and make the name convention more consistent and meaningful. Please take another look |
b01fcf8 to
f63929bComparef63929b to
c690c32Compare4cfe0cf to
e9933c6Comparee9933c6 to
e032686Compare* add access analyzer * add test cases * move header files and polish comments * fix lint * update * fix lint * address comments * fix lint
* add access analyzer * add test cases * move header files and polish comments * fix lint * update * fix lint * address comments * fix lint
* add access analyzer * add test cases * move header files and polish comments * fix lint * update * fix lint * address comments * fix lint
* add access analyzer * add test cases * move header files and polish comments * fix lint * update * fix lint * address comments * fix lint
* add access analyzer * add test cases * move header files and polish comments * fix lint * update * fix lint * address comments * fix lint
For the full upstream plan, see Ansor RFC.
This pr
The search policy will use the analysis results to make decisions such as doing multi-level tiling for an op or strictly inlining an op.
include/tvm/auto_schedulerand polishes some comments.