Skip to content

Commit

Permalink
fix lint and build issue on web CI
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-dong-ms committed Oct 24, 2024
1 parent 5d0d07d commit e6b86e6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
2 changes: 1 addition & 1 deletion onnxruntime/core/framework/session_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ Status SessionState::PrepackConstantInitializedTensors(InlinedHashMap<std::strin
// If prepacked weights already read from ONNX data file (this happens we ORT reads data file with prepacked
// weights serialized), only need to set prepacked weights once to kernel.
is_kernel_prepacked = true;
ORT_THROW_IF_ERROR(kernel->SetPrePackTensor(input_idx,
ORT_THROW_IF_ERROR(kernel->SetPrePackTensor(input_idx,
*(constant_initialized_tensors[ort_value_idx].GetMutable<Tensor>())));
}
// Caching pre-packed weights is limited to shared initializers associated with the CPU EP for now
Expand Down
17 changes: 11 additions & 6 deletions onnxruntime/core/framework/tensorprotoutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ Status TensorProtoToOrtValueImpl(const Env& env, const std::filesystem::path& mo

namespace utils {

inline Status utils::GetExternalDataInfo(const ONNX_NAMESPACE::TensorProto& tensor_proto,
const std::filesystem::path& tensor_proto_dir,
std::basic_string<ORTCHAR_T>& external_file_path,
onnxruntime::FileOffsetType& file_offset,
SafeInt<size_t>& tensor_byte_size,
bool& pre_packed) {
static Status GetExternalDataInfo(const ONNX_NAMESPACE::TensorProto& tensor_proto,
const std::filesystem::path& tensor_proto_dir,
std::basic_string<ORTCHAR_T>& external_file_path,
onnxruntime::FileOffsetType& file_offset,
SafeInt<size_t>& tensor_byte_size,
bool& pre_packed) {
ORT_RETURN_IF_NOT(onnxruntime::utils::HasExternalData(tensor_proto),
"Tensor does not have external data to read from.");

Expand Down Expand Up @@ -268,6 +268,11 @@ void SetRawDataInTensorProto(ONNX_NAMESPACE::TensorProto& tensor_proto, std::str
tensor_proto.set_raw_data(std::move(param));
}

Status GetExternalDataInfo(const ONNX_NAMESPACE::TensorProto& tensor_proto, const std::filesystem::path& tensor_proto_dir, std::basic_string<ORTCHAR_T>& external_file_path, onnxruntime::FileOffsetType& file_offset, SafeInt<size_t>& tensor_byte_size) {
bool pre_packed = false;
return GetExternalDataInfo(tensor_proto, tensor_proto_dir, external_file_path, file_offset, tensor_byte_size, pre_packed);
}

void ConvertRawDataInTensorProto(TensorProto* tensor) {
size_t element_size = 1;
char* bytes = NULL;
Expand Down
26 changes: 3 additions & 23 deletions onnxruntime/core/framework/tensorprotoutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,13 @@

namespace onnxruntime {
namespace utils {
/**
* This function is used to get the external data info from the given tensor proto.
* @param tensor_proto given initializer tensor
* @param tensor_proto_dir directory of the tensor proto file
* @param external_file_path output external file path
* @param file_offset output tensor offset
* @param tensor_byte_size output tensor byte size
* @pre_packed whether output tensor is prepacked buffer serialize as tensor
* @returns Status::OK() if the function is executed successfully
*/
inline Status GetExternalDataInfo(const ONNX_NAMESPACE::TensorProto& tensor_proto,
const std::filesystem::path& tensor_proto_dir,
std::basic_string<ORTCHAR_T>& external_file_path,
onnxruntime::FileOffsetType& file_offset,
SafeInt<size_t>& tensor_byte_size,
bool& pre_packed);

inline Status GetExternalDataInfo(const ONNX_NAMESPACE::TensorProto& tensor_proto,
Status GetExternalDataInfo(const ONNX_NAMESPACE::TensorProto& tensor_proto,
const std::filesystem::path& tensor_proto_dir,
std::basic_string<ORTCHAR_T>& external_file_path,
onnxruntime::FileOffsetType& file_offset,
SafeInt<size_t>& tensor_byte_size) {
bool pre_packed = false;
return utils::GetExternalDataInfo(tensor_proto, tensor_proto_dir, external_file_path, file_offset, tensor_byte_size, pre_packed);
}
SafeInt<size_t>& tensor_byte_size);

/**
/**
* This function is used to convert the endianess of Tensor data.
* Mostly, will be used in big endian system to support the model file
* generated on little endian system.
Expand Down

0 comments on commit e6b86e6

Please sign in to comment.