Browse Source

rdiv binaryop

tags/20180704
nihui 8 years ago
parent
commit
30b6cc4ecd
2 changed files with 13 additions and 1 deletions
  1. +11
    -0
      src/layer/binaryop.cpp
  2. +2
    -1
      src/layer/binaryop.h

+ 11
- 0
src/layer/binaryop.cpp View File

@@ -396,6 +396,11 @@ struct binary_op_rsub : std::binary_function<T,T,T> {
T operator() (const T& x, const T& y) const { return y - x; }
};

template<typename T>
struct binary_op_rdiv : std::binary_function<T,T,T> {
T operator() (const T& x, const T& y) const { return y / x; }
};

int BinaryOp::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& top_blobs) const
{
const Mat& bottom_blob = bottom_blobs[0];
@@ -427,6 +432,9 @@ int BinaryOp::forward(const std::vector<Mat>& bottom_blobs, std::vector<Mat>& to
if (op_type == Operation_RSUB)
return binary_op< binary_op_rsub<float> >(bottom_blob, bottom_blob1, top_blob);

if (op_type == Operation_RDIV)
return binary_op< binary_op_rdiv<float> >(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<float> >(bottom_top_blob, b);

if (op_type == Operation_RDIV)
return binary_op_scalar_inplace< binary_op_rdiv<float> >(bottom_top_blob, b);

return 0;
}



+ 2
- 1
src/layer/binaryop.h View File

@@ -38,7 +38,8 @@ public:
Operation_MAX = 4,
Operation_MIN = 5,
Operation_POW = 6,
Operation_RSUB = 7
Operation_RSUB = 7,
Operation_RDIV = 8
};

public:


Loading…
Cancel
Save