1 Star 0 Fork 0

snowingbear/onnx-tensorrt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ShapedWeights.hpp 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
Kevin Chen 提交于 2022-06-15 01:28 +08:00 . TensorRT 8.4 GA ONNX Parser Release (#851)
/*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <NvInfer.h>
#include <onnx/onnx_pb.h>
namespace onnx2trt
{
class ShapedWeights
{
public:
using DataType = int32_t;
//! Create 1D zero-length ShapedWeights of given type, count()==0, and values=nullptr.
static ShapedWeights empty(DataType type);
//! Construct ShapedWeights that is not expected to be usuable,
//! except with `operator=` and method `setName()`.
ShapedWeights() = default;
explicit ShapedWeights(DataType type, void* values, nvinfer1::Dims shape_);
size_t count() const;
size_t size_bytes() const;
const char* getName() const;
void setName(const char* name);
//! True if values exist.
explicit operator bool() const;
operator nvinfer1::Weights() const;
template <typename T>
T& at(size_t index)
{
assert(index >= 0 && (index * sizeof(T)) < size_bytes());
return static_cast<T*>(values)[index];
}
template <typename T>
const T& at(size_t index) const
{
assert(index >= 0 && (index * sizeof(T)) < size_bytes());
return static_cast<const T*>(values)[index];
}
public:
DataType type{static_cast<DataType>(-1)};
void* values{nullptr};
nvinfer1::Dims shape{-1, {}};
const char* name{};
};
class IImporterContext;
} // namespace onnx2trt
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/snowingbear/onnx-tensorrt.git
git@gitee.com:snowingbear/onnx-tensorrt.git
snowingbear
onnx-tensorrt
onnx-tensorrt
main

搜索帮助