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

assign_value operator #7371

Merged
merged 4 commits into from
Jan 12, 2018
Merged

Conversation

emailweixu
Copy link
Collaborator

We need this operator to assign value to a tensor and the values are stored in the program so that they can be used independent of python.

}

protected:
framework::OpKernelType GetActualKernelType(
Copy link
Collaborator

@JiayiFeng JiayiFeng Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function name should be GetExpectedKernelType.

Related doc: https://github.com/PaddlePaddle/Paddle/blob/develop/doc/design/kernel_hint_design.md#final-choice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.
The interface changed before I submitted the PR.

framework::proto::DataType::FP32});
AddAttr<std::vector<float>>("fp32_values", "store the float values")
.SetDefault({});
AddAttr<std::vector<int>>("int32_values", "store the int values")
Copy link
Collaborator

@JiayiFeng JiayiFeng Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Op's attribute will be stored into the protobuf. However, the size of a protobuf object is limited(64M). I'm afraid there might be some problems if the tensor to be assigned is huge.

An alternative way is writing the tensor values to a file in Python, then the assign_value_op read the file and fill them into output variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If the arry is too big, we may have to use a separate file. But if many cases where only a small matrix is used, it's quite inconvenient to use a separate file to array the matrix.

break;
}
auto values = ctx.Attr<std::vector<T>>(value_name);
Copy(dst, values.data(), sizeof(T) * values.size(), ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

xuwei06 added 4 commits January 11, 2018 12:53
We need this operator to assign value to a tensor and the values are stored in the program so that they can be used independent of python.
Copy link
Collaborator

@JiayiFeng JiayiFeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@emailweixu emailweixu merged commit d954bec into PaddlePaddle:develop Jan 12, 2018
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

Successfully merging this pull request may close these issues.

3 participants