You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

binaryop-broadcasting.md 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ### broadcasting rule
  2. ncnn BinaryOp accepts blobs with different shape
  3. C = BinaryOp(A, B)
  4. shape notation convention is [w], [w,h], [w,h,c], [w,h,d,c]
  5. * binaryop with scalar and scalar-like
  6. |type|A|B|C|
  7. |---|---|---|---|
  8. |0|[2]|scalar / [1]|[2]|
  9. |1|[2,3]|scalar / [1] / [1,1]|[2,3]|
  10. |2|[2,3,4]|scalar / [1] / [1,1] / [1,1,1]|[2,3,4]|
  11. |3|[2,3,4,5]|scalar / [1] / [1,1] / [1,1,1] / [1,1,1,1]|[2,3,4,5]|
  12. * no broadcast
  13. |type|A|B|C|
  14. |---|---|---|---|
  15. |4|[2]|[2]|[2]|
  16. |5|[2,3]|[2,3]|[2,3]|
  17. |6|[2,3,4]|[2,3,4]|[2,3,4]|
  18. |7|[2,3,4,5]|[2,3,4,5]|[2,3,4,5]|
  19. * broadcast B for inner axis
  20. |type|A|B|C|
  21. |---|---|---|---|
  22. |8|[2,3]|[3] / [1,3]|[2,3]|
  23. |9|[2,3,4]|[4] / [1,1,4]|[2,3,4]|
  24. |10|[2,3,4]|[3,4] / [1,3,4]|[2,3,4]|
  25. |11|[2,3,4,5]|[5] / [1,1,1,5]|[2,3,4,5]|
  26. |12|[2,3,4,5]|[4,5] / [1,1,4,5]|[2,3,4,5]|
  27. |13|[2,3,4,5]|[3,4,5] / [1,3,4,5]|[2,3,4,5]|
  28. * broadcast B for outer axis
  29. |type|A|B|C|
  30. |---|---|---|---|
  31. |14|[2,3]|[2,1]|[2,3]|
  32. |15|[2,3,4]|[2,1,1]|[2,3,4]|
  33. |16|[2,3,4]|[2,3,1]|[2,3,4]|
  34. |17|[2,3,4,5]|[2,1,1,1]|[2,3,4,5]|
  35. |18|[2,3,4,5]|[2,3,1,1]|[2,3,4,5]|
  36. |19|[2,3,4,5]|[2,3,4,1]|[2,3,4,5]|
  37. * some special broadcasting rule exists for model compatibility
  38. |special type|A|B|C|
  39. |---|---|---|---|
  40. |20|[2,3,4]|[2,1,4]|[2,3,4]|