-
Notifications
You must be signed in to change notification settings - Fork 82
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
[Layer] Remove Tensor setDataType() usage #2498
Conversation
📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2498. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://ci.nnstreamer.ai/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
In several layers, there are attempts to change the data type of a Tensor object after initializing it. This is currently possible but can cause issues down the line (e.g., treat FloatTensor object as HalfTensor). As such, the setDataType() method will be removed and considered not to be used in future updates. Instead, users will need to provide the desired data type when creating a new tensor. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong <[email protected]>
a477abe
to
044ba5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djeong20, 💯 All CI checkers are successfully verified. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this is quite important point.
I will keep this in mind in the future development of myself as well :)
Question: In a network, is the Tensor name required to be unique?
(I hope not..) |
Tensor empty; | ||
empty.setTensorType(weight_tensor_type); | ||
Tensor empty = | ||
Tensor("empty", weight_tensor_type.format, weight_tensor_type.data_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can set the format and data_type with weight_tensor_type. No need to set separately. Also, we do not need to set the tensor name always. I think when we create tensor like here, Tensor empty
, then it does not allocate the buffer. So.. I think it is ok to set the Tensor type here. The reason we set like this.. we do not want to allocate a buffer at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed offline, Tensor empty;
would create FloatTensor as a default.
nntrainer::Tensor t;
if (t.getDataType() == nntrainer::Tdatatype::FP32) {
// This would be executed
std::cout << "FP32" << std::endl;
} else {
std::cout << "FP16" << std::endl;
}
I will make an additional Tensor constructor that only takes data type without allocating a buffer (e.g., Tensor empty = Tensor(weight_tensor_type.data_type);
)
I don't think the name has to be unique. |
If this is for debugging and developer referencing, it's ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
In several layers, there are attempts to change the data type of a Tensor object after initializing it.
This is currently possible but can cause issues down the line (e.g., treat FloatTensor object as HalfTensor).
As such, the setDataType() method will be removed and considered not to be used in future updates.
Instead, users will need to provide the desired data type when creating a new tensor.
Self-evaluation: