• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2021 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef MINDSPORE_CCSRC_RUNTIME_DEVICE_CPU_CPU_DEVICE_ADDRESS_H_
17 #define MINDSPORE_CCSRC_RUNTIME_DEVICE_CPU_CPU_DEVICE_ADDRESS_H_
18 
19 #include <string>
20 #include <vector>
21 #include "runtime/device/device_address.h"
22 #include "utils/shape_utils.h"
23 
24 namespace mindspore {
25 namespace device {
26 namespace cpu {
27 class CPUDeviceAddress : public DeviceAddress {
28  public:
CPUDeviceAddress(void * ptr,size_t size)29   CPUDeviceAddress(void *ptr, size_t size) : DeviceAddress(ptr, size) {}
30 
CPUDeviceAddress(void * ptr,size_t size,const string & format,TypeId type_id)31   CPUDeviceAddress(void *ptr, size_t size, const string &format, TypeId type_id)
32       : DeviceAddress(ptr, size, format, type_id) {}
33 
CPUDeviceAddress(void * ptr,size_t size,const std::string & format,TypeId type_id,const KernelWithIndex & node_index)34   CPUDeviceAddress(void *ptr, size_t size, const std::string &format, TypeId type_id, const KernelWithIndex &node_index)
35       : DeviceAddress(ptr, size, format, type_id, node_index) {}
36 
37   ~CPUDeviceAddress() override;
38 
39   bool SyncDeviceToHost(const ShapeVector &shape, size_t size, TypeId type, void *host_ptr) const override;
40   bool SyncHostToDevice(const ShapeVector &shape, size_t size, TypeId type, const void *host_ptr,
41                         const std::string &format = "DefaultFormat") const override;
42   bool DumpMemToFile(const std::string &filepath, const std::string &host_fmt, const ShapeVector &host_shape,
43                      TypeId host_type, bool trans_flag) const override;
44   void ClearDeviceMemory() override;
DeviceType()45   DeviceAddressType DeviceType() const override { return DeviceAddressType::kCPU; }
46 };
47 }  // namespace cpu
48 }  // namespace device
49 }  // namespace mindspore
50 
51 #endif  // MINDSPORE_CCSRC_RUNTIME_DEVICE_CPU_CPU_DEVICE_ADDRESS_H_
52