Commit f52f82f6 by Ting PAN

Fix the potential crash on L2NormOp

1 parent 904b59fd
...@@ -36,7 +36,7 @@ find_packages('dragon') ...@@ -36,7 +36,7 @@ find_packages('dragon')
find_modules() find_modules()
setup(name = 'dragon', setup(name = 'dragon',
version='0.2.1.4', version='0.2.1.5',
description = 'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework', description = 'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework',
url='https://github.com/neopenx/Dragon', url='https://github.com/neopenx/Dragon',
author='Ting Pan', author='Ting Pan',
......
...@@ -104,7 +104,7 @@ void ProposalOp<Context>::RunWithType() { ...@@ -104,7 +104,7 @@ void ProposalOp<Context>::RunWithType() {
// distribute rois into K bins // distribute rois into K bins
if (OutputSize() > 1) { if (OutputSize() > 1) {
CHECK_EQ(max_level - min_level + 1, (int)OutputSize()) CHECK_EQ(max_level - min_level + 1, (int)OutputSize())
<< "Excepted " << OutputSize() << " outputs for levels between " << "\nExcepted " << OutputSize() << " outputs for levels between "
<< "[" << min_level << ", " << max_level << "]."; << "[" << min_level << ", " << max_level << "].";
vector< vector<TIndex> > roi_bins(OutputSize(), vector<TIndex>()); vector< vector<TIndex> > roi_bins(OutputSize(), vector<TIndex>());
vector<T*> outputs; vector<T*> outputs;
...@@ -130,7 +130,7 @@ template <class Context> ...@@ -130,7 +130,7 @@ template <class Context>
void ProposalOp<Context>::RunOnDevice() { void ProposalOp<Context>::RunOnDevice() {
num_images = input(0).dim(0); num_images = input(0).dim(0);
CHECK_EQ(input(-1).count(), num_images * 3) CHECK_EQ(input(-1).count(), num_images * 3)
<< "Excepted " << num_images * 3 << " groups image info, " << "\nExcepted " << num_images * 3 << " groups image info, "
<< "but got " << input(-1).count() / 3 << "."; << "but got " << input(-1).count() / 3 << ".";
roi_indices_.Reshape(vector<TIndex>(1, post_nms_top_n)); roi_indices_.Reshape(vector<TIndex>(1, post_nms_top_n));
output(0)->Reshape(vector<TIndex>({ num_images * post_nms_top_n, 5 })); output(0)->Reshape(vector<TIndex>({ num_images * post_nms_top_n, 5 }));
......
...@@ -42,4 +42,4 @@ class ProposalOp final : public Operator<Context> { ...@@ -42,4 +42,4 @@ class ProposalOp final : public Operator<Context> {
} // namespace dragon } // namespace dragon
#endif // DRAGON_OPERATORS_CONTRIB_RCNN_PROPOSAL_OP_H_ #endif // DRAGON_CONTRIB_RCNN_PROPOSAL_OP_H_
\ No newline at end of file \ No newline at end of file
...@@ -25,6 +25,7 @@ void L2NormOp<Context>::RunWithType() { ...@@ -25,6 +25,7 @@ void L2NormOp<Context>::RunWithType() {
auto* Ydata = output(0)->template mutable_data<T, Context>(); auto* Ydata = output(0)->template mutable_data<T, Context>();
auto* Bdata = buffer->template mutable_data<T, Context>(); auto* Bdata = buffer->template mutable_data<T, Context>();
auto* Ndata = norm->template mutable_data<T, Context>(); auto* Ndata = norm->template mutable_data<T, Context>();
math::Set<T, Context>(norm->count(), dragon_cast<T, float>(eps), Ndata);
for (int n = 0; n < outer_dim; n++) { for (int n = 0; n < outer_dim; n++) {
if (across_inner) { if (across_inner) {
...@@ -34,7 +35,6 @@ void L2NormOp<Context>::RunWithType() { ...@@ -34,7 +35,6 @@ void L2NormOp<Context>::RunWithType() {
Ndata_[n] = pow(sum_of_sqr + eps, 0.5); Ndata_[n] = pow(sum_of_sqr + eps, 0.5);
math::Scale<T, Context>(buffer->count(), 1.0 / Ndata_[n], Xdata, Ydata); math::Scale<T, Context>(buffer->count(), 1.0 / Ndata_[n], Xdata, Ydata);
} else { } else {
math::Set<T, Context>(norm->count(), dragon_cast<T, float>(eps), Ndata);
math::Square<T, Context>(buffer->count(), Xdata, Bdata); math::Square<T, Context>(buffer->count(), Xdata, Bdata);
// compute T1 = \sum_{i} x_{i,j}^{2} // compute T1 = \sum_{i} x_{i,j}^{2}
math::Gemv<T, Context>(CblasTrans, dim, inner_dim, math::Gemv<T, Context>(CblasTrans, dim, inner_dim,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!