You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

grpc_client.h 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Copyright 2020 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_DEBUG_DEBUGGER_GRPC_CLIENT_H_
  17. #define MINDSPORE_CCSRC_DEBUG_DEBUGGER_GRPC_CLIENT_H_
  18. #include <grpcpp/grpcpp.h>
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <openssl/pem.h>
  22. #include <openssl/err.h>
  23. #include <openssl/pkcs12.h>
  24. #include <string>
  25. #include <list>
  26. #include <memory>
  27. #include "proto/debug_grpc.grpc.pb.h"
  28. using debugger::EventListener;
  29. using debugger::EventReply;
  30. using debugger::GraphProto;
  31. using debugger::Metadata;
  32. using debugger::TensorProto;
  33. using debugger::WatchpointHit;
  34. namespace mindspore {
  35. class GrpcClient {
  36. public:
  37. // constructor
  38. GrpcClient(const std::string &host, const std::string &port, const bool &ssl_certificate,
  39. const std::string &certificate_dir, const std::string &certificate_passphrase);
  40. // deconstructor
  41. ~GrpcClient() = default;
  42. // init
  43. void Init(const std::string &host, const std::string &port, const bool &ssl_certificate,
  44. const std::string &certificate_dir, const std::string &certificate_passphrase);
  45. // reset
  46. void Reset();
  47. EventReply WaitForCommand(const Metadata &metadata);
  48. EventReply SendMetadata(const Metadata &metadata);
  49. EventReply SendGraph(const GraphProto &graph);
  50. EventReply SendTensors(const std::list<TensorProto> &tensors);
  51. EventReply SendWatchpointHits(const std::list<WatchpointHit> &watchpoints);
  52. private:
  53. std::unique_ptr<EventListener::Stub> stub_;
  54. };
  55. } // namespace mindspore
  56. #endif // MINDSPORE_CCSRC_DEBUG_DEBUGGER_GRPC_CLIENT_H_