Skip to content

[TVM EP] code refactor - #10655

Merged
Xavier Dupré (xadupre) merged 16 commits into
microsoft:masterfrom
octoml:vc/tvm_ep_refactor
Mar 16, 2022
Merged

Xavier Dupré (xadupre) merged 16 commits into
microsoft:masterfrom
octoml:vc/tvm_ep_refactor

Conversation

@vvchernov

@vvchernov Valery Chernov (vvchernov) commented Feb 24, 2022

Copy link
Copy Markdown
Contributor

The main idea of the patch is to clean code of TVM EP for simplification of further development:

  1. Create separated classes for compilation and running
  2. Extract model compilation from Runner class
  3. Implement different specialization of Runner for GraphExecutor and VirtualMachine
  4. Reduce the number of conditions operators in complicated algorithms.
  5. Small refactoring for clarification of system behaviour
  6. all TVM EP dependences were covered by onnxruntime::tvm namespace

Alone functionality added is that each fused node has own compiler, earlier there is only one compiler. It should correctly support the mechanism of the responsibility pass between EPs.

@vvchernov
Valery Chernov (vvchernov) force-pushed the vc/tvm_ep_refactor branch 4 times, most recently from 83de210 to 53968a6 Compare March 3, 2022 18:05
…tion from TVMRunner. connect TVMRunnerImpl to TVMRunner
@vvchernov Valery Chernov (vvchernov) changed the title WIP: [TVM EP] code refactor [TVM EP] code refactor Mar 9, 2022
@vvchernov

Copy link
Copy Markdown
Contributor Author

Hello Xavier Dupré (@xadupre)! Could you see and start CI?

@xadupre

Copy link
Copy Markdown
Member

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

@xadupre

Copy link
Copy Markdown
Member

/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows WebAssembly CI Pipeline, orttraining-amd-gpu-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, onnxruntime-python-checks-ci-pipeline

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 9 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 8 pipeline(s).

@vvchernov

Copy link
Copy Markdown
Contributor Author

Hello Xavier Dupré (@xadupre) could you restart onnxruntime-python-checks-ci-pipeline, it failed due to read timeout, looks like it is occasual issue of CI test which does not depend on the patch

@xadupre

Copy link
Copy Markdown
Member

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

auto TVMCompiler::operator()(const TvmEPOptions& options,
const TVMTensorShapes& input_shapes) -> ModulePtr {
if (mod_) {
return mod_;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

size_t pos = src.find( ch );
size_t initialPos = 0;
while( pos != std::string::npos ) {
dst.push_back( src.substr( initialPos, pos - initialPos ) );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

int TvmExecutionProvider::CreateStateFunc(ComputeContext* context, FunctionState* state) {
int TvmExecutionProvider::createStateFunc(ComputeContext* context, FunctionState* state) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first letter is lower, is it a private method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is

const std::shared_ptr<TvmModule>& mod,
const InputsInfoMap& inputs_info,
const std::vector<DLTensor>& output_tensors) {
runner_ = getTVMRunnerImpl(mod, options, inputs_info, output_tensors);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vvchernov

Copy link
Copy Markdown
Contributor Author

Hello Xavier Dupré (@xadupre)! I've tried to fix all indentations in TVM EP code, also TVM hash commit was updated. Do you have any other comments/remarks?

@xadupre

Copy link
Copy Markdown
Member

It is ok. I'm running the test again.

@xadupre

Copy link
Copy Markdown
Member

/azp run Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows WebAssembly CI Pipeline, orttraining-amd-gpu-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, onnxruntime-python-checks-ci-pipeline

@xadupre

Copy link
Copy Markdown
Member

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 7 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 9 pipeline(s).

@vvchernov

Copy link
Copy Markdown
Contributor Author

Good morning Xavier Dupré (@xadupre)! Could you start Windows CPU CI pipelines?

@xadupre

Copy link
Copy Markdown
Member

/azp run Windows CPU CI Pipeline

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@vvchernov

Copy link
Copy Markdown
Contributor Author

Hello Xavier Dupré (@xadupre). CI tests passed successfully

@xadupre
Xavier Dupré (xadupre) merged commit 625a1f7 into microsoft:master Mar 16, 2022
@xadupre

Copy link
Copy Markdown
Member

/azp run Linux TVM CI Pipeline

@xadupre

Copy link
Copy Markdown
Member

Hi Valery Chernov (@vvchernov), I think this PR may have broken Linux TVM CI Pipeline (see #10895). It is possible to look into it?

@vvchernov

Copy link
Copy Markdown
Contributor Author

Thanks Xavier Dupré (@xadupre), I'll see it

@vvchernov
Valery Chernov (vvchernov) deleted the vc/tvm_ep_refactor branch March 17, 2022 13:07
@ytaous

ytaous commented Mar 17, 2022

Copy link
Copy Markdown
Contributor

It seems to break the TVM CI pipeline. Is it possible to revert it for now? Or have a quick fix ....
https://dev.azure.com/onnxruntime/onnxruntime/_build?definitionId=189&_a=summary

@vvchernov

Copy link
Copy Markdown
Contributor Author

ytaous quick fix here

lavanyax pushed a commit to intel/onnxruntime that referenced this pull request Mar 29, 2022
* rename info to options for TVM EP

* transfer options processing from TVMExecutionProvider to TVMEPOptions

* transfer TVMRunner to separated files

* implement TVMCompiler class

* replace CompileFunc by TVMCompiler object. update TVMRunner. now it does not depend on TvmExecutionProvider

* correct logging of TVM EP options

* RunnerImpl, GERunnerImpl and VMRunnerImpl were implemented

* add prepareComputeInfo method

* remove update_output_shapes flag

* embed all TVM EP dependences to tvm namespace. transfer model compilation from TVMRunner. connect TVMRunnerImpl to TVMRunner

* refactor compileModel method

* small cleaning

* separate TVM EP options data store and processing

* replace TvmTensorShape by InlinedVector with max_size 5

* correct indentation

* update TVM hash

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
Mike Seddon (seddonm1) pushed a commit to seddonm1/onnxruntime that referenced this pull request May 15, 2022
* rename info to options for TVM EP

* transfer options processing from TVMExecutionProvider to TVMEPOptions

* transfer TVMRunner to separated files

* implement TVMCompiler class

* replace CompileFunc by TVMCompiler object. update TVMRunner. now it does not depend on TvmExecutionProvider

* correct logging of TVM EP options

* RunnerImpl, GERunnerImpl and VMRunnerImpl were implemented

* add prepareComputeInfo method

* remove update_output_shapes flag

* embed all TVM EP dependences to tvm namespace. transfer model compilation from TVMRunner. connect TVMRunnerImpl to TVMRunner

* refactor compileModel method

* small cleaning

* separate TVM EP options data store and processing

* replace TvmTensorShape by InlinedVector with max_size 5

* correct indentation

* update TVM hash

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
Peter Salas (petersalas) pushed a commit to octoml/onnxruntime that referenced this pull request Nov 7, 2022
* rename info to options for TVM EP

* transfer options processing from TVMExecutionProvider to TVMEPOptions

* transfer TVMRunner to separated files

* implement TVMCompiler class

* replace CompileFunc by TVMCompiler object. update TVMRunner. now it does not depend on TvmExecutionProvider

* correct logging of TVM EP options

* RunnerImpl, GERunnerImpl and VMRunnerImpl were implemented

* add prepareComputeInfo method

* remove update_output_shapes flag

* embed all TVM EP dependences to tvm namespace. transfer model compilation from TVMRunner. connect TVMRunnerImpl to TVMRunner

* refactor compileModel method

* small cleaning

* separate TVM EP options data store and processing

* replace TvmTensorShape by InlinedVector with max_size 5

* correct indentation

* update TVM hash

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
(cherry picked from commit 625a1f7)
Peter Salas (petersalas) pushed a commit to octoml/onnxruntime that referenced this pull request Nov 8, 2022
* rename info to options for TVM EP

* transfer options processing from TVMExecutionProvider to TVMEPOptions

* transfer TVMRunner to separated files

* implement TVMCompiler class

* replace CompileFunc by TVMCompiler object. update TVMRunner. now it does not depend on TvmExecutionProvider

* correct logging of TVM EP options

* RunnerImpl, GERunnerImpl and VMRunnerImpl were implemented

* add prepareComputeInfo method

* remove update_output_shapes flag

* embed all TVM EP dependences to tvm namespace. transfer model compilation from TVMRunner. connect TVMRunnerImpl to TVMRunner

* refactor compileModel method

* small cleaning

* separate TVM EP options data store and processing

* replace TvmTensorShape by InlinedVector with max_size 5

* correct indentation

* update TVM hash

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
(cherry picked from commit 625a1f7)
Peter Salas (petersalas) pushed a commit to octoml/onnxruntime that referenced this pull request Nov 8, 2022
* rename info to options for TVM EP

* transfer options processing from TVMExecutionProvider to TVMEPOptions

* transfer TVMRunner to separated files

* implement TVMCompiler class

* replace CompileFunc by TVMCompiler object. update TVMRunner. now it does not depend on TvmExecutionProvider

* correct logging of TVM EP options

* RunnerImpl, GERunnerImpl and VMRunnerImpl were implemented

* add prepareComputeInfo method

* remove update_output_shapes flag

* embed all TVM EP dependences to tvm namespace. transfer model compilation from TVMRunner. connect TVMRunnerImpl to TVMRunner

* refactor compileModel method

* small cleaning

* separate TVM EP options data store and processing

* replace TvmTensorShape by InlinedVector with max_size 5

* correct indentation

* update TVM hash

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
(cherry picked from commit 625a1f7)
Peter Salas (petersalas) pushed a commit to octoml/onnxruntime that referenced this pull request Nov 8, 2022
* rename info to options for TVM EP

* transfer options processing from TVMExecutionProvider to TVMEPOptions

* transfer TVMRunner to separated files

* implement TVMCompiler class

* replace CompileFunc by TVMCompiler object. update TVMRunner. now it does not depend on TvmExecutionProvider

* correct logging of TVM EP options

* RunnerImpl, GERunnerImpl and VMRunnerImpl were implemented

* add prepareComputeInfo method

* remove update_output_shapes flag

* embed all TVM EP dependences to tvm namespace. transfer model compilation from TVMRunner. connect TVMRunnerImpl to TVMRunner

* refactor compileModel method

* small cleaning

* separate TVM EP options data store and processing

* replace TvmTensorShape by InlinedVector with max_size 5

* correct indentation

* update TVM hash

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
(cherry picked from commit 625a1f7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants