- ### broadcasting rule
-
- ncnn BinaryOp accepts blobs with different shape
-
- C = BinaryOp(A, B)
-
- shape notation convention is [w], [w,h], [w,h,c], [w,h,d,c]
-
- * binaryop with scalar and scalar-like
-
- |type|A|B|C|
- |---|---|---|---|
- |0|[2]|scalar / [1]|[2]|
- |1|[2,3]|scalar / [1] / [1,1]|[2,3]|
- |2|[2,3,4]|scalar / [1] / [1,1] / [1,1,1]|[2,3,4]|
- |3|[2,3,4,5]|scalar / [1] / [1,1] / [1,1,1] / [1,1,1,1]|[2,3,4,5]|
-
- * no broadcast
-
- |type|A|B|C|
- |---|---|---|---|
- |4|[2]|[2]|[2]|
- |5|[2,3]|[2,3]|[2,3]|
- |6|[2,3,4]|[2,3,4]|[2,3,4]|
- |7|[2,3,4,5]|[2,3,4,5]|[2,3,4,5]|
-
- * broadcast B for inner axis
-
- |type|A|B|C|
- |---|---|---|---|
- |8|[2,3]|[3] / [1,3]|[2,3]|
- |9|[2,3,4]|[4] / [1,1,4]|[2,3,4]|
- |10|[2,3,4]|[3,4] / [1,3,4]|[2,3,4]|
- |11|[2,3,4,5]|[5] / [1,1,1,5]|[2,3,4,5]|
- |12|[2,3,4,5]|[4,5] / [1,1,4,5]|[2,3,4,5]|
- |13|[2,3,4,5]|[3,4,5] / [1,3,4,5]|[2,3,4,5]|
-
- * broadcast B for outer axis
-
- |type|A|B|C|
- |---|---|---|---|
- |14|[2,3]|[2,1]|[2,3]|
- |15|[2,3,4]|[2,1,1]|[2,3,4]|
- |16|[2,3,4]|[2,3,1]|[2,3,4]|
- |17|[2,3,4,5]|[2,1,1,1]|[2,3,4,5]|
- |18|[2,3,4,5]|[2,3,1,1]|[2,3,4,5]|
- |19|[2,3,4,5]|[2,3,4,1]|[2,3,4,5]|
-
- * some special broadcasting rule exists for model compatibility
-
- |special type|A|B|C|
- |---|---|---|---|
- |20|[2,3,4]|[2,1,4]|[2,3,4]|
|