-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rpc] Implemented rpc logging #11232
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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,93 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 TVM_RUNTIME_MINRPC_MINRPC_INTERFACES_H_ | ||
#define TVM_RUNTIME_MINRPC_MINRPC_INTERFACES_H_ | ||
|
||
#include <tvm/runtime/c_runtime_api.h> | ||
|
||
#include "rpc_reference.h" | ||
|
||
namespace tvm { | ||
namespace runtime { | ||
|
||
/*! | ||
* \brief Return interface used in ExecInterface to generate and send the responses. | ||
*/ | ||
class MinRPCReturnInterface { | ||
public: | ||
virtual ~MinRPCReturnInterface() {} | ||
/*! * \brief sends a response to the client with kTVMNullptr in payload. */ | ||
virtual void ReturnVoid() = 0; | ||
|
||
/*! * \brief sends a response to the client with one kTVMOpaqueHandle in payload. */ | ||
virtual void ReturnHandle(void* handle) = 0; | ||
|
||
/*! * \brief sends an exception response to the client with a kTVMStr in payload. */ | ||
virtual void ReturnException(const char* msg) = 0; | ||
|
||
/*! * \brief sends a packed argument sequnce to the client. */ | ||
virtual void ReturnPackedSeq(const TVMValue* arg_values, const int* type_codes, int num_args) = 0; | ||
|
||
/*! * \brief sends a copy of the requested remote data to the client. */ | ||
virtual void ReturnCopyFromRemote(uint8_t* data_ptr, uint64_t num_bytes) = 0; | ||
|
||
/*! * \brief sends an exception response to the client with the last TVM erros as the message. */ | ||
virtual void ReturnLastTVMError() = 0; | ||
|
||
/*! * \brief internal error. */ | ||
virtual void ThrowError(RPCServerStatus code, RPCCode info = RPCCode::kNone) = 0; | ||
}; | ||
|
||
/*! | ||
* \brief Execute interface used in MinRPCServer to process different received commands | ||
*/ | ||
class MinRPCExecInterface { | ||
public: | ||
virtual ~MinRPCExecInterface() {} | ||
|
||
/*! * \brief Execute an Initilize server command. */ | ||
virtual void InitServer(int num_args) = 0; | ||
|
||
/*! * \brief calls a function specified by the call_handle. */ | ||
virtual void NormalCallFunc(uint64_t call_handle, TVMValue* values, int* tcodes, | ||
int num_args) = 0; | ||
|
||
/*! * \brief Execute a copy from remote command by sending the data described in arr to the client | ||
*/ | ||
virtual void CopyFromRemote(DLTensor* arr, uint64_t num_bytes, uint8_t* data_ptr) = 0; | ||
|
||
/*! * \brief Execute a copy to remote command by receiving the data described in arr from the | ||
* client */ | ||
virtual int CopyToRemote(DLTensor* arr, uint64_t num_bytes, uint8_t* data_ptr) = 0; | ||
|
||
/*! * \brief calls a system function specified by the code. */ | ||
virtual void SysCallFunc(RPCCode code, TVMValue* values, int* tcodes, int num_args) = 0; | ||
|
||
/*! * \brief internal error. */ | ||
virtual void ThrowError(RPCServerStatus code, RPCCode info = RPCCode::kNone) = 0; | ||
|
||
/*! * \brief return the ReturnInterface pointer that is used to generate and send the responses. | ||
*/ | ||
virtual MinRPCReturnInterface* GetReturnInterface() = 0; | ||
}; | ||
|
||
} // namespace runtime | ||
} // namespace tvm | ||
#endif // TVM_RUNTIME_MINRPC_MINRPC_INTERFACES_H_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkatanbaf @mehrdadh @areusch why is this header needed ?
Is it just because to use the type ssize_t ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also do we want this added to c_runtime_api ?
(As this is affecting bare metal deployments)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I forgot about that. I believe this was needed on Windows to define tvm_ssize_t properly. @mkatanbaf could you confirm that? If so, perhaps we can place this #include behind
#ifdef _MSC_VER
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manupa-arm @areusch The <stdio.h> is needed to define ssize_t (not on windows, for windows we directly used int64_t and int32_t instead of ssize_t). The <sys/type.h> was needed on hexagon.
We discussed the proper place to add this definition and landed on the c_runtime_api. @manupa-arm please lmk if you have another suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a naive look at the PR, It seems it is being used in rpc related sources (that uses PosixWrite and already assumes the presense of the OS). How about somewhere that is specific to rpc ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manupa-arm thanks. there was an issue with ssize_t being defined in other parts of the code which caused a redefinition error. our plan was to unify the different definitions in a subsequent PR soon. I'll check if I can find a better place for the definition in order to minimize the effect on bare metal deployments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps we can move this to e.g.
tvm/support/types.h
or something of that nature.