未验证 提交 5728dffb 编写于 作者: C Chen Weihang 提交者: GitHub

fix assign typo (#41005)

上级 55f9b71a
......@@ -27,7 +27,7 @@ namespace operators {
using Tensor = framework::Tensor;
template <typename T>
typename std::enable_if<std::is_same<T, bool>::value>::type CopyVecotorToTensor(
typename std::enable_if<std::is_same<T, bool>::value>::type CopyVectorToTensor(
const char* value_name, framework::Tensor* out,
const framework::ExecutionContext& ctx) {
// If attribute value dtype is vector<bool>, it will be converted to
......@@ -48,9 +48,9 @@ typename std::enable_if<std::is_same<T, bool>::value>::type CopyVecotorToTensor(
}
template <typename T>
typename std::enable_if<!std::is_same<T, bool>::value>::type
CopyVecotorToTensor(const char* value_name, framework::Tensor* out,
const framework::ExecutionContext& ctx) {
typename std::enable_if<!std::is_same<T, bool>::value>::type CopyVectorToTensor(
const char* value_name, framework::Tensor* out,
const framework::ExecutionContext& ctx) {
auto values = ctx.Attr<std::vector<T>>(value_name);
framework::TensorFromVector(values, ctx.device_context(), out);
}
......@@ -83,7 +83,7 @@ class AssignValueKernel : public framework::OpKernel<T> {
dtype));
break;
}
CopyVecotorToTensor<T>(value_name, out, ctx);
CopyVectorToTensor<T>(value_name, out, ctx);
out->Resize(phi::make_ddim(shape));
}
};
......
......@@ -157,7 +157,7 @@ void SetValueCompute(const framework::ExecutionContext& ctx,
value_t.mutable_data<T>(value_dims, place);
auto value_name = GetValueName(dtype);
CopyVecotorToTensor<T>(value_name.c_str(), &value_t, ctx);
CopyVectorToTensor<T>(value_name.c_str(), &value_t, ctx);
value_t.Resize(value_dims);
ElementwiseComputeEx<SubFunctor<T>, DeviceContext, T>(
ctx, &slice_tensor, &value_t, -1, SubFunctor<T>(), &slice_tensor);
......
......@@ -141,7 +141,7 @@ class SetValueNPUKernel : public framework::OpKernel<T> {
value_t.mutable_data<T>(value_dims, ctx.GetPlace());
auto value_name =
GetValueName(framework::TransToProtoVarType(in->dtype()));
CopyVecotorToTensor<T>(value_name.c_str(), &value_t, ctx);
CopyVectorToTensor<T>(value_name.c_str(), &value_t, ctx);
value_t.Resize(value_dims);
}
......
......@@ -47,7 +47,7 @@ void AssignArrayKernel(const Context& dev_ctx,
}
template <typename T, typename Context>
typename std::enable_if<std::is_same<T, bool>::value>::type CopyVecotorToTensor(
typename std::enable_if<std::is_same<T, bool>::value>::type CopyVectorToTensor(
const Context& dev_ctx,
const std::vector<Scalar>& values,
DenseTensor* out) {
......@@ -72,10 +72,10 @@ typename std::enable_if<std::is_same<T, bool>::value>::type CopyVecotorToTensor(
}
template <typename T, typename Context>
typename std::enable_if<!std::is_same<T, bool>::value>::type
CopyVecotorToTensor(const Context& dev_ctx,
const std::vector<Scalar>& values,
DenseTensor* out) {
typename std::enable_if<!std::is_same<T, bool>::value>::type CopyVectorToTensor(
const Context& dev_ctx,
const std::vector<Scalar>& values,
DenseTensor* out) {
std::vector<T> assign_values;
assign_values.reserve(values.size());
for (const auto& val : values) {
......@@ -98,7 +98,7 @@ void AssignValueKernel(const Context& dev_ctx,
"argument dtype is %s, kernel dtype is %s.",
dtype,
template_dtype));
CopyVecotorToTensor<T>(dev_ctx, values, out);
CopyVectorToTensor<T>(dev_ctx, values, out);
out->Resize(phi::make_ddim(shape));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册