CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[Paddle Tensorrt] add pd_op.tanh marker and converter #68614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件不需要了,你可以看到test_converter_math.py的self.check_trt_result()已经会检测Marker了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
python/paddle/tensorrt/impls/math.py
Outdated
@@ -118,3 +118,9 @@ def multiply_converter(network, paddle_op, inputs): | |||
return add_elementwise_layer( | |||
network, paddle_op, inputs, trt.ElementWiseOperation.PROD | |||
) | |||
|
|||
|
|||
@converter_registry.register("pd_op.tanh", trt_version="8.x") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这类converter,不适合每个都写一遍吧,最好是写一个通用的类
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (dims < 1) { | ||
VLOG(3) << "Tanh op does not support 0 dim input when TensorRT < 8.6."; | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
少加了一个#endif
def activation_converter(network, type, inputs): | ||
if type == "pd_op.tanh": | ||
layer = network.add_activation(inputs[0], trt.ActivationType.TANH) | ||
elif type == "pd_op.relu": | ||
layer = network.add_activation(inputs[0], trt.ActivationType.RELU) | ||
elif type == "pd_op.sigmoid": | ||
layer = network.add_activation(inputs[0], trt.ActivationType.SIGMOID) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里有必要进行判断吗,不能直接将type替换trt.ActivationType.xxx吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
得判断,这是一个公共类啊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数直接传入trt.ActivationType.xxx不可以吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也可以,下个pr让他修改下吧
def activation_converter(network, paddle_op, inputs): | ||
return activation_map[paddle_op.name()](network, inputs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个写法依然没有简化,你需要这样写:
def activation_converter(network, paddle_op, inputs):
layer = network.add_activation(inputs[0], activation_type_map[paddle_op.name()])
return layer.get_output(0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
PR Category
Inference
PR Types
New features
Description
card-71500
添加tanh op 的marker、converter和单测