diff --git a/src/layer/binaryop.cpp b/src/layer/binaryop.cpp index 89ba43ec7..72108b81a 100644 --- a/src/layer/binaryop.cpp +++ b/src/layer/binaryop.cpp @@ -396,6 +396,11 @@ struct binary_op_rsub : std::binary_function { T operator() (const T& x, const T& y) const { return y - x; } }; +template +struct binary_op_rdiv : std::binary_function { + T operator() (const T& x, const T& y) const { return y / x; } +}; + int BinaryOp::forward(const std::vector& bottom_blobs, std::vector& top_blobs) const { const Mat& bottom_blob = bottom_blobs[0]; @@ -427,6 +432,9 @@ int BinaryOp::forward(const std::vector& bottom_blobs, std::vector& to if (op_type == Operation_RSUB) return binary_op< binary_op_rsub >(bottom_blob, bottom_blob1, top_blob); + if (op_type == Operation_RDIV) + return binary_op< binary_op_rdiv >(bottom_blob, bottom_blob1, top_blob); + return 0; } @@ -456,6 +464,9 @@ int BinaryOp::forward_inplace(Mat& bottom_top_blob) const if (op_type == Operation_RSUB) return binary_op_scalar_inplace< binary_op_rsub >(bottom_top_blob, b); + if (op_type == Operation_RDIV) + return binary_op_scalar_inplace< binary_op_rdiv >(bottom_top_blob, b); + return 0; } diff --git a/src/layer/binaryop.h b/src/layer/binaryop.h index ac486886e..8affa7c35 100644 --- a/src/layer/binaryop.h +++ b/src/layer/binaryop.h @@ -38,7 +38,8 @@ public: Operation_MAX = 4, Operation_MIN = 5, Operation_POW = 6, - Operation_RSUB = 7 + Operation_RSUB = 7, + Operation_RDIV = 8 }; public: