未验证 提交 a9fdbbf6 编写于 作者: W wangguanzhong 提交者: GitHub

fix ext_op (#714)

上级 a65bf31e
...@@ -59,12 +59,9 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`python -c 'import paddle; print(paddle. ...@@ -59,12 +59,9 @@ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`python -c 'import paddle; print(paddle.
执行下列单测,确保自定义算子可在网络中正确使用: 执行下列单测,确保自定义算子可在网络中正确使用:
``` ```
# 回到 ext_op 目录,添加 PYTHONPATH # 回到 ext_op 目录,运行单测
cd .. cd ..
export PYTHONPATH=$PYTHONPATH:`pwd` python test/test_corner_pool.py
# 运行单测
python test/test_corner_op.py
``` ```
单测运行成功会输出提示信息,如下所示: 单测运行成功会输出提示信息,如下所示:
......
...@@ -17,7 +17,14 @@ from __future__ import print_function ...@@ -17,7 +17,14 @@ from __future__ import print_function
import unittest import unittest
import numpy as np import numpy as np
import paddle.fluid as fluid import paddle.fluid as fluid
import cornerpool_lib import os
import sys
# add python path of PadleDetection to sys.path
parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 4)))
if parent_path not in sys.path:
sys.path.append(parent_path)
from ppdet.ext_op import cornerpool_lib
def bottom_pool_np(x): def bottom_pool_np(x):
...@@ -83,11 +90,7 @@ class TestRightPoolOp(unittest.TestCase): ...@@ -83,11 +90,7 @@ class TestRightPoolOp(unittest.TestCase):
place = fluid.CUDAPlace(0) place = fluid.CUDAPlace(0)
with fluid.program_guard(tp, sp): with fluid.program_guard(tp, sp):
x = fluid.data( x = fluid.data(name=self.name, shape=x_shape, dtype=x_type)
name=self.name,
shape=x_shape,
dtype=x_type,
append_batch_size=False)
y = self.func_map[self.name][0](x) y = self.func_map[self.name][0](x)
np.random.seed(0) np.random.seed(0)
......
...@@ -243,11 +243,6 @@ class CornerHead(object): ...@@ -243,11 +243,6 @@ class CornerHead(object):
ae_threshold=1, ae_threshold=1,
num_dets=1000, num_dets=1000,
top_k=100): top_k=100):
try:
import cornerpool_lib
except:
logger.error(
"cornerpool_lib not found, compile in ppdet/ext_op at first")
self.train_batch_size = train_batch_size self.train_batch_size = train_batch_size
self.test_batch_size = test_batch_size self.test_batch_size = test_batch_size
self.num_classes = num_classes self.num_classes = num_classes
...@@ -279,6 +274,11 @@ class CornerHead(object): ...@@ -279,6 +274,11 @@ class CornerHead(object):
return conv1 return conv1
def get_output(self, input): def get_output(self, input):
try:
from ppdet.ext_op import cornerpool_lib
except:
logger.error(
"cornerpool_lib not found, compile in ppdet/ext_op at first")
for ind in range(self.stack): for ind in range(self.stack):
cnv = input[ind] cnv = input[ind]
tl_modules = corner_pool( tl_modules = corner_pool(
...@@ -455,6 +455,11 @@ class CornerHead(object): ...@@ -455,6 +455,11 @@ class CornerHead(object):
return {'loss': loss} return {'loss': loss}
def get_prediction(self, input): def get_prediction(self, input):
try:
from ppdet.ext_op import cornerpool_lib
except:
logger.error(
"cornerpool_lib not found, compile in ppdet/ext_op at first")
ind = self.stack - 1 ind = self.stack - 1
tl_modules = corner_pool( tl_modules = corner_pool(
input, input,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册