当前位置: 首页 > news >正文

专门做钱币的网站石碣镇仿做网站

专门做钱币的网站,石碣镇仿做网站,网站建设单位是什么意思,wordpress 页面宽度文章目录 mutable其他Reference mutable 当你定义一个类#xff0c;并且在将类的实例当作参数传递过程中#xff0c;需要用const Class* cls_ptr方式传递时#xff0c;会存在一种情况#xff0c;就是虽然cls_ptr为const#xff0c;但是你还需要调用该类的方法#xff0c… 文章目录 mutable其他Reference mutable 当你定义一个类并且在将类的实例当作参数传递过程中需要用const Class* cls_ptr方式传递时会存在一种情况就是虽然cls_ptr为const但是你还需要调用该类的方法修改类中一些属性来满足自己的需求这个时候就需要将一些需要修改不受类的const修饰词影响的属性定义为mutable属性。 class Context {void set_stream(Stream stream) { stream_ stream; }// 当Context的实例被const修饰时只能调用void Function const{}的方法。否则会报错误。const Stream stream() const { return stream_; }mutable Stream stream_; } 源码参考https://github.com/google/mediapipe/blob/3e9f86e580ad89519d8e7a228d247ca330d71409/mediapipe/framework/formats/tensor.h#L391 struct MtlResources; class Tensor {class View {public:// Non-copyable.View(const View) delete;View operator(const View) delete;protected:explicit View(std::unique_ptrabsl::MutexLock lock): lock_(std::move(lock)) {}std::unique_ptrabsl::MutexLock lock_;};public:// No resources are allocated here.enum class ElementType {kNone,kFloat16,kFloat32,kUInt8,kInt8,kInt32,kChar,kBool};struct Shape {Shape() default;Shape(std::initializer_listint dimensions) : dims(dimensions) {}Shape(const std::vectorint dimensions) : dims(dimensions) {}Shape(std::initializer_listint dimensions, bool is_dynamic): dims(dimensions), is_dynamic(is_dynamic) {}Shape(const std::vectorint dimensions, bool is_dynamic): dims(dimensions), is_dynamic(is_dynamic) {}int num_elements() const {return std::accumulate(dims.begin(), dims.end(), 1,std::multipliesint());}std::vectorint dims;// The Tensor has dynamic rather than static shape so the TFLite interpreter// needs to be reallocated. Only relevant for CPU.bool is_dynamic false;};// Quantization parameters corresponding to the zero_point and scale value// made available by TfLite quantized (uint8/int8) tensors.struct QuantizationParameters {QuantizationParameters() default;QuantizationParameters(float scale, int zero_point): scale(scale), zero_point(zero_point) {}float scale 1.0f;int zero_point 0;};...private:friend class MtlBufferView;void Move(Tensor*);void Invalidate();ElementType element_type_;Shape shape_;QuantizationParameters quantization_parameters_;// The flags describe the current source of truth resource type.enum {kValidNone 0,kValidCpu 1 0,kValidMetalBuffer 1 1,kValidOpenGlBuffer 1 2,kValidOpenGlTexture2d 1 3,kValidAHardwareBuffer 1 5,};// A list of resource which are currently allocated and synchronized between// each-other: valid_ kValidCpu | kValidMetalBuffer;mutable int valid_ 0;// The mutex is locked by Get*View and is kept by all Views.mutable absl::Mutex view_mutex_;mutable void* cpu_buffer_ nullptr;void AllocateCpuBuffer() const;// Forward declaration of the MtlResources provides compile-time verification// of ODR if this header includes any actual code that uses MtlResources.mutable std::unique_ptrMtlResources mtl_resources_;#ifdef MEDIAPIPE_TENSOR_USE_AHWBmutable std::shared_ptrHardwareBuffer ahwb_;// Allocates and pools HardwareBuffer instances. Holding the shared_ptr to the// pool ensures it outlives the internal ahwb_.std::shared_ptrHardwareBufferPool hardware_buffer_pool_;// Signals when GPU finished writing into SSBO so AHWB can be used then. Or// signals when writing into AHWB has been finished so GPU can read from SSBO.// Sync and FD are bound together.mutable EGLSyncKHR fence_sync_ EGL_NO_SYNC_KHR;// This FD signals when the writing into the SSBO has been finished.mutable int ssbo_written_ -1;// An externally set FD that is wrapped with the EGL sync then to synchronize// AHWB - OpenGL SSBO.mutable int fence_fd_ -1;// Reading from SSBO has been finished so SSBO can be released.mutable GLsync ssbo_read_ 0;// An externally set function that signals when it is safe to release AHWB.// If the input parameter is true then wait for the writing to be finished.mutable FinishingFunc ahwb_written_;mutable std::functionvoid() release_callback_;bool AllocateAHardwareBuffer(int size_alignment 0) const;void CreateEglSyncAndFd() const; #endif // MEDIAPIPE_TENSOR_USE_AHWB// Use Ahwb for other views: OpenGL / CPU buffer.mutable bool use_ahwb_ false;mutable uint64_t ahwb_tracking_key_ 0;// TODO: Tracks all unique tensors. Can grow to a large number. LRU// (Least Recently Used) can be more predicted.// The value contains the size alignment parameter.static inline absl::flat_hash_mapuint64_t, int ahwb_usage_track_;// Expects the target SSBO to be already bound.bool AllocateAhwbMapToSsbo() const;bool InsertAhwbToSsboFence() const;void MoveAhwbStuff(Tensor* src);void ReleaseAhwbStuff();void* MapAhwbToCpuRead() const;void* MapAhwbToCpuWrite() const;void MoveCpuOrSsboToAhwb() const;// Set current tracking key, set use ahwb if the key is already marked.void TrackAhwbUsage(uint64_t key) const;#if MEDIAPIPE_OPENGL_ES_VERSION MEDIAPIPE_OPENGL_ES_30mutable std::shared_ptrmediapipe::GlContext gl_context_;mutable GLuint opengl_texture2d_ GL_INVALID_INDEX;mutable GLuint frame_buffer_ GL_INVALID_INDEX;mutable int texture_width_;mutable int texture_height_; #ifdef __EMSCRIPTEN__mutable bool texture_is_half_float_ false; #endif // __EMSCRIPTEN__void AllocateOpenGlTexture2d() const; #if MEDIAPIPE_OPENGL_ES_VERSION MEDIAPIPE_OPENGL_ES_31mutable GLuint opengl_buffer_ GL_INVALID_INDEX;void AllocateOpenGlBuffer() const; #endif // MEDIAPIPE_OPENGL_ES_VERSION MEDIAPIPE_OPENGL_ES_31bool NeedsHalfFloatRenderTarget() const; #endif // MEDIAPIPE_OPENGL_ES_VERSION MEDIAPIPE_OPENGL_ES_30 };其他 上层用非const底层传递过程中用const修饰的 一个思考就是在不同调用层级中会使用不同的方法对同样的属性操作比如在上层context是非const的所以可以调用一些set方法设置一些属性当传递到下层时我们希望他们只使用这些设置好的属性那么我们就将context的实例修饰成const这样他只能调用这些void Function const{}方法。 mutable 的使用思考 是不是能够用于管理类的方法控制哪些可以被const实例使用哪些可以被非const实例使用这样管理起来可以控制一些类的使用权限情况–方法层级的使用权限。 Reference
http://www.pierceye.com/news/404639/

相关文章:

  • ps做分享类网站效果图设计公司工作室创业规划
  • 个人虚拟机做网站设计实例网站
  • 衡阳企业网站wordpress置顶文章顺序
  • 网站建设宗旨是指郑州有名的做网页的公司
  • 怎么0成本做网站企业网站如何设计网页
  • 做韦恩图网站课程分销平台
  • html5网站建设中企业整站推广
  • 织梦网站打开速度慢做抢单软件的网站
  • 51单片机可以做网站怎么建设游戏试玩平台网站
  • 汕头网站建设方案维护wordpress百度熊掌
  • 牛街网站建设产品vi设计都包括什么
  • 网站需要多大宽带网站发展的方向
  • 陈光锋网站运营推广新动向故城建设银行网站
  • 备案后网站可以改名吗临颖网站建设
  • 临沭县建设局官方网站怎样做外贸网站推广
  • 手机网站支付一个简单的网页代码带图片
  • 向公司申请请做网站广州网站推广教程
  • 用QQ群做网站排名交互式网站app
  • 正规免费发布信息网站国外网站界面
  • 浏览国外网站 dns网店运营推广方案
  • wordpress弹幕视频插件广西seo搜索引擎优化
  • 网站开发与维护工资多少网络公司排名兴田德润
  • wordpress主题ux壹搜网站建设优化排名
  • 试剂产品商城网站建设杭州网站现场备案
  • 高唐企业建网站服务商wordpress google
  • 重庆网站开发商城最近新闻有哪些
  • 电商网站设计线路图有哪些网络推广平台
  • 海门市建设局网站科技与应用
  • 北京做网站s免费做app网站有哪些
  • 免费制作网页的网站网络营销师报名官网