Skip to content

Commit

Permalink
Some documentation updates. (microsoft#3060)
Browse files Browse the repository at this point in the history
skottmckay authored Feb 21, 2020
1 parent c033cfe commit 932ecae
Showing 4 changed files with 37 additions and 5 deletions.
26 changes: 26 additions & 0 deletions ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
@@ -3821,3 +3821,29 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----

dcleblanc/SafeInt

MIT License

Copyright (c) 2018 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 6 additions & 3 deletions docs/Coding_Conventions_and_Standards.md
Original file line number Diff line number Diff line change
@@ -27,9 +27,12 @@ Other
* Don't overuse std::shared\_ptr. Use std::shared\_ptr only if it's not clear when and where the object will be deallocated. See also: [https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-shared_ptr)
* Avoid using the 'long' type, which could be either 32 bits or 64 bits.
* If there is a legitimate need to allocate objects on the heap, prefer using onnxruntime::make_unique(). References for the reasoning:
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-make_unique
* https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/
* https://abseil.io/tips/126
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-make_unique
* https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/
* https://abseil.io/tips/126
* Use [SafeInt](https://github.com/dcleblanc/SafeInt) when calculating the size of memory to allocate to protect against overflow errors
* `#include "core/common/safeint.h"`
* search for `SafeInt<size_t>` in the code for examples

#### Clang-format

3 changes: 3 additions & 0 deletions include/onnxruntime/core/framework/allocator.h
Original file line number Diff line number Diff line change
@@ -153,6 +153,9 @@ using IAllocatorUniquePtr = std::unique_ptr<T, std::function<void(T*)>>;
class IAllocator {
public:
virtual ~IAllocator() = default;
/**
@remarks Use SafeInt when calculating the size of memory to allocate using Alloc.
*/
virtual void* Alloc(size_t size) = 0;
virtual void Free(void* p) = 0;
virtual const OrtMemoryInfo& Info() const = 0;
4 changes: 2 additions & 2 deletions include/onnxruntime/core/framework/op_kernel.h
Original file line number Diff line number Diff line change
@@ -133,8 +133,8 @@ class OpKernelContext {
}

/**
* return an allocator on device 0, with memtype of OrtMemTypeDefault
*
Return an allocator on device 0, with memtype of OrtMemTypeDefault.
@remarks Use SafeInt when calculating the size of memory to allocate using AllocatorPtr->Alloc.
*/
Status GetTempSpaceAllocator(AllocatorPtr* output) const;

0 comments on commit 932ecae

Please sign in to comment.