Skip to content
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

How to set the default value of a std::vector<int> attribute #4077

Closed
Xreki opened this issue Sep 13, 2017 · 2 comments
Closed

How to set the default value of a std::vector<int> attribute #4077

Xreki opened this issue Sep 13, 2017 · 2 comments

Comments

@Xreki
Copy link
Contributor

Xreki commented Sep 13, 2017

In some operators, we may need attributes of which the type is std::vector<int>. We can define them in C++ code as follows:

    AddAttr<std::vector<int>>("xNumColDims", "Some comments");
    AddAttr<std::vector<int>>( "wNumColDims", "Some comments");

So, the problem is: we don't know the length in advance, "how to set the default value".

@Yancey1989
Copy link
Contributor

Maybe we can just set an empty vector as the default value:

AddAttr<std::vector<int>>("xNumColDims", "Some comments").SetDefault(std::vector<int>{})

And call vector::reserve() in Kernel Code.

@Xreki
Copy link
Contributor Author

Xreki commented Sep 14, 2017

@Yancey1989 It works. Thanks.

@Xreki Xreki closed this as completed Sep 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants