- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
// Returns true iff this op kernel is considered "expensive". The
// runtime may use this flag to optimize graph execution for example
// to "inline" inexpensive kernels.
virtual bool IsExpensive() { return expensive_; }
似乎默认情况下 GPU are considered as inexpensive 上的所有操作而 CPU、SYSL 则被标记为昂贵。
expensive
的定义和作用有点难以理解。没有information in the guide .
IsExpensive
应为 false, true
时是否有任何具体指导? AsyncOp
(如 RemoteFusedGraphExecuteOp
)都很昂贵,MPIAllgatherOp
似乎被定义为不昂贵。这不是矛盾吗?我在问,因为 IdentityOp
被明确标记为便宜。我想知道,我是否也应该在我的自定义操作中重写此方法,因为每个 CPU 版本(甚至 任何 自定义代码)都被标记为昂贵。
XLA 的整个逻辑似乎是关于 an instruction is expensive或不。因此,这可能是需要考虑的重要部分。因此,关于真/假的抛硬币可能不是在我的自定义操作中决定返回值的最佳方式。
最佳答案
在回答您的问题之前,我认为值得尝试了解 TensorFlow 如何使用线程来完成您的工作。为此,我建议您阅读 this related and very good SO post .
您会发现 TensorFlow 使用线程池来完成工作。昂贵的 Ops 被安排在线程池上执行,而廉价的 Ops 是“内联”执行的,这意味着由安排任务的同一线程执行(旁注:从您链接的源文件中,您只发现一个异常,即当inline_ready
队列是空的,线程可以自己执行最后一个昂贵的操作。)。
考虑到这一点,让我们尝试回答您的问题。
- Is there any specific guideline when IsExpensive should be false, true?
我在 TensorFlow 手册中找不到具体的指导方针,但是,从我们上面讨论的内部结构来看,当将任务调度到线程池的偏移量与需要执行任务的时间。
- What's the effect if an operation is flagged as expensive? So far I can only tell, that active profiling uses this just as a hint ? The only place querying this property is in the scheduler but without explaining what being inline means.
效果如下,每次Ops的IsExpensive
方法返回false
可能会被插入inline_ready
队列,可能阻塞线程从执行进一步的任务,从而停止你的程序。相反,如果 Ops IsExpensive
方法返回 true,它将被调度到线程池上执行,并且调度线程可以自由地继续在进程循环中执行其任务。
- In conjunction with "1." should I care about it in my custom Ops?
我认为您应该关心并尝试尽可能多地推理您 Op. 的执行时间。然后决定如何实现 IsExpensive
方法。
- While it makes sense, that any AsyncOp (like RemoteFusedGraphExecuteOp) is expensive, MPIAllgatherOp seems to be defined as not expensive. Isn't this a contradiction?
不,这并不矛盾。如果您阅读MPIAllgatherOp
的评论,您会发现以下内容:
// Although this op is handled asynchronously, the ComputeAsync call is
// very inexpensive. It only sets up a CollectiveOpRecord and places it
// in the table for the background thread to handle. Thus, we do not need
// a TF pool thread to perform the op.
其中明确指出,为线程池调度此任务几乎只是开销。因此,内联执行它很有意义。
关于c++ - TensorFlow 操作 ` IsExpensive()` 的含义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51397757/
这个问题在这里已经有了答案: Towards the "true" definition of JAVA_HOME (5 个答案) 关闭 4 年前。 为什么 ActiveMQ 提供者需要设置 JAV
这个问题在这里已经有了答案: What is a lambda expression in C++11? (10 个答案) 关闭 8 年前。 这是来自 boosts asio 的一个例子。这是什么意
这个问题在这里已经有了答案: What does the double colon (::) mean in CSS? (3 个答案) 关闭 7 年前。 我经常看到这种用法。特别是伪类。“::”在
嗨,另一个愚蠢的简单问题。我注意到在Apple框架中的某些typedef中使用符号"<<"谁能告诉我这是什么意思?: enum { UIViewAutoresizingNone
someObject.$() 是什么意思? 我正在浏览 sapui5 工具包中的 tilecontainer-dbg 文件,发现了这个: var oDomRef = this.$(); or some
这个问题已经有答案了: How to interpret function parameters in software and language documentation? (4 个回答) 已关闭
我遇到过这个语法。任何人都可以解释一下 getArg1ListInfo:()=>(object.freeze(arg1)) 的含义 function foo (arg1,arg2) { let
对于子类,我有以下代码: class child1 : public parent { public: static parent* function1(void) { ret
这个问题在这里已经有了答案: What does "|=" mean? (pipe equal operator) (6 个答案) 关闭 1 年前。 我有一部分代码包含以下功能: void Keyb
以下在 C++ 中是什么意思? typedef PComplex RComplex [100]; 请注意,PComplex 是我代码中的用户定义类型。 谢谢 最佳答案 RComplex 是 PComp
在我的 Lisp 代码中,我有函数 (nfa-regex-compile),它创建一个包含初始状态、转换和最终状态的 cons 列表(表示自动机的节点)从作为参数给出的正则表达式开始。 在这种情况下,
以下文字摘自 Learning Spark 第 3 章 One issue to watch out for when passing functions is inadvertently seria
PHP 文档 block 中以下内容的含义是什么: #@+ zend框架代码中的一个例子: /**#@+ * @const string Version constant numbers */ c
由于 python 的一些版本控制问题,我必须使用自定义函数来比较 HMAC (SHA512)。为此,我找到了这个函数: def compare_digest(x, y): if not (i
取自this answer here : static const qi::rule node = '{' >> *node >> '}' | +~qi::char_("{}"); 请注意,声明了名称
我正在查看 chi 包的文档。我看到类似的东西: https://github.com/pressly/chi/blob/master/_examples/rest/main.go#L154 data
我想知道如果我采用值为 8 的 INT,这是否意味着我只能从 1 到 99999999 或从 1 到 4294967295 UNSIGNED? 最佳答案 文档似乎很清楚这一点: Numeric Typ
我想知道如果我采用值为 8 的 INT,这是否意味着我只能从 1 到 99999999 或从 1 到 4294967295 UNSIGNED? 最佳答案 文档似乎很清楚这一点: Numeric Typ
这个问题在这里已经有了答案: 关闭9年前。 Possible Duplicate: Does “/* (non-javadoc)” have a well-understood meaning? 以下
在 Prolog 代码中,可以使用“ headless ”Horn 子句将指令传递给编译器,这些子句与指向左侧的物质蕴涵 ':-' (⇐) 的左侧没有头部关系。例如,导入模块或声明 Unit Test
我是一名优秀的程序员,十分优秀!