Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Device Resident Tensors - API & Framework (#3745)
Summary: Taking over #3671, but spinning out the API and Glow-core level changes associated with the DRT plan in #3629. This does not implement DRT support on any device. Documentation: See #3629. Pull Request resolved: #3745 Test Plan: Ran tests, added two simple new sanity checks to DeviceManagerTest. The first `DeviceResidentTensors` should run only for backends that support resident tensors (none currently). The second `CanHandleDeviceResidentTensors` should run on all devices. Differential Revision: D18378905 Pulled By: nickgg fbshipit-source-id: 887c290dae5a6b9b75e9b41a415958d499bc5402
- Loading branch information
1 parent
ec46f24
commit eb48b31
Showing
21 changed files
with
464 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (c) Glow Contributors. See CONTRIBUTORS file. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef GLOW_BASE_DEVICETENSORTRANSFERMANAGER_H | ||
#define GLOW_BASE_DEVICETENSORTRANSFERMANAGER_H | ||
|
||
#include "glow/Base/Tensor.h" | ||
#include "glow/Support/Error.h" | ||
|
||
#include <functional> | ||
|
||
namespace glow { | ||
|
||
class Tensor; | ||
|
||
class DeviceTensorTransferManager { | ||
public: | ||
virtual ~DeviceTensorTransferManager() {} | ||
/// Copies the contents of \p tensor from the host to the \p location address | ||
/// on this device. Updates the tensor residency info. | ||
virtual void transferToDevice(Tensor &tensor, void *locationContext = nullptr, | ||
std::function<void(Error)> resultCB = | ||
[](Error) {}) = 0; | ||
|
||
/// Copies the device buffer associated with \p tensor to the host. | ||
/// The tensor must be resident on this device. If \p release is true, frees | ||
/// the device memory. Updates the tensor residency info. | ||
virtual void transferFromDevice(Tensor &tensor, bool release = true, | ||
std::function<void(Error)> resultCB = | ||
[](Error) {}) = 0; | ||
|
||
/// Releases the device buffer associated with \p tensor. | ||
virtual bool releaseDeviceTensor(void *locationContext) = 0; | ||
}; | ||
|
||
} // namespace glow | ||
|
||
#endif // GLOW_BASE_DEVICETENSORTRANSFERMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.