- 版本、环境信息
1)PaddlePaddle版本:1.5.1
2)CPU/GPU:CUDA 10.1, cuDNN 7.5
3)系统环境:Ubuntu 16.04
When using NumpyInitializer with array of dtype=int64 or float64, it reports unsupported data type. Because NumpyInitializer uses a assign_value OP to do the initialization. And only int32 and float32 are supported.
# Initialization Ops should be prepended and not appended
if out_dtype == VarDesc.VarType.FP32:
value_name = "fp32_values"
values = [float(v) for v in np_value.flat]
elif out_dtype == VarDesc.VarType.INT32:
value_name = "int32_values"
values = [int(v) for v in np_value.flat]
else:
raise ValueError("Unsupported dtype %s", self._value.dtype)
And I checked the C++ implementation of assign_value OP and tried to add int64 and float64 support. But, only int64 support was added successfully, float64 fails.
class AssignValueOpMaker : public framework::OpProtoAndCheckerMaker {
public:
void Make() override {
AddOutput("Out", "(Tensor) Output tensor of assign_value operator.");
AddAttr<std::vector<int>>("shape",
"(vector<int>) "
"Shape of values.");
AddAttr<int>("dtype", "data type of values")
.InEnum({framework::proto::VarType::INT32,
framework::proto::VarType::FP32});
AddAttr<std::vector<float>>("fp32_values", "store the float values")
.SetDefault({});
AddAttr<std::vector<int>>("int32_values", "store the int values")
.SetDefault({});
AddComment(R"DOC(
AssignValue operator
$$Out = values$$
)DOC");
}
};
暂无答案!
目前还没有任何答案,快来回答吧!