-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[phi] move viterbi_decode to phi #40186
Conversation
Thanks for your contribution! |
paddle/phi/infermeta/multiary.cc
Outdated
@@ -186,6 +186,53 @@ void BilinearTensorProductInferMeta(const MetaTensor& x, | |||
out->set_dtype(x.dtype()); | |||
} | |||
|
|||
void ViterbiDecodeInferMeta(const MetaTensor& input, |
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.
这里有三个tensor参数?是不是应该属于ternary.h/cc
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, thx
namespace funcs { | ||
|
||
template <typename Context, typename T> | ||
inline void TransCompute(const int dim, |
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.
这个有没有可能直接用transpose_kernel.h中的Transpose替代,避免重复封装
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, thx
} | ||
} | ||
|
||
class TensorBuffer { |
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.
这种在内部封装类似Tensor的结构是应该避免的,我们后续优化下这个算子
#include <string> | ||
#include <vector> | ||
|
||
#include "paddle/fluid/operators/elementwise/elementwise_op_function.h" |
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.
这里LaunchElementwiseCudaKernel需要用到
#ifdef PADDLE_WITH_MKLML | ||
#include <omp.h> | ||
#endif |
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.
我看到funcs/viterbi_decode_functor.h下也用到了这个头文件的内容,这个头文件引用是否放在那个文件里更合适一点?
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, thx
DenseTensor int_buffer; | ||
int_buffer.Resize(phi::make_ddim({buffer_size})); | ||
dev_ctx.template Alloc<int64_t>(&int_buffer); |
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.
这种写法可以试试使用 int_buffer = Empty<int64_t>(dev_ctx, {buffer_size});
, 写起来会简单一些
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, thx
DenseTensor float_buffer; | ||
float_buffer.Resize(phi::make_ddim({buffer_size})); | ||
dev_ctx.template Alloc<T>(&float_buffer); |
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.
done, thx
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.
LGTM
PR types
Function optimization
PR changes
OPs
Describe
move viterbi_decode to phi