[Functions] Add +-*/ operators and reshape for FDTensor (#655)

* Add +-*/ functions

* Add same dims test case for operations

* add broadcast 0

* Add broadcast dim2 testcase

* Add broadcast dim3 and dim4 testcase

* Add +-*/ operators

* Add mixed operation

* refresh code style

* Add reshape op

* update code style
This commit is contained in:
Jack Zhou
2022-11-23 11:34:02 +08:00
committed by GitHub
parent c11bfb8341
commit de98163efa
12 changed files with 1163 additions and 126 deletions

7
fastdeploy/core/fd_tensor.h Executable file → Normal file
View File

@@ -57,9 +57,7 @@ struct FASTDEPLOY_DECL FDTensor {
void* Data();
bool IsShared() {
return external_data_ptr != nullptr;
}
bool IsShared() { return external_data_ptr != nullptr; }
void StopSharing();
@@ -116,6 +114,7 @@ struct FASTDEPLOY_DECL FDTensor {
const FDDataType& data_type, const std::string& tensor_name = "",
const Device& new_device = Device::CPU);
bool Reshape(const std::vector<int64_t>& new_shape);
// Debug function
// Use this function to print shape, dtype, mean, max, min
// prefix will also be printed as tag
@@ -141,7 +140,7 @@ struct FASTDEPLOY_DECL FDTensor {
static void CopyBuffer(void* dst, const void* src, size_t nbytes,
const Device& device = Device::CPU,
bool is_pinned_memory = false);
bool is_pinned_memory = false);
};
} // namespace fastdeploy