You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/06/15 01:11:45 UTC

[GitHub] [tvm] mehrdadh opened a new pull request #8259: [Graph Debug Executor] Fix device_type for profile command

mehrdadh opened a new pull request #8259:
URL: https://github.com/apache/tvm/pull/8259


   This PR:
   - Fixes issue with converting `device_type` to `device name` for profile command
   - Adds a test in test_crt for micro device to catch errors with profile command
   
   cc @areusch 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] mehrdadh commented on pull request #8259: [Graph Debug Executor] Fix device_type for profile command

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on pull request #8259:
URL: https://github.com/apache/tvm/pull/8259#issuecomment-861097892


   https://github.com/apache/tvm/issues/8255


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] mehrdadh commented on pull request #8259: [Graph Debug Executor] Fix device_type for profile command

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on pull request #8259:
URL: https://github.com/apache/tvm/pull/8259#issuecomment-868728472


   Here is a trackeback on this error. When I run the `test_debug_graph_executor_profile` test that I added in this PR, I get this error:
   ```
   enabled targets: llvm -device=arm_cpu; llvm
   pytest marker:
   ================================================================ test session starts =================================================================
   platform linux -- Python 3.6.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
   rootdir: /workspace, configfile: pytest.ini
   plugins: forked-1.3.0, xdist-2.2.1, profiling-1.7.0
   collected 7 items / 6 deselected / 1 selected
   tests/python/unittest/test_crt.py F                                                                                                            [100%]
   ====================================================================== FAILURES ======================================================================
   _________________________________________________________ test_debug_graph_executor_profile __________________________________________________________
       @tvm.testing.requires_micro
       def test_debug_graph_executor_profile():
           """Test use of the graph debug executor profile operation with microTVM."""
           import tvm.micro
           workspace = tvm.micro.Workspace(debug=True)
           relay_mod = tvm.parser.fromtext(
               """
             #[version = "0.0.5"]
             def @main(%a : Tensor[(1, 2), uint8], %b : Tensor[(1, 2), uint8]) {
                 %0 = %a + %b;
                 %0
             }"""
           )
           with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
               factory = tvm.relay.build(relay_mod, target=TARGET)
           with _make_session(workspace, factory.get_lib()) as sess:
               debug_g_mod = tvm.micro.create_local_debug_executor(
                   factory.get_graph_json(), sess.get_system_lib(), sess.device
               )
               A_data = tvm.nd.array(np.array([2, 3], dtype="uint8"), device=sess.device)
               B_data = tvm.nd.array(np.array([4, 7], dtype="uint8"), device=sess.device)
               input_dict = {"a": A_data, "b": B_data}
   >           timing_results = debug_g_mod.profile(**input_dict).csv()
   tests/python/unittest/test_crt.py:200:
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
   python/tvm/contrib/debugger/debug_executor.py:287: in profile
       return self._profile()
   tvm/_ffi/_cython/./packed_func.pxi:323: in tvm._ffi._cy3.core.PackedFuncBase.__call__
       ???
   tvm/_ffi/_cython/./packed_func.pxi:257: in tvm._ffi._cy3.core.FuncCall
       ???
   tvm/_ffi/_cython/./packed_func.pxi:246: in tvm._ffi._cy3.core.FuncCall3
       ???
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
   >   ???
   E   tvm._ffi.base.TVMError: Traceback (most recent call last):
   E     12: TVMFuncCall
   E           at /workspace/src/runtime/c_runtime_api.cc:474
   E     11: tvm::runtime::PackedFunc::CallPacked(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
   E           at /workspace/include/tvm/runtime/packed_func.h:1151
   E     10: std::function<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator()(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const
   E           at /usr/include/c++/7/bits/std_function.h:706
   E     9: _M_invoke
   E           at /usr/include/c++/7/bits/std_function.h:316
   E     8: operator()
   E           at /workspace/include/tvm/runtime/packed_func.h:1492
   E     7: unpack_call<tvm::runtime::profiling::Report, 0, tvm::runtime::GraphExecutorDebug::GetFunction(const string&, const tvm::runtime::ObjectPtr<t>
   E           at /workspace/include/tvm/runtime/packed_func.h:1421
   E     6: run<>
   E           at /workspace/include/tvm/runtime/packed_func.h:1397
   E     5: operator()
   E           at /workspace/src/runtime/graph_executor/debug/graph_executor_debug.cc:370
   E     4: tvm::runtime::GraphExecutorDebug::Profile()
   E           at /workspace/src/runtime/graph_executor/debug/graph_executor_debug.cc:294
   E     3: tvm::runtime::profiling::Profiler::Start(std::vector<DLDevice, std::allocator<DLDevice> > const&)
   E           at /workspace/src/runtime/profiling.cc:106
   E     2: tvm::runtime::Timer::Start(DLDevice)
   E           at /workspace/src/runtime/profiling.cc:87
   E     1: tvm::runtime::DeviceName(int)
   E           at /workspace/include/tvm/runtime/object.h:383
   E     0: tvm::runtime::DeviceName(int)
   E           at /workspace/include/tvm/runtime/device_api.h:263
   E     File "/workspace/include/tvm/runtime/device_api.h", line 263
   E   TVMError: unknown type =129
   tvm/_ffi/_cython/./base.pxi:163: TVMError
   ```
   and the `sess.device` is equal to `remote[0]:cpu(0)`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] mehrdadh commented on pull request #8259: [Graph Debug Executor] Fix device_type for profile command

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on pull request #8259:
URL: https://github.com/apache/tvm/pull/8259#issuecomment-868834151


   since profile is not supported for remote devices, we added an exception for remote devices for now, until we fix it.
   https://github.com/apache/tvm/pull/8345
   I change this to draft until we find a solution.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] tkonolige commented on a change in pull request #8259: [Graph Debug Executor] Fix device_type for profile command

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #8259:
URL: https://github.com/apache/tvm/pull/8259#discussion_r652128115



##########
File path: src/runtime/graph_executor/debug/graph_executor_debug.cc
##########
@@ -300,7 +306,8 @@ class GraphExecutorDebug : public GraphExecutor {
         }
 
         uint32_t eid = entry_id(i, 0);
-        const Device& dev = data_entry_[eid]->device;
+        Device dev = data_entry_[eid]->device;
+        dev.device_type = static_cast<DLDeviceType>(dev.device_type % kRPCSessMask);

Review comment:
       I don't think the device type should be changed within the profiling call. Instead, you should set the device type when the graph executor is created.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] mehrdadh closed pull request #8259: [Graph Debug Executor] Fix device_type for profile command

Posted by GitBox <gi...@apache.org>.
mehrdadh closed pull request #8259:
URL: https://github.com/apache/tvm/pull/8259


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [tvm] mehrdadh commented on a change in pull request #8259: [Graph Debug Executor] Fix device_type for profile command

Posted by GitBox <gi...@apache.org>.
mehrdadh commented on a change in pull request #8259:
URL: https://github.com/apache/tvm/pull/8259#discussion_r654012924



##########
File path: src/runtime/graph_executor/debug/graph_executor_debug.cc
##########
@@ -300,7 +306,8 @@ class GraphExecutorDebug : public GraphExecutor {
         }
 
         uint32_t eid = entry_id(i, 0);
-        const Device& dev = data_entry_[eid]->device;
+        Device dev = data_entry_[eid]->device;
+        dev.device_type = static_cast<DLDeviceType>(dev.device_type % kRPCSessMask);

Review comment:
       So the reason that I did this way is that [RPC client](https://github.com/apache/tvm/blob/1c251f50ee616507bdfd8866408e7acf9888cc3f/python/tvm/rpc/client.py#L75) adds an encoding to device type which we need to decode somehow when is used in graph_executor_debugger. I'm not sure if this is the best place to remove encoding.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org