• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2024 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_MBUF_DEVICE_ADDRESS_H
17 #define MINDSPORE_MBUF_DEVICE_ADDRESS_H
18 
19 #include <string>
20 #include "include/backend/device_address.h"
21 
22 namespace mindspore {
23 namespace device {
24 class MbufDeviceAddress : public device::DeviceAddress {
25  public:
MbufDeviceAddress(void * ptr,size_t size)26   MbufDeviceAddress(void *ptr, size_t size) : DeviceAddress(ptr, size) {}
SetData(void * data)27   void SetData(void *data) { set_ptr(data); }
28 
SyncDeviceToHost(const ShapeVector & shape,size_t size,TypeId type,void * host_ptr)29   bool SyncDeviceToHost(const ShapeVector &shape, size_t size, TypeId type, void *host_ptr) const override {
30     MS_LOG(ERROR) << "Mbuf address does not support sync data from device to host, please use graph mode";
31     return false;
32   }
SyncHostToDevice(const ShapeVector & shape,size_t size,TypeId type,const void * host_ptr,const std::string & format)33   bool SyncHostToDevice(const ShapeVector &shape, size_t size, TypeId type, const void *host_ptr,
34                         const std::string &format) const override {
35     MS_LOG(ERROR) << "Mbuf address does not support sync data from host to device, please use graph mode";
36     return false;
37   }
SyncHostToDevice(const ShapeVector & shape,size_t size,TypeId type,const void * host_ptr)38   bool SyncHostToDevice(const ShapeVector &shape, size_t size, TypeId type, const void *host_ptr) const override {
39     MS_LOG(ERROR) << "Mbuf address does not support sync data from device to host, please use graph mode";
40     return false;
41   }
ClearDeviceMemory()42   void ClearDeviceMemory() override {}
GetDeviceType()43   device::DeviceType GetDeviceType() const { return DeviceType::kAscend; }
44 };
45 }  // namespace device
46 }  // namespace mindspore
47 #endif  // MINDSPORE_MBUF_DEVICE_ADDRESS_H
48