-
Notifications
You must be signed in to change notification settings - Fork 88
Add some tensor dtype convert APIs #576
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
Conversation
For pre/post process. Type: Code Refine
src/tim/vx/tensor.cc
Outdated
/**************************************************************************** | ||
* | ||
* Copyright (c) 2020-2023 Vivante Corporation | ||
* Copyright (c) 2020 Vivante Corporation |
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.
copyright should not changed.
src/tim/vx/tensor.cc
Outdated
#define ENABLE_TENSOR_HNDL 1 | ||
#endif | ||
|
||
#include <stdio.h> |
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.
why include this?
include/tim/vx/tensor.h
Outdated
virtual void unmap() = 0; | ||
virtual bool IsPlaceHolder() = 0; | ||
virtual bool IsConstTensor() = 0; | ||
virtual const void* GetDataRef() const = 0; |
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.
Add a comment for GetDataRef() since this is an dangerous API.
Comment: "Never use this api expect AcuityLite codegen"
include/tim/vx/tensor.h
Outdated
virtual bool IsPlaceHolder() = 0; | ||
virtual bool IsConstTensor() = 0; | ||
virtual const void* GetDataRef() const = 0; | ||
virtual bool SaveTensorToTextByFp32(const char* filename) = 0; |
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.
Suggest use SaveAsRawFp32( std::ostream& os);
For file operation, you can use ofstream from generated code.
include/tim/vx/tensor.h
Outdated
virtual bool IsConstTensor() = 0; | ||
virtual const void* GetDataRef() const = 0; | ||
virtual bool SaveTensorToTextByFp32(const char* filename) = 0; | ||
virtual bool Float32ToDtype(float fval, uint8_t* tensorData, uint32_t stride) = 0; |
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.
Should not be
namespace tim::vx::utils {
float32ToDtype(const std::vector&, uint8_t* destData, TensorSpec& targetSpec);
or
static function of tensor class
}
For pre/post process.
Type: Code Refine