Paddle assign_value OP 目前不支持 int64 和 float64 数据类型

uwopmtnx  于 2021-11-30  发布在  Java
关注(0)|答案(0)|浏览(311)
  • 版本、环境信息

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");
  }
};

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题