Top Level Implementation-ETM

什么是ETM?

上一篇讲了 abstract  view,这次讲一下跟它相近的一种block model ETM,ETM (Extracted Timing Model ) 是一种包含block 时序信息的抽象模型,使用 extract_model 命令抽取。它会把每个port的timing信息都保留下来,block内部的各种信息不会保留,另外,还保留了clk to inport 的timing arc,如下图所示。

图片

Owner做完block level后,去做top level时需要使用 block model,假如把一个block 看作一个 cell 的话,那么ETM 以及上面说的 abs view/ILM 就相当于这个cell 的lib 文件,里面能够看到这cell 边界的 timing/noise/power等信息。

例如出abstract  view时时可以把power 信息整出来的,需要设置:

set_scenario_status -leakage_power true -dynamic_power true [get_scenarios -filter active]set_app_options -name abstract.annotate_power -value true

怎么去生成ETM?

一般ETM 可以使用FC/ICC2/PT 产生,比较常用的工具时 PT,使用命令 extract_model ,可以使用-format 指定格式 .db/.lib,.db能过被大部分的S 家工具识别读取,但没法肉眼去看,如果你想肉眼去看或者使用第三方工具时可以存为 .lib 

使用FC/ICC2 生成:

# Open the design, create a frame view, and set the PrimeTime optionsopen block.nlib:block.designcreate_frame <options> ;# extract_model needs Frame for library  preparationset_pt_options -pt_exec_path <> -work_dir ETM_work_dir \ -post_link_script <tcl script with extract_model*  variables> \# To use StarRC for Parasitic extractionset_app_options -name extract.starrc_mode -value trueset_starrc_options -config <starrc_config_file># Create the ETM and generate the ETM cell libraryextract_model

一般情况下,写出来的 ETM library 保存在:

• [pwd]/ETM_Lib_work_dir/block_name/label_name/ for labelled blocks

• [pwd]/ETM_Lib_work_dir/block_name/ for non-labelled blocks

    据我了解使用FC/ICC2 产生ETM 比较少见,正常都是使用PT 产生,网上有看到有人用ICC2 生成ETM 会有一些问题,ICC2产生的block的etm,clock pin的port_type属性是signal而不是clock,导致其CTS阶段没法正常长tree,另外报告report_delay_calculation -from block/output port -to receiver/IN,transition为0,在PT中使用模块的.v和.spef展开分析时序时 transition的违例非常多。所以这里推荐使用Library Manager的normal flow来替代etm moded flow。

使用PT 生成的准备工作与 流程比较多,留在下一篇来写......

这是第79篇总结,后续的文章中会涉及到 很多sta 相关的内容,包含Constraints介绍/各种Reports详解以及debug/Clock相关/CRPR/POCV等,欢迎持续关注,已关注的请点赞

图片

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是使用BERT-ETM模型进行问答的代码示例: 1. 导入所需的库和模型 ```python import torch from transformers import BertTokenizer, BertForQuestionAnswering from etm.etm import ETM from etm.utils import get_device device = get_device() tokenizer = BertTokenizer.from_pretrained("bert-base-uncased") bert_model = BertForQuestionAnswering.from_pretrained("bert-base-uncased").to(device) etm_model = ETM(num_topics=50, num_embeddings=10000, hidden_size=512, num_layers=2).to(device) etm_model.load_state_dict(torch.load("path/to/etm/model.pth")) ``` 2. 定义问答函数 ```python def answer_question(question, context): # 对上下文和问题进行编码 encoded_dict = tokenizer.encode_plus(question, context, add_special_tokens=True, max_length=256, return_tensors='pt') input_ids = encoded_dict['input_ids'].to(device) attention_mask = encoded_dict['attention_mask'].to(device) # 使用BERT模型预测答案的起始和结束位置 start_scores, end_scores = bert_model(input_ids, attention_mask=attention_mask) start_index = torch.argmax(start_scores) end_index = torch.argmax(end_scores) # 根据预测的起始和结束位置提取答案 tokens = tokenizer.convert_ids_to_tokens(input_ids[0]) answer_tokens = tokens[start_index:end_index+1] answer = tokenizer.convert_tokens_to_string(answer_tokens) # 使用ETM模型对答案进行主题建模 with torch.no_grad(): embedding = etm_model.get_embedding_for_words([answer]).to(device) topic_weights = etm_model.get_topic_weights(embedding) topic_index = torch.argmax(topic_weights) # 返回答案和主题 return answer, topic_index ``` 3. 使用问答函数 ```python context = "The PyTorch library is used for building deep neural networks. It is one of the most popular open-source libraries for deep learning. PyTorch was developed by Facebook and is written in Python. It has a dynamic computational graph, which makes it easier to debug and optimize deep learning models." question = "Who developed PyTorch?" answer, topic = answer_question(question, context) print(f"Answer: {answer}") print(f"Topic index: {topic}") ``` 输出结果: ``` Answer: Facebook Topic index: 23 ``` 其中,主题索引23表示答案与主题模型中的第23个主题最相关。可以根据需要进行进一步的主题分析和处理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东坡ju士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值