question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[RFC][PASS][RUNTIME] Enable Slice on LHS during concat

See original GitHub issue

This was mentioned in https://github.com/dmlc/tvm/issues/2122#issuecomment-439581161; I also asked about it here a while back.

Basically I’d like to implement a compiler pass that replaces concat operations with simple slicing operations, where:

out[0:1] = concat(f1(), f2())

is replaced with

out[0] = f1()
out[1] = f2()

This can provide large improvements in some cases, e.g. DenseNet, which goes from having O(n^2) memory copies to having O(n) memory copies. It also reduces memory requirements in low-memory deployment scenarios. It can be implemented by partially specializing compute kernels over data size.

I’d like to implement this pass (partly just to get more used to working inside TVM), but I’m not exactly sure where in the stack this should go. It’s somewhat backend-dependent, and AFAICT Relay can’t really represent slicing in this way (although I might be wrong). Maybe a pass can be added that annotates data-movement operations, and backends can consume those annotations?

A place to start might be just implementing this in the graph runtime. If someone could provide some guidance that would be helpful ( @tqchen ?)

cc @areusch

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
tqchencommented, Apr 5, 2019

What I mean is that runtime need to be aware of the memory layout and provide out[slice] = f(inputs). Another possible “obstacle” is that TVM’s compute kernel requires the buffer to be somewhat aligned, and we need to generate a special kernel for out[slice] = f(inputs), with a known offset(so we still benefit from good alignment). This is necessary for OpenCL

1reaction
tqchencommented, Apr 6, 2019

I have not yet put very deep thoughts how can we generate annotation, this is something that worth some thoughts and discussion

Read more comments on GitHub >

github_iconTop Results From Across the Web

arrays - Could someone explain the example below regarding ...
You are slicing the first <index> items and the last <index-1> items, then merging them together into one array. The item in the...
Read more >
Operation Semantics | XLA - TensorFlow
Effectively, we slice each lhs batch into batch_group_count groups, and do the same for the output features. Then, for each of these groups ......
Read more >
Concat in std::slice - Rust
Helper trait for [T]::concat . Note: the Item type parameter is not used in this trait, but it allows impls to be more...
Read more >
Array.prototype.slice() - JavaScript - MDN Web Docs
Both include a reference to the object myHonda . When the color of myHonda is changed to purple, both arrays reflect the change....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found