-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Variable Structure Definition #2545
Comments
Blob of caffe2DescriptionBlob is a general container that hosts a typed pointer. A Blob hosts a pointer as well as its type, and takes charge of deleting it properly when the blob is deallocated or re-allocated with a new type. A blob could contain anything, although the most common case is to contain a Tensor. Key interfaces
ReferencePlease go to https://caffe2.ai/doxygen-c/html/classcaffe2_1_1Blob.html for detailed description. |
Define the |
Discussion about Input parameters:
Difference about
Implementation of template <class T>
T* Reset(T* allocated) { // notice the return type, doesn't need meta data
if (pointer_ && destroy_) {
destroy_(pointer_);
}
meta_ = TypeMeta::Make<T>(); // construct meta data
pointer_ = static_cast<void*>(allocated);
destroy_ = &Destroy<T>; // hold the destroy function
return allocated;
} void* ShareExternal(void* allocated, const TypeMeta& meta) { // return void* and need meta data
if (pointer_ && destroy_) {
destroy_(pointer_);
}
meta_ = meta;
pointer_ = static_cast<void*>(allocated);
destroy_ = nullptr; // doesn't hold the destroy function
return allocated;
} Calling snippet code: Calling std::string* pvec = new std::string();
myblob.Reset(pvec); // no need to release pvec, myblob takes ownership. Calling // Note(jiayq): This removes a const but conceptually
// local_input_blobs will only be used as const blob input for the
// base op so we are still fine.
local_input_blobs_[i]->ShareExternal(
const_cast<void*>(OperatorBase::Inputs()[i]->GetRaw()),
OperatorBase::Inputs()[i]->meta()); |
According to the previous comment, here to discuss the type of
For the first and second points, in the |
|
close by #2587 |
Discuss the definition of variable structure
The text was updated successfully, but these errors were encountered: