Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add isReferenced function to querry the referenced state

  • Loading branch information...
commit 585a24c6011fc78e30fbcdbb4513e30a493da06a 1 parent 70a2177
@koraykv koraykv authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 pkg/torch/File.lua
View
13 pkg/torch/File.lua
@@ -42,12 +42,25 @@ function File:isWritableObject(object)
end
function File:referenced(ref)
+ -- we use an environment to keep a record of written objects
+ if not torch.getenv(self).writeObjects then
+ torch.setenv(self, {writeObjects={}, writeObjectsRef={}, readObjects={}})
+ end
local env = torch.getenv(self)
env.force = not ref
torch.setenv(self,env)
return self
end
+function File:isReferenced()
+ -- if no environment, then no forcing setup yet
+ if not torch.getenv(self).writeObjects then
+ return true
+ end
+ local env = torch.getenv(self)
+ return not env.force
+end
+
function File:writeObject(object)
-- we use an environment to keep a record of written objects
if not torch.getenv(self).writeObjects then
Please sign in to comment.
Something went wrong with that request. Please try again.